diff --git a/src/calng/AgipdCorrection.py b/src/calng/AgipdCorrection.py index c0b1d9a4faa406be2fa126c9f7a8d568dbf031ec..baaaa95c6e7b1649814bd7b7e9ba11a956778563 100644 --- a/src/calng/AgipdCorrection.py +++ b/src/calng/AgipdCorrection.py @@ -12,7 +12,6 @@ from karabo.bound import ( OVERWRITE_ELEMENT, STRING_ELEMENT, VECTOR_STRING_ELEMENT, - State, ) from . import base_gpu, calcat_utils, utils @@ -624,7 +623,6 @@ class AgipdCorrection(BaseCorrection): self._has_updated_bad_pixel_selection = False - def _initialization(self): self._update_bad_pixel_selection() super()._initialization() diff --git a/src/calng/DsscCorrection.py b/src/calng/DsscCorrection.py index c228648a01057c0d44719a2a316792497f705adb..650dcd47258dd6bfeddbfd8e948a82e0018a6db2 100644 --- a/src/calng/DsscCorrection.py +++ b/src/calng/DsscCorrection.py @@ -7,7 +7,6 @@ from karabo.bound import ( KARABO_CLASSINFO, OVERWRITE_ELEMENT, VECTOR_STRING_ELEMENT, - State, ) from . import base_gpu, calcat_utils, utils diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py index 1bfa18953f6e4987247d749635d09ff74aee3a48..db273a91f30e62a3cf78bb6e8f28f31b214270d1 100644 --- a/src/calng/base_correction.py +++ b/src/calng/base_correction.py @@ -1,4 +1,3 @@ -import collections import enum import gc import pathlib @@ -771,7 +770,7 @@ class BaseCorrection(PythonDevice): ) elif name.startswith("browse_schema"): if ":" in name: - prefix = name[len("browse_schema:") :] + prefix = name[len("browse_schema:"):] else: prefix = "managed" payload["data"] = scenes.recursive_subschema_scene( diff --git a/src/tests/problem.py b/src/tests/problem.py index 97c2ca2cbb25310492561d267a482147c0751ce9..a9590844bdc35ec0f69a56eff5856af995fab51d 100644 --- a/src/tests/problem.py +++ b/src/tests/problem.py @@ -3,6 +3,7 @@ from calng import utils calls = 0 + @utils.threadsafe_cache def will_raise_once(argument): global calls @@ -11,6 +12,7 @@ def will_raise_once(argument): raise Exception("That's just what I do") return argument + 1 + try: will_raise_once(0) except Exception as ex: diff --git a/src/tests/test_agipd_kernels.py b/src/tests/test_agipd_kernels.py index 73b776aba85acf5e34bb5a671f3b484e3c57b8b9..8f0f9aca56b29ccfd914b3eda510ca32d5bfca56 100644 --- a/src/tests/test_agipd_kernels.py +++ b/src/tests/test_agipd_kernels.py @@ -1,7 +1,6 @@ import h5py import numpy as np import pathlib -import pytest from calng import AgipdCorrection diff --git a/src/tests/test_calcat_utils.py b/src/tests/test_calcat_utils.py index 4b647c805876766ccc9fc66a36576788f3f216e5..91be20dcdf688c1771488b56801793082ba5d37b 100644 --- a/src/tests/test_calcat_utils.py +++ b/src/tests/test_calcat_utils.py @@ -1,5 +1,4 @@ import pathlib -import timeit from calng import AgipdCorrection, DsscCorrection from calng.utils import Stopwatch @@ -101,22 +100,22 @@ def test_agipd_constants_and_caching_and_async(): with Stopwatch() as timer_async_cold: # TODO: put this sort of thing in BaseCalcatFriend - threads = [] - for constant in AgipdCorrection.AgipdConstants: - thread = device.calibration_constant_manager.get_constant_version_and_call_me_back( + threads = [ + device.calibration_constant_manager.get_constant_version_and_call_me_back( constant, backcall ) - threads.append(thread) + for constant in AgipdCorrection.AgipdConstants + ] for thread in threads: thread.join() with Stopwatch() as timer_async_warm: - threads = [] - for constant in AgipdCorrection.AgipdConstants: - thread = device.calibration_constant_manager.get_constant_version_and_call_me_back( + threads = [ + device.calibration_constant_manager.get_constant_version_and_call_me_back( constant, backcall ) - threads.append(thread) + for constant in AgipdCorrection.AgipdConstants + ] for thread in threads: thread.join() diff --git a/src/tests/test_dssc_kernels.py b/src/tests/test_dssc_kernels.py index 95c3ec55c580aa216eef871006955109c0a31ee4..8277ae25e3a62eefe889f365aadb83ed4303a256 100644 --- a/src/tests/test_dssc_kernels.py +++ b/src/tests/test_dssc_kernels.py @@ -18,6 +18,7 @@ raw_data = np.random.randint( low=0, high=2000, size=(memory_cells, pixels_y, pixels_x), dtype=input_dtype ) + # TODO: gather CPU implementations elsewhere def correct_cpu(data, cell_table, offset_map): corr = np.squeeze(data).astype(corr_dtype, copy=True) diff --git a/src/tests/test_utils.py b/src/tests/test_utils.py index 91b1f280f63bb61f54e0325d94216ecfe5d90a44..ebe7d64061f47baf1f6f04b4db425e3d96962a49 100644 --- a/src/tests/test_utils.py +++ b/src/tests/test_utils.py @@ -48,7 +48,7 @@ class TestThreadsafeCache: assert len(calls) == 1, "omitting default args doesn't matter" def test_threadsafeness(self): - # wow, synchronization (presumably) makes this take forever *without* the decorator... + # wow, synchronization (presumably) makes this take forever *without* decorator from_was_called = [] base_sleep = 1 @@ -64,8 +64,8 @@ class TestThreadsafeCache: letters = "abcd" start_ts = timeit.default_timer() for i in range(num_threads): - for l in letters: - thread = threading.Thread(target=was_called, args=(l,)) + for letter in letters: + thread = threading.Thread(target=was_called, args=(letter,)) thread.start() threads.append(thread) submitted_ts = timeit.default_timer() @@ -85,7 +85,8 @@ class TestThreadsafeCache: letters ), "Caching prevents recomputation due to threading" - # check that the function was not locked too broadly (should run faster than sequential lower bound) + # check that the function was not locked too broadly + # (should run faster than sequential lower bound) reasonable_time_to_spawn_thread = 0.45 / 1000 cutoff = ( len(letters) * base_sleep + reasonable_time_to_spawn_thread * num_threads