dcnum 0.25.0__tar.gz → 0.25.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dcnum might be problematic. Click here for more details.

Files changed (125) hide show
  1. {dcnum-0.25.0 → dcnum-0.25.1}/.github/workflows/check.yml +2 -4
  2. {dcnum-0.25.0 → dcnum-0.25.1}/CHANGELOG +5 -0
  3. {dcnum-0.25.0 → dcnum-0.25.1}/PKG-INFO +1 -1
  4. dcnum-0.25.1/benchmark/.gitignore +2 -0
  5. dcnum-0.25.1/benchmark/Readme.md +11 -0
  6. dcnum-0.25.1/benchmark/benchmark.py +54 -0
  7. dcnum-0.25.1/benchmark/bm_write_deque_writer_thread.py +46 -0
  8. dcnum-0.25.1/benchmark/bm_write_queue_collector_thread.py +45 -0
  9. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/_version.py +2 -2
  10. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/logic/ctrl.py +7 -2
  11. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/write/queue_collector_thread.py +7 -14
  12. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/write/writer.py +3 -3
  13. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum.egg-info/PKG-INFO +1 -1
  14. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum.egg-info/SOURCES.txt +5 -0
  15. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_write_queue_collector_thread.py +1 -8
  16. {dcnum-0.25.0 → dcnum-0.25.1}/.github/workflows/deploy_pypi.yml +0 -0
  17. {dcnum-0.25.0 → dcnum-0.25.1}/.gitignore +0 -0
  18. {dcnum-0.25.0 → dcnum-0.25.1}/.readthedocs.yml +0 -0
  19. {dcnum-0.25.0 → dcnum-0.25.1}/LICENSE +0 -0
  20. {dcnum-0.25.0 → dcnum-0.25.1}/README.rst +0 -0
  21. {dcnum-0.25.0 → dcnum-0.25.1}/docs/conf.py +0 -0
  22. {dcnum-0.25.0 → dcnum-0.25.1}/docs/extensions/github_changelog.py +0 -0
  23. {dcnum-0.25.0 → dcnum-0.25.1}/docs/index.rst +0 -0
  24. {dcnum-0.25.0 → dcnum-0.25.1}/docs/requirements.txt +0 -0
  25. {dcnum-0.25.0 → dcnum-0.25.1}/pyproject.toml +0 -0
  26. {dcnum-0.25.0 → dcnum-0.25.1}/setup.cfg +0 -0
  27. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/__init__.py +0 -0
  28. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/__init__.py +0 -0
  29. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/event_extractor_manager_thread.py +0 -0
  30. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_background/__init__.py +0 -0
  31. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_background/base.py +0 -0
  32. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_background/bg_copy.py +0 -0
  33. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_background/bg_roll_median.py +0 -0
  34. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_background/bg_sparse_median.py +0 -0
  35. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_brightness/__init__.py +0 -0
  36. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_brightness/bright_all.py +0 -0
  37. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_brightness/common.py +0 -0
  38. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_contour/__init__.py +0 -0
  39. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_contour/contour.py +0 -0
  40. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_contour/moments.py +0 -0
  41. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_contour/volume.py +0 -0
  42. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_texture/__init__.py +0 -0
  43. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_texture/common.py +0 -0
  44. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/feat_texture/tex_all.py +0 -0
  45. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/gate.py +0 -0
  46. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/feat/queue_event_extractor.py +0 -0
  47. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/logic/__init__.py +0 -0
  48. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/logic/job.py +0 -0
  49. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/logic/json_encoder.py +0 -0
  50. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/meta/__init__.py +0 -0
  51. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/meta/paths.py +0 -0
  52. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/meta/ppid.py +0 -0
  53. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/read/__init__.py +0 -0
  54. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/read/cache.py +0 -0
  55. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/read/const.py +0 -0
  56. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/read/detect_flicker.py +0 -0
  57. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/read/hdf5_data.py +0 -0
  58. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/read/mapped.py +0 -0
  59. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/__init__.py +0 -0
  60. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segm_thresh.py +0 -0
  61. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segm_torch/__init__.py +0 -0
  62. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segm_torch/segm_torch_base.py +0 -0
  63. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segm_torch/segm_torch_mpo.py +0 -0
  64. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segm_torch/segm_torch_sto.py +0 -0
  65. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segm_torch/torch_model.py +0 -0
  66. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segm_torch/torch_postproc.py +0 -0
  67. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segm_torch/torch_preproc.py +0 -0
  68. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segmenter.py +0 -0
  69. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segmenter_manager_thread.py +0 -0
  70. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segmenter_mpo.py +0 -0
  71. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/segm/segmenter_sto.py +0 -0
  72. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/write/__init__.py +0 -0
  73. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum/write/deque_writer_thread.py +0 -0
  74. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum.egg-info/dependency_links.txt +0 -0
  75. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum.egg-info/requires.txt +0 -0
  76. {dcnum-0.25.0 → dcnum-0.25.1}/src/dcnum.egg-info/top_level.txt +0 -0
  77. {dcnum-0.25.0 → dcnum-0.25.1}/tests/conftest.py +0 -0
  78. {dcnum-0.25.0 → dcnum-0.25.1}/tests/data/fmt-hdf5_cytoshot_extended-moments-features.zip +0 -0
  79. {dcnum-0.25.0 → dcnum-0.25.1}/tests/data/fmt-hdf5_cytoshot_full-features_2023.zip +0 -0
  80. {dcnum-0.25.0 → dcnum-0.25.1}/tests/data/fmt-hdf5_cytoshot_full-features_2024.zip +0 -0
  81. {dcnum-0.25.0 → dcnum-0.25.1}/tests/data/fmt-hdf5_cytoshot_full-features_legacy_allev_2023.zip +0 -0
  82. {dcnum-0.25.0 → dcnum-0.25.1}/tests/data/fmt-hdf5_shapein_empty.zip +0 -0
  83. {dcnum-0.25.0 → dcnum-0.25.1}/tests/data/fmt-hdf5_shapein_raw-with-variable-length-logs.zip +0 -0
  84. {dcnum-0.25.0 → dcnum-0.25.1}/tests/data/segm-torch-model_unet-dcnum-test_g1_910c2.zip +0 -0
  85. {dcnum-0.25.0 → dcnum-0.25.1}/tests/data/segm-torch-test-data_unet-dcnum-test_g1_910c2.zip +0 -0
  86. {dcnum-0.25.0 → dcnum-0.25.1}/tests/helper_methods.py +0 -0
  87. {dcnum-0.25.0 → dcnum-0.25.1}/tests/requirements.txt +0 -0
  88. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_background_base.py +0 -0
  89. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_background_bg_copy.py +0 -0
  90. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_background_bg_roll_median.py +0 -0
  91. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_background_bg_sparsemed.py +0 -0
  92. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_brightness.py +0 -0
  93. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_event_extractor_manager.py +0 -0
  94. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_gate.py +0 -0
  95. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_haralick.py +0 -0
  96. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_moments_based.py +0 -0
  97. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_moments_based_extended.py +0 -0
  98. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_feat_volume.py +0 -0
  99. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_init.py +0 -0
  100. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_logic_job.py +0 -0
  101. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_logic_join.py +0 -0
  102. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_logic_json.py +0 -0
  103. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_logic_pipeline.py +0 -0
  104. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_meta_paths.py +0 -0
  105. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_meta_ppid_base.py +0 -0
  106. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_meta_ppid_bg.py +0 -0
  107. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_meta_ppid_data.py +0 -0
  108. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_meta_ppid_feat.py +0 -0
  109. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_meta_ppid_gate.py +0 -0
  110. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_meta_ppid_segm.py +0 -0
  111. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_read_basin.py +0 -0
  112. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_read_concat_hdf5.py +0 -0
  113. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_read_detect_flicker.py +0 -0
  114. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_read_hdf5.py +0 -0
  115. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_read_hdf5_basins.py +0 -0
  116. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_read_hdf5_index_mapping.py +0 -0
  117. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_segm_base.py +0 -0
  118. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_segm_mpo.py +0 -0
  119. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_segm_no_mask_proc.py +0 -0
  120. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_segm_sto.py +0 -0
  121. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_segm_thresh.py +0 -0
  122. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_segm_torch.py +0 -0
  123. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_segm_torch_preproc.py +0 -0
  124. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_write_deque_writer_thread.py +0 -0
  125. {dcnum-0.25.0 → dcnum-0.25.1}/tests/test_write_writer.py +0 -0
@@ -19,7 +19,7 @@ jobs:
19
19
  with:
20
20
  fetch-depth: 0
21
21
  - name: Set up Python ${{ matrix.python-version }}
22
- uses: actions/setup-python@v4
22
+ uses: actions/setup-python@main
23
23
  with:
24
24
  python-version: ${{ matrix.python-version }}
25
25
  - name: Install dependencies
@@ -29,8 +29,6 @@ jobs:
29
29
  python -m pip install coverage flake8 pytest
30
30
  - name: Install dcnum
31
31
  run: |
32
- # mahotas 1.4.15 does not yet support numpy 2.0
33
- pip install "numpy<2"
34
32
  pip install .[torch]
35
33
  - name: List installed packages
36
34
  run: |
@@ -42,4 +40,4 @@ jobs:
42
40
  run: |
43
41
  coverage run --source=dcnum -m pytest tests
44
42
  - name: Upload coverage to Codecov
45
- uses: codecov/codecov-action@v3
43
+ uses: codecov/codecov-action@v4
@@ -1,3 +1,8 @@
1
+ 0.25.1
2
+ - fix: catch ValueError when computing relative path on different anchors
3
+ - ref: replace np.string_ with np.bytes_
4
+ - ref: remove unused `data` argument to QueueCollectorThread
5
+ - ref: minor speed-up for QueueCollectorThread
1
6
  0.25.0
2
7
  - feat: identify flickering in raw data via dcnum.read.detect_flickering
3
8
  - fix: handle out-of-bounds slice indexing for BaseImageChunkCache
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcnum
3
- Version: 0.25.0
3
+ Version: 0.25.1
4
4
  Summary: numerics toolbox for imaging deformability cytometry
5
5
  Author: Maximilian Schlögel, Paul Müller, Raghava Alajangi
6
6
  Maintainer-email: Paul Müller <dev@craban.de>
@@ -0,0 +1,2 @@
1
+ bm_*.txt
2
+ *.lprof
@@ -0,0 +1,11 @@
1
+ This directory contains benchmarking scripts used for optimizing dcnum performance.
2
+ To run all benchmarks, execute `python benchmark.py`. You can also specify
3
+ individual benchmarks or a list of benchmarks (path to `bm_*.py` file)
4
+ as arguments to `benchmark.py`.
5
+
6
+ The benchmarks are also ideal use cases for identifying bottlenecks with
7
+ tools such as [line profiler](https://kernprof.readthedocs.io/en/latest/),
8
+ since benchmarks can be designed to run in single threads.
9
+
10
+ pip install line_profiler
11
+ kernprof -lv benchmark.py
@@ -0,0 +1,54 @@
1
+ import importlib
2
+ import os
3
+ import pathlib
4
+ import sys
5
+ import time
6
+ import timeit
7
+
8
+ import numpy as np
9
+
10
+
11
+ here = pathlib.Path(__file__).parent
12
+
13
+
14
+ def print_underline(msg):
15
+ print(msg)
16
+ print("-" * len(msg))
17
+
18
+
19
+ def run_benchmark(bm_path, repeats=5):
20
+ print_underline(f"Running {bm_path}")
21
+ bm_path = pathlib.Path(bm_path).resolve()
22
+ os.chdir(f"{bm_path.parent}")
23
+ bm_mod = importlib.import_module(f"{bm_path.stem}")
24
+
25
+ reps = []
26
+ print("Running...", end="\r")
27
+ for ii in range(repeats):
28
+ t = timeit.timeit(bm_mod.main, setup=bm_mod.setup, number=1)
29
+ reps.append(t)
30
+ print(f"Running {ii + 1}/{repeats}", end="\r")
31
+ print(reps)
32
+ print(f"best={min(reps):.3g}, mean={np.mean(reps):.3g}")
33
+ return reps
34
+
35
+
36
+ if __name__ == "__main__":
37
+ benchmark_paths = []
38
+ for arg in sys.argv[1:]:
39
+ if arg.startswith("bm_"):
40
+ benchmark_paths.append(arg)
41
+
42
+ if not benchmark_paths:
43
+ print("No benchmarking script specified, running all benchmarks.")
44
+ benchmark_paths = here.glob("bm_*.py")
45
+
46
+ results = {}
47
+
48
+ for bmp in sorted(benchmark_paths):
49
+ bmp = pathlib.Path(bmp)
50
+ print("")
51
+ res = run_benchmark(bmp)
52
+ with bmp.with_suffix(".txt").open("a") as fd:
53
+ fd.write(time.strftime(f"%Y-%m-%d_%H.%M.%S {res}\n"))
54
+ print("")
@@ -0,0 +1,46 @@
1
+ import atexit
2
+ from collections import deque
3
+ import pathlib
4
+ import shutil
5
+ import tempfile
6
+
7
+ import multiprocessing as mp
8
+
9
+ import numpy as np
10
+
11
+ from dcnum import write
12
+
13
+
14
+ mp_spawn = mp.get_context('spawn')
15
+
16
+
17
+ def setup():
18
+ global path_out
19
+ global writer_dq
20
+ total_frames = 3000
21
+ batch_size = 500
22
+ num_batches = 6
23
+ assert batch_size * num_batches == total_frames
24
+
25
+ writer_dq = deque()
26
+ # Create 1000 events with at most two repetitions in a frame
27
+ np.random.seed(42)
28
+ rng = np.random.default_rng()
29
+
30
+ # create a sample event
31
+ for ii in range(num_batches):
32
+ writer_dq.append(("mask", rng.random((batch_size, 80, 320)) > .5))
33
+ writer_dq.append(("temp", rng.normal(23, size=batch_size)))
34
+
35
+ temp_dir = tempfile.mkdtemp(prefix=pathlib.Path(__file__).name)
36
+ atexit.register(shutil.rmtree, temp_dir, ignore_errors=True, onerror=None)
37
+ path_out = pathlib.Path(temp_dir) / "out.rtdc"
38
+
39
+
40
+ def main():
41
+ thr_drw = write.DequeWriterThread(
42
+ path_out=path_out,
43
+ dq=writer_dq,
44
+ )
45
+ thr_drw.may_stop_loop = True
46
+ thr_drw.run()
@@ -0,0 +1,45 @@
1
+ from collections import deque
2
+ import multiprocessing as mp
3
+
4
+ import numpy as np
5
+
6
+ from dcnum import write
7
+
8
+
9
+ mp_spawn = mp.get_context('spawn')
10
+
11
+
12
+ def setup():
13
+ global event_queue
14
+ global writer_dq
15
+ global feat_nevents
16
+ batch_size = 1000
17
+ num_batches = 3
18
+ num_events = batch_size * num_batches
19
+ event_queue = mp.Queue()
20
+ writer_dq = deque()
21
+ feat_nevents = mp_spawn.Array("i", num_events)
22
+
23
+ # Create 1000 events with at most two repetitions in a frame
24
+ np.random.seed(42)
25
+ rng = np.random.default_rng()
26
+ number_order = rng.choice(batch_size, size=batch_size, replace=False)
27
+
28
+ # create a sample event
29
+ event = {
30
+ "temp": np.atleast_1d(rng.normal(23)),
31
+ "mask": rng.random((1, 80, 320)) > .5,
32
+ }
33
+ for ii in range(num_batches):
34
+ for idx in number_order:
35
+ event_queue.put((ii*batch_size + idx, event))
36
+
37
+
38
+ def main():
39
+ thr_coll = write.QueueCollectorThread(
40
+ event_queue=event_queue,
41
+ writer_dq=writer_dq,
42
+ feat_nevents=feat_nevents,
43
+ write_threshold=500,
44
+ )
45
+ thr_coll.run()
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.25.0'
16
- __version_tuple__ = version_tuple = (0, 25, 0)
15
+ __version__ = version = '0.25.1'
16
+ __version_tuple__ = version_tuple = (0, 25, 1)
@@ -679,8 +679,14 @@ class DCNumJobRunner(threading.Thread):
679
679
  self.logger.debug(f"Creating basin for {feats}")
680
680
  # Relative and absolute paths.
681
681
  pin = pathlib.Path(hin.filename).resolve()
682
+ paths = [pin]
682
683
  pout = pathlib.Path(hout.filename).resolve().parent
683
- paths = [pin, os.path.relpath(pin, pout)]
684
+ try:
685
+ paths.append(os.path.relpath(pin, pout))
686
+ except ValueError:
687
+ # This means it is impossible to compute a relative
688
+ # path (e.g. different drive letter on Windows).
689
+ pass
684
690
  hw.store_basin(name="dcnum basin",
685
691
  features=feats,
686
692
  mapping=basinmap0,
@@ -776,7 +782,6 @@ class DCNumJobRunner(threading.Thread):
776
782
 
777
783
  # Start the data collection thread
778
784
  thr_coll = QueueCollectorThread(
779
- data=self.dtin,
780
785
  event_queue=fe_kwargs["event_queue"],
781
786
  writer_dq=writer_dq,
782
787
  feat_nevents=fe_kwargs["feat_nevents"],
@@ -8,8 +8,6 @@ from typing import List
8
8
 
9
9
  import numpy as np
10
10
 
11
- from ..read import HDF5Data
12
-
13
11
 
14
12
  class EventStash:
15
13
  def __init__(self,
@@ -61,11 +59,10 @@ class EventStash:
61
59
  Event dictionary
62
60
  """
63
61
  idx_loc = index - self.index_offset
64
- idx_stop = self.nev_idx[idx_loc]
65
- self._tracker[idx_loc] = True
66
62
 
67
63
  if events:
68
64
  slice_loc = None
65
+ idx_stop = self.nev_idx[idx_loc]
69
66
  for feat in events:
70
67
  dev = events[feat]
71
68
  if dev.size:
@@ -76,6 +73,8 @@ class EventStash:
76
73
  if slice_loc:
77
74
  self.indices_for_data[slice_loc] = index
78
75
 
76
+ self._tracker[idx_loc] = True
77
+
79
78
  def require_feature(self, feat, sample_data):
80
79
  """Create a new empty feature array in `self.events` and return it
81
80
 
@@ -87,10 +86,10 @@ class EventStash:
87
86
  Sample data for one event of the feature (used to determine
88
87
  shape and dtype of the feature array)
89
88
  """
90
- sample_data = np.array(sample_data)
91
- event_shape = sample_data.shape
92
- dtype = sample_data.dtype
93
89
  if feat not in self.events:
90
+ sample_data = np.array(sample_data)
91
+ event_shape = sample_data.shape
92
+ dtype = sample_data.dtype
94
93
  darr = np.zeros((self.size,) + tuple(event_shape),
95
94
  dtype=dtype)
96
95
  self.events[feat] = darr
@@ -99,7 +98,6 @@ class EventStash:
99
98
 
100
99
  class QueueCollectorThread(threading.Thread):
101
100
  def __init__(self,
102
- data: HDF5Data,
103
101
  event_queue: mp.Queue,
104
102
  writer_dq: deque,
105
103
  feat_nevents: mp.Array,
@@ -115,9 +113,6 @@ class QueueCollectorThread(threading.Thread):
115
113
 
116
114
  Parameters
117
115
  ----------
118
- data:
119
- Data source object. This is used for appending additional
120
- information
121
116
  event_queue:
122
117
  A queue object to which other processes or threads write
123
118
  events as tuples `(frame_index, events_dict)`.
@@ -146,8 +141,6 @@ class QueueCollectorThread(threading.Thread):
146
141
  super(QueueCollectorThread, self).__init__(
147
142
  name="QueueCollector", *args, **kwargs)
148
143
  self.logger = logging.getLogger("dcnum.write.QueueCollector")
149
- #: HDF5 data instance
150
- self.data = data
151
144
  #: Event queue from which to collect event data
152
145
  self.event_queue = event_queue
153
146
  #: Writer deque to which event arrays are appended
@@ -169,7 +162,7 @@ class QueueCollectorThread(threading.Thread):
169
162
  # We are not writing to `event_queue` so we can safely cancel
170
163
  # our queue thread if we are told to stop.
171
164
  self.event_queue.cancel_join_thread()
172
- # Indexes the current frame in `self.data`.
165
+ # Indexes the current frame in the input HDF5Data instance.
173
166
  last_idx = 0
174
167
  self.logger.debug("Started collector thread")
175
168
  while True:
@@ -140,10 +140,10 @@ class HDF5Writer:
140
140
  feat_dtype=feat_dtype),
141
141
  **ds_kwds)
142
142
  if len(item_shape) == 2:
143
- dset.attrs.create('CLASS', np.string_('IMAGE'))
144
- dset.attrs.create('IMAGE_VERSION', np.string_('1.2'))
143
+ dset.attrs.create('CLASS', np.bytes_('IMAGE'))
144
+ dset.attrs.create('IMAGE_VERSION', np.bytes_('1.2'))
145
145
  dset.attrs.create('IMAGE_SUBCLASS',
146
- np.string_('IMAGE_GRAYSCALE'))
146
+ np.bytes_('IMAGE_GRAYSCALE'))
147
147
  offset = 0
148
148
  else:
149
149
  dset = egroup[feat]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcnum
3
- Version: 0.25.0
3
+ Version: 0.25.1
4
4
  Summary: numerics toolbox for imaging deformability cytometry
5
5
  Author: Maximilian Schlögel, Paul Müller, Raghava Alajangi
6
6
  Maintainer-email: Paul Müller <dev@craban.de>
@@ -6,6 +6,11 @@ README.rst
6
6
  pyproject.toml
7
7
  .github/workflows/check.yml
8
8
  .github/workflows/deploy_pypi.yml
9
+ benchmark/.gitignore
10
+ benchmark/Readme.md
11
+ benchmark/benchmark.py
12
+ benchmark/bm_write_deque_writer_thread.py
13
+ benchmark/bm_write_queue_collector_thread.py
9
14
  docs/conf.py
10
15
  docs/index.rst
11
16
  docs/requirements.txt
@@ -4,9 +4,8 @@ import pathlib
4
4
 
5
5
  import numpy as np
6
6
 
7
- from dcnum import read, write
7
+ from dcnum import write
8
8
 
9
- from helper_methods import retrieve_data
10
9
 
11
10
  data_path = pathlib.Path(__file__).parent / "data"
12
11
 
@@ -44,15 +43,12 @@ def test_event_stash():
44
43
 
45
44
  def test_queue_collector_thread():
46
45
  # keyword arguments
47
- data = read.HDF5Data(
48
- retrieve_data("fmt-hdf5_cytoshot_full-features_2023.zip"))
49
46
  event_queue = mp.Queue()
50
47
  writer_dq = collections.deque()
51
48
  feat_nevents = np.array([1, 3, 1, 5])
52
49
  write_threshold = 2
53
50
  # queue collector thread
54
51
  qct = write.QueueCollectorThread(
55
- data=data,
56
52
  event_queue=event_queue,
57
53
  writer_dq=writer_dq,
58
54
  feat_nevents=feat_nevents,
@@ -99,15 +95,12 @@ def test_queue_collector_thread():
99
95
 
100
96
  def test_queue_collector_thread_with_full_stash():
101
97
  # keyword arguments
102
- data = read.HDF5Data(
103
- retrieve_data("fmt-hdf5_cytoshot_full-features_2023.zip"))
104
98
  event_queue = mp.Queue()
105
99
  writer_dq = collections.deque()
106
100
  feat_nevents = np.array([1, 3, 1, 5])
107
101
  write_threshold = 2
108
102
  # queue collector thread
109
103
  qct = write.QueueCollectorThread(
110
- data=data,
111
104
  event_queue=event_queue,
112
105
  writer_dq=writer_dq,
113
106
  feat_nevents=feat_nevents,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes