From dbe5bd9e60e6ea1505f215d58103f9a4c2bf8952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Mon, 23 Nov 2026 16:00:55 +0100 Subject: [PATCH 1/2] docs: fix typos and broken markup in docstrings and comments - typos in docstrings, comments, and two error messages ("provice", "`image_cor`") - the package docstring ran into the license text (missing blank line) - lists without a preceding blank line rendered inline (LazyLoader, HDF5Data index_mapping, get_mapping_indices); the LazyLoader example used `sibling==__name__` instead of `sibling=__name__` - the texture feature list rendered as a nested list - "Usage:" in reserve_slot_for_task rendered as a block quote - single backticks (italics) where code was meant, :func: for a method, malformed Raises/Returns entries in DCNumPipelineJob.validate Co-Authored-By: Claude Opus 5.5 --- CHANGELOG | 1 + dcnum/__init__.py | 1 + dcnum/common.py | 3 ++- dcnum/feat/feat_background/base.py | 2 +- dcnum/feat/feat_background/bg_roll_median.py | 10 ++++---- .../feat/feat_background/bg_sparse_median.py | 8 +++---- dcnum/feat/feat_contour/contour.py | 2 +- dcnum/feat/feat_contour/volume.py | 2 +- dcnum/feat/feat_texture/tex_all.py | 24 +++++++++---------- dcnum/feat/gate.py | 2 +- dcnum/feat/queue_event_extractor.py | 2 +- dcnum/logic/chunk_slot_data.py | 12 +++++----- dcnum/logic/ctrl.py | 12 +++++----- dcnum/logic/job.py | 10 ++++---- dcnum/logic/slot_register.py | 12 +++++----- dcnum/logic/universal_worker.py | 2 +- dcnum/meta/paths.py | 2 +- dcnum/read/detect_flicker.py | 2 +- dcnum/read/hdf5_concat.py | 2 +- dcnum/read/hdf5_data.py | 15 +++++++----- dcnum/read/mapped.py | 13 ++++++---- dcnum/segm/segm_torch/torch_model.py | 6 ++--- dcnum/segm/segm_torch/torch_postproc.py | 5 ++-- dcnum/segm/segmenter.py | 2 +- dcnum/segm/segmenter_manager_thread.py | 2 +- dcnum/write/chunk_writer.py | 3 ++- dcnum/write/event_stash.py | 2 +- dcnum/write/queue_writer_base.py | 6 ++--- dcnum/write/writer.py | 4 ++-- 29 files changed, 90 insertions(+), 79 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index deb548b..e503aff 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -74,6 +74,7 @@ - docs: fix broken logo in README, inconsistent background note and incomplete gating description, building the docs from the repository root, and typos in the changelog + - docs: fix typos and broken markup in docstrings and comments 0.31.2 - fix: online gates for `size_x` and `size_y` were ignored (regression in 0.16.6) - fix: "pipeline:dcnum yield" and "experiment:event count" were set to diff --git a/dcnum/__init__.py b/dcnum/__init__.py index 9e69fd1..a69f853 100644 --- a/dcnum/__init__.py +++ b/dcnum/__init__.py @@ -1,4 +1,5 @@ """Base library for deformability cytometry postprocessing + MIT License Copyright (c) 2023 Paul Müller diff --git a/dcnum/common.py b/dcnum/common.py index e2b3700..971bd76 100644 --- a/dcnum/common.py +++ b/dcnum/common.py @@ -33,12 +33,13 @@ def __init__(self, structure: - ``module`` + - ``submod_1`` - ``submod_2`` If ``submod_1`` would like to lazily import ``submod_2``:: - submod_2 = LazyLoader("submod_2", sibling==__name__) + submod_2 = LazyLoader("submod_2", sibling=__name__) action_before_import: Callable Called before the import. action_after_import: Callable diff --git a/dcnum/feat/feat_background/base.py b/dcnum/feat/feat_background/base.py index 436099a..6987da0 100644 --- a/dcnum/feat/feat_background/base.py +++ b/dcnum/feat/feat_background/base.py @@ -27,7 +27,7 @@ def __init__(self, input_data, output_path, compress=True, num_cpus=None, ---------- input_data: array-like or pathlib.Path The input data can be either a path to an HDF5 file with - the "evtens/image" dataset or an array-like object that + the "events/image" dataset or an array-like object that behaves like an image stack (first axis enumerates events) output_path: pathlib.Path Path to the output file. If ``input_data`` is a path, you can diff --git a/dcnum/feat/feat_background/bg_roll_median.py b/dcnum/feat/feat_background/bg_roll_median.py index a1d00db..1a06592 100644 --- a/dcnum/feat/feat_background/bg_roll_median.py +++ b/dcnum/feat/feat_background/bg_roll_median.py @@ -20,20 +20,20 @@ def __init__(self, input_data, output_path, kernel_size=100, 1. There is one big shared array ``shared_input`` that contains the image data for each batch. - 2. User specifies batch size (10000) and kernel size (default - is 100) + 2. User specifies batch size (default is 10000) and kernel size + (default is 100) 3. There is a second shared array ``shared_output`` that contains the median values corresponding to the data in ``shared_input``. 4. Background computation is done by copying the input images from a file into the shared array. - 5. The input array is split into and workers compute the + 5. The input array is split into pixel slices and workers compute the rolling median for each point in ``shared_input``. Parameters ---------- input_data: array-like or pathlib.Path The input data can be either a path to an HDF5 file with - the "evtens/image" dataset or an array-like object that + the "events/image" dataset or an array-like object that behaves like an image stack (first axis enumerates events) output_path: pathlib.Path Path to the output file. If ``input_data`` is a path, you can @@ -332,7 +332,7 @@ def compute_median_for_slice(shared_input, shared_output, kernel_size, """ input_size = output_size + kernel_size # perform median filter on input data - # write median data into output array. Nnote that the values at + # write median data into output array. Note that the values at # filtered[-kernel_size:] are just junk data, but we keep it to # make the code simpler. shared_output[:output_size, job_slice] = ndi.median_filter( diff --git a/dcnum/feat/feat_background/bg_sparse_median.py b/dcnum/feat/feat_background/bg_sparse_median.py index 8fe02ae..e5b829f 100644 --- a/dcnum/feat/feat_background/bg_sparse_median.py +++ b/dcnum/feat/feat_background/bg_sparse_median.py @@ -39,7 +39,7 @@ def __init__(self, input_data, output_path, kernel_size=200, ---------- input_data: array-like or pathlib.Path The input data can be either a path to an HDF5 file with - the "evtens/image" dataset or an array-like object that + the "events/image" dataset or an array-like object that behaves like an image stack (first axis enumerates events). output_path: pathlib.Path Path to the output file. If ``input_data`` is a path, you can @@ -180,13 +180,13 @@ def __init__(self, input_data, output_path, kernel_size=200, self.shared_input = np.ctypeslib.as_array( self.shared_input_raw).reshape(kernel_size, -1) """numpy array reshaped view on ``self.shared_input_raw``. - The First axis enumerating the events + The first axis enumerating the events """ self.shared_output = np.ctypeslib.as_array( self.shared_output_raw).reshape(self.image_shape) """numpy array reshaped view on ``self.shared_output_raw``. - The First axis enumerating the events + The first axis enumerating the events """ self.worker_counter = mp_spawn.Value("q", 0) @@ -351,7 +351,7 @@ def process_approach(self): # assigned the background image closest in time (they may be # assigned an image up to a few seconds away). This is intended # and should not be changed: The background is generally - # consiered stable. Minimal changes in focus don't affect the + # considered stable. Minimal changes in focus don't affect the # center of the ROI significantly. bg_idx = np.zeros(self.image_count, dtype=int) idx0 = 0 diff --git a/dcnum/feat/feat_contour/contour.py b/dcnum/feat/feat_contour/contour.py index 3e1e982..e69a486 100644 --- a/dcnum/feat/feat_contour/contour.py +++ b/dcnum/feat/feat_contour/contour.py @@ -8,7 +8,7 @@ def contour_single_opencv(mask): - """Return the contour for a boolean mask image containg *one* blob""" + """Return the contour for a boolean mask image containing *one* blob""" cv_im = np.asarray(mask * 255, dtype=np.uint8) # determine the contour information using opencv diff --git a/dcnum/feat/feat_contour/volume.py b/dcnum/feat/feat_contour/volume.py index 926accc..88c10eb 100644 --- a/dcnum/feat/feat_contour/volume.py +++ b/dcnum/feat/feat_contour/volume.py @@ -116,7 +116,7 @@ def vol_revolve(r, z, point_scale=1.): V = \frac{h \cdot \pi}{3} \cdot (R^2 + R \cdot r + r^2) Where :math:`h` is the height of the cone and :math:`r` and - ``R`` are the smaller and larger radii of the truncated cone. + :math:`R` are the smaller and larger radii of the truncated cone. Each line segment of the contour resembles one truncated cone. If the z-step is positive (counter-clockwise contour), then the diff --git a/dcnum/feat/feat_texture/tex_all.py b/dcnum/feat/feat_texture/tex_all.py index 43de3ea..2fbd99a 100644 --- a/dcnum/feat/feat_texture/tex_all.py +++ b/dcnum/feat/feat_texture/tex_all.py @@ -23,17 +23,17 @@ def haralick_texture_features( avg and ptp): https://earlglynn.github.io/RNotes/package/EBImage/Haralick-Textural-Features.html - - 1. ``tex_asm``: (1) Angular Second Moment - - 2. ``tex_con``: (2) Contrast - - 3. ``tex_cor``: (3) Correlation - - 4. ``tex_var``: (4) Variance - - 5. ``tex_idm``: (5) Inverse Difference Moment - - 6. ``tex_sva``: (7) Sum Variance - - 7. ``tex_sen``: (8) Sum Entropy - - 8. ``tex_ent``: (9) Entropy - - 9. ``tex_den``: (11) Difference Entropy - - 10. ``tex_f12``: (12) Information Measure of Correlation 1 - - 11. ``tex_f13``: (13) Information Measure of Correlation 2 + 1. ``tex_asm``: (1) Angular Second Moment + 2. ``tex_con``: (2) Contrast + 3. ``tex_cor``: (3) Correlation + 4. ``tex_var``: (4) Variance + 5. ``tex_idm``: (5) Inverse Difference Moment + 6. ``tex_sva``: (7) Sum Variance + 7. ``tex_sen``: (8) Sum Entropy + 8. ``tex_ent``: (9) Entropy + 9. ``tex_den``: (11) Difference Entropy + 10. ``tex_f12``: (12) Information Measure of Correlation 1 + 11. ``tex_f13``: (13) Information Measure of Correlation 2 """ # make sure we have a boolean array mask = np.asarray(mask, dtype=bool) @@ -45,7 +45,7 @@ def haralick_texture_features( # Background-corrected brightness values image_corr = np.asarray(image, dtype=np.int16) - image_bg else: - raise ValueError("Please specify either `image_cor` or both " + raise ValueError("Please specify either `image_corr` or both " "`image` and `image_bg`") tex_dict = {} diff --git a/dcnum/feat/gate.py b/dcnum/feat/gate.py index b558f6d..4076b25 100644 --- a/dcnum/feat/gate.py +++ b/dcnum/feat/gate.py @@ -180,7 +180,7 @@ def gate_feature(self, ``data`` may be a number or an array. If no box filter is defined for ``feat``, True is always returned. Otherwise, either a boolean or a boolean array is returned, depending on the type of ``data``. - Not that ``np.logical_and`` can deal with mixed argument types + Note that ``np.logical_and`` can deal with mixed argument types (scalar and array). """ bound_lo, bound_up = self.box_gates[feat] diff --git a/dcnum/feat/queue_event_extractor.py b/dcnum/feat/queue_event_extractor.py index f1b309c..914e902 100644 --- a/dcnum/feat/queue_event_extractor.py +++ b/dcnum/feat/queue_event_extractor.py @@ -49,7 +49,7 @@ def __init__(self, extract_kwargs: Keyword arguments for the extraction process. See the keyword-only arguments in - :func:`QueueEventExtractor.get_events_from_masks`. + :meth:`QueueEventExtractor.get_events_from_masks`. logger: Logger to use """ diff --git a/dcnum/logic/chunk_slot_data.py b/dcnum/logic/chunk_slot_data.py index 4956587..299bc5e 100644 --- a/dcnum/logic/chunk_slot_data.py +++ b/dcnum/logic/chunk_slot_data.py @@ -175,7 +175,7 @@ def acquire_task_lock(self, """Acquire the lock for performing a task Return the start and stop indices for which the lock was acquired. - If no lock could be acquired, return `(0, 0)`. The returned + If no lock could be acquired, return ``(0, 0)``. The returned indices might not match the input batch size: Locks for contiguous indices are returned based on availability. """ @@ -184,7 +184,7 @@ def acquire_task_lock(self, # array that monitors the progress of the current state progress_array = np.ctypeslib.as_array(self._task_progress_array) with self._task_reserve_lock: - # combined array with frames are completed or are in use + # combined array with frames that are completed or in use used_array = np.logical_or(reserve_array, progress_array) if self._state.value != req_state: # wrong state @@ -223,7 +223,7 @@ def release_task_lock(self, start, stop, task_done=True): Releasing the task lock is done after completing the task for which a lock was required. This method also updates the - progress (see `get_progress`) for the current task. Only release + progress (see ``get_progress``) for the current task. Only release the task lock if you acquired it before. """ if task_done: @@ -238,9 +238,9 @@ def get_progress(self): """Return the progress of the current task Return a value between 0 and 1. If processing is done in batches - (`batch_size` set in `acquire_task_lock`), this returns the - fraction of frames for which `release_task_lock` was called - with `task_done=True`. + (``batch_size`` set in ``acquire_task_lock``), this returns the + fraction of frames for which ``release_task_lock`` was called + with ``task_done=True``. """ progress_array = np.ctypeslib.as_array(self._task_progress_array) return float(np.sum(progress_array)) / self.length diff --git a/dcnum/logic/ctrl.py b/dcnum/logic/ctrl.py index 55268a8..d8e4d9e 100644 --- a/dcnum/logic/ctrl.py +++ b/dcnum/logic/ctrl.py @@ -591,7 +591,7 @@ def run_pipeline(self): def task_background(self): """Perform background computation task - This populates the file `self.path_temp_in` with the 'image_bg' + This populates the file ``self.path_temp_in`` with the 'image_bg' feature. """ self.logger.info("Starting background computation") @@ -695,7 +695,7 @@ def task_enforce_basin_strategy(self): # We achieve this by keeping a specific order and only copying # those features that we don't already have in the output file. feats_raw = [ - # background data from the temporary input image + # background data from the temporary input file [self.dtin.h5, ["bg_off"], "critical"], [self.draw.h5, self.draw.features_scalar_frame, "optional"], [self.draw.h5, ["image", "bg_off"], "optional"], @@ -919,10 +919,10 @@ def task_segment_extract(self): w_dcs = UniversalWorker.get_worker_dedications(self.job, num_universal) # The number of ChunkSlots defines how well workers can operate in - # parallel. This should be higher than the number states a ChunkSlot - # can have to prevent workers from waiting on each other. Seven slots - # results in a shared memory usage of roughly 1GB for a standard - # blood measurement (image chunks of (1000, 80, 32). + # parallel. This should be higher than the number of states a + # ChunkSlot can have to prevent workers from waiting on each other. + # Seven slots result in a shared memory usage of roughly 1GB for a + # standard blood measurement (image chunks of (1000, 80, 32)). if self.job["debug"]: num_slots = 1 else: diff --git a/dcnum/logic/job.py b/dcnum/logic/job.py index 2a09174..6e64d3e 100644 --- a/dcnum/logic/job.py +++ b/dcnum/logic/job.py @@ -140,7 +140,7 @@ def __setstate__(self, state): self.kwargs.update(copy.deepcopy(state)) def assert_pp_codes(self): - """Sanity check of `self.kwargs`""" + """Sanity check of ``self.kwargs``""" # PPID classes with only one option for cls, key in [ (HDF5Data, "data_code"), @@ -253,15 +253,15 @@ def validate(self): Returns ------- - True: - for testing convenience + bool + Always True (for testing convenience) Raises ------ - dcnum.segm.SegmenterNotApplicableError: + dcnum.segm.SegmenterNotApplicableError the segmenter is incompatible with the input path """ - # Check segmenter applicability applicability + # Check segmenter applicability seg_cls = self.get_segmenter_class() with HDF5Data(self.kwargs["path_in"]) as hd: seg_cls.validate_applicability( diff --git a/dcnum/logic/slot_register.py b/dcnum/logic/slot_register.py index a4082e5..6db457f 100644 --- a/dcnum/logic/slot_register.py +++ b/dcnum/logic/slot_register.py @@ -218,7 +218,7 @@ def write_queue_size(self): A large number indicates a slow writer which can be a result of a slow hard disk or a slow CPU (since - is used compression). Used for preventing + compression is used). Used for preventing OOM events by stalling data processing when the writer is slow. """ return self.get_counter_value("write_queue_size") @@ -306,7 +306,7 @@ def increment_counter_value(self, increment: By how much the counter should be incremented timeout: - Timeout for acquiring a lock (if `lock` is not set) + Timeout for acquiring a lock (if ``lock`` is not set) lock: A locked lock for the given counter. The lock will not be released after incrementing the value. @@ -367,7 +367,7 @@ def reserve_slot_for_task(self, state_warden Context manager that enforces setting the next state or None if no chunk slot could be reserved. - Usage: + Usage:: if state_warden is not None: with state_warden as (chunk_slot, batch_range): @@ -376,7 +376,7 @@ def reserve_slot_for_task(self, stop_index=batch_range[1] ) - The `batch_range` indices are defined by the `batch_size` + The ``batch_range`` indices are defined by the ``batch_size`` parameter. This context manager will automatically set the slot @@ -641,7 +641,7 @@ def task_label_masks(self, Returns ------- did_something : bool - Whether masks where converted to labels + Whether masks were converted to labels """ did_something = False cs = self.find_slot(state="m") @@ -688,7 +688,7 @@ def task_process_labels(self, logger = logger or logging.getLogger(__name__) - # Comput labels from this ChunkSlot + # Process labels from this ChunkSlot batch_size = 100 if cs is not None and cs.state == "l": while True: diff --git a/dcnum/logic/universal_worker.py b/dcnum/logic/universal_worker.py index 4202ddc..0d17410 100644 --- a/dcnum/logic/universal_worker.py +++ b/dcnum/logic/universal_worker.py @@ -291,7 +291,7 @@ def __init__(self, *args, **kwargs): def start(self): """Start the process with single-threaded library settings""" - # Set all relevant os environment variables such libraries in the + # Set all relevant os environment variables such that libraries in the # new process only use single-threaded computation. with RequestSingleThreaded(): mp_spawn.Process.start(self) diff --git a/dcnum/meta/paths.py b/dcnum/meta/paths.py index 351214d..8a3a937 100644 --- a/dcnum/meta/paths.py +++ b/dcnum/meta/paths.py @@ -11,7 +11,7 @@ def register_search_path(topic: str, Search paths are a global solution for organizing the locations of resources that are part of an analysis pipeline. For instance, - if the location of such a file that depends on where your pipeline is + if the location of such a file depends on where your pipeline is running, you can register multiple search paths and the file will be found using :func:`find_file`. """ diff --git a/dcnum/read/detect_flicker.py b/dcnum/read/detect_flicker.py index 0e85b06..c9a61f6 100644 --- a/dcnum/read/detect_flicker.py +++ b/dcnum/read/detect_flicker.py @@ -30,7 +30,7 @@ def detect_flickering(image_data: np.ndarray | HDF5Data, height of the ROI in pixels for which to search for flickering; the entire width of the image is used brightness_threshold: float - brightness difference between individual ROIs median and median + brightness difference between an individual ROI's median and median of all ROI medians leading to a positive flickering event count_threshold: int minimum number of flickering events that would lead to a positive diff --git a/dcnum/read/hdf5_concat.py b/dcnum/read/hdf5_concat.py index a84872f..224dda3 100644 --- a/dcnum/read/hdf5_concat.py +++ b/dcnum/read/hdf5_concat.py @@ -28,7 +28,7 @@ def concatenated_hdf5_data(paths: list[pathlib.Path], If `None`, then the dataset is created in memory. If `True` (default), create a file on disk. If a pathlib.Path is specified, the dataset is written to that file. Note that datasets in memory - are likely not pickable (so don't use them for multiprocessing). + are likely not picklable (so don't use them for multiprocessing). compute_frame: Whether to compute the "events/frame" feature, taking the frame data from the input files and properly incrementing them along diff --git a/dcnum/read/hdf5_data.py b/dcnum/read/hdf5_data.py index db1d860..b553709 100644 --- a/dcnum/read/hdf5_data.py +++ b/dcnum/read/hdf5_data.py @@ -111,13 +111,16 @@ def __init__(self, index_mapping: select only a subset of input events, transparently reducing the size of the dataset, possible data types are - - int `N`: use the first `N` events + + - int ``N``: use the first ``N`` events - slice: use the events defined by a slice - - list: list of integers specifying the event indices to use + - list or np.ndarray: integers specifying the event indices + to use + Numpy indexing rules apply. E.g. to only process the first - 100 events, set this to `100` or `slice(0, 100)`. Negative + 100 events, set this to ``100`` or ``slice(0, 100)``. Negative values are not allowed. Integers and slices are limited to - the size of the dataset (e.g. `slice(30, None)`). + the size of the dataset (e.g. ``slice(30, None)``). """ # Init is in __setstate__ so we can pickle this class # and use it for multiprocessing. @@ -235,7 +238,7 @@ def __getstate__(self): def __setstate__(self, state): # Make sure these properties exist (we rely on __init__, because - # we want this class to be pickable and __init__ is not called by + # we want this class to be picklable and __init__ is not called by # `pickle.load`). # Cached properties self._feats = None @@ -406,7 +409,7 @@ def mask(self): @property def meta_nest(self): - """Return `self.meta` as nested dicitonary + """Return `self.meta` as nested dictionary This gets very close to the dclab `config` property of datasets. """ diff --git a/dcnum/read/mapped.py b/dcnum/read/mapped.py index e487594..18f5b76 100644 --- a/dcnum/read/mapped.py +++ b/dcnum/read/mapped.py @@ -85,17 +85,20 @@ def get_mapping_indices( ---------- index_mapping: numbers.Integral | slice | list | np.ndarray Several options you have here: - - integer: results in np.arange(integer) - - slice: results in np.arange(slice.start, slice.stop, slice.step) + + - integer: results in ``np.arange(integer)`` + - slice: results in + ``np.arange(slice.start, slice.stop, slice.step)`` - list or np.ndarray: returns the input as uint32 array + Negative values are not allowed. size: int Size of the dataset to which the mapping is applied. If given, integers and slices are limited to the dataset size (e.g. - `slice(30, None)` or `slice(30, 1000)` for a dataset of size - 40 results in `np.arange(30, 40)`), and a `ValueError` is + ``slice(30, None)`` or ``slice(30, 1000)`` for a dataset of size + 40 results in ``np.arange(30, 40)``), and a ``ValueError`` is raised if a list or array contains indices beyond the dataset. - Slices without start or stop require `size`. + Slices without start or stop require ``size``. Returns ------- diff --git a/dcnum/segm/segm_torch/torch_model.py b/dcnum/segm/segm_torch/torch_model.py index 453c06e..41675f1 100644 --- a/dcnum/segm/segm_torch/torch_model.py +++ b/dcnum/segm/segm_torch/torch_model.py @@ -126,7 +126,7 @@ def get_model_meta(path_or_name: str | pathlib.Path, assert False # The available backend/device wiring are baked into the model file. - # Each entries consist of a dictionary with keys "device" and + # Each entry consists of a dictionary with keys "device" and # "backend", ordered according to efficiency/suggestion decreasing. wiring_options: list[dict[str, str]] = model_meta["wiring_options"] # Determine the correct wiring based on the input. @@ -147,7 +147,7 @@ def get_model_meta(path_or_name: str | pathlib.Path, if backend is None and device is None: raise ValueError( f"The model {model_path.name} does not have wiring " - f"options specified. Please provice 'device' and " + f"options specified. Please provide 'device' and " f"'backend' manually.") else: raise ValueError( @@ -273,7 +273,7 @@ def load_model_v2_pt2(model_meta: dict[str, Any]): Notes ----- - The `model_meta` dict should contain the "backend" key. If "openvino" + The ``model_meta`` dict should contain the "backend" key. If "openvino" is installed, then the backend "openvino" is available. Torch's eager mode is available via the "torch.eager" backend (strictly speaking, this is not a backend at all, it's just the torch default diff --git a/dcnum/segm/segm_torch/torch_postproc.py b/dcnum/segm/segm_torch/torch_postproc.py index a64170f..bc01569 100644 --- a/dcnum/segm/segm_torch/torch_postproc.py +++ b/dcnum/segm/segm_torch/torch_postproc.py @@ -19,7 +19,8 @@ def postprocess_masks(masks, :func:`.preprocess_images` by padding with zeros and cropping. - If the original image shape is larger than the mask image shape, also clear borders in an intermediate step - (maks postprocessing using :func:`Segmenter.process_labels`). + (mask postprocessing using + :meth:`~dcnum.segm.segmenter.Segmenter.process_labels`). Parameters ---------- @@ -27,7 +28,7 @@ def postprocess_masks(masks, Mask data in shape (batch_size, 1, imagex_size, imagey_size) or (batch_size, imagex_size, imagey_size). original_image_shape: tuple of (int, int) - The required output mask shape for one event. This required for + The required output mask shape for one event. This is required for doing the inverse of what is done in :func:`.preprocess_images`. Returns diff --git a/dcnum/segm/segmenter.py b/dcnum/segm/segmenter.py index da2b053..df1dc40 100644 --- a/dcnum/segm/segmenter.py +++ b/dcnum/segm/segmenter.py @@ -137,7 +137,7 @@ def get_border(shape): @staticmethod @functools.cache def get_disk(radius): - """Cached `skimage.morphology.disk(radius)`""" + """Cached ``skimage.morphology.disk(radius)``""" return skimage_morphology.disk(radius) def get_ppid(self): diff --git a/dcnum/segm/segmenter_manager_thread.py b/dcnum/segm/segmenter_manager_thread.py index 802c9d9..0049de4 100644 --- a/dcnum/segm/segmenter_manager_thread.py +++ b/dcnum/segm/segmenter_manager_thread.py @@ -35,7 +35,7 @@ def __init__(self, ----- The working principle of this ``SegmenterManagerThread`` allows the user to define a fixed number of slots on which the segmenter - can work on. For instance, if the segmenter is a CPU-based segmenter, + can work. For instance, if the segmenter is a CPU-based segmenter, it does not make sense to have more than one slot (because feature extraction should not take place at the same time). But if the segmenter is a GPU-based segmenter, then it makes sense to have diff --git a/dcnum/write/chunk_writer.py b/dcnum/write/chunk_writer.py index d531197..55b2c1f 100644 --- a/dcnum/write/chunk_writer.py +++ b/dcnum/write/chunk_writer.py @@ -25,7 +25,8 @@ def __init__(self, *args, **kwargs): """Convenience class for writing to data outside the main loop - Data are numpy arrays collected from a `dequeue` object + Data are ``(feature, numpy array)`` tuples collected from a + ``collections.deque`` object Parameters ---------- diff --git a/dcnum/write/event_stash.py b/dcnum/write/event_stash.py index b522e25..2ad16a2 100644 --- a/dcnum/write/event_stash.py +++ b/dcnum/write/event_stash.py @@ -11,7 +11,7 @@ def __init__(self, Parameters ---------- index_offset: - This is the index offset at which we are working on. + This is the index offset at which we are working. Normally, `feat_nevents` is just a slice of a larger array and `index_offset` defines at which position it is taken. diff --git a/dcnum/write/queue_writer_base.py b/dcnum/write/queue_writer_base.py index 0472987..ea0d53c 100644 --- a/dcnum/write/queue_writer_base.py +++ b/dcnum/write/queue_writer_base.py @@ -69,7 +69,7 @@ def __init__(self, that do not match are kept in a buffer until the corresponding :class:`~dcnum.write.event_stash.EventStash` is created). Then, for each frame, we may have multiple or - None events, so the + no events, so the output size could be 513 which is computed via `np.sum(feat_nevents[idx:idx+write_threshold])`. """ @@ -138,8 +138,8 @@ def run(self, buffer_dq=None, writer_dq=None, logger=None): thr_write = ChunkWriter( path_out=self.path_out, # We need the daemon mode, because otherwise dcnum hangs - # when sending a KeyboardInterupt. But this is safe, because - # wer are always joining the writer thread. + # when sending a KeyboardInterrupt. But this is safe, because + # we are always joining the writer thread. daemon=True, dq=writer_dq, mode="w", diff --git a/dcnum/write/writer.py b/dcnum/write/writer.py index 10cbc5a..590e786 100644 --- a/dcnum/write/writer.py +++ b/dcnum/write/writer.py @@ -127,7 +127,7 @@ def require_feature(self, group_name: str name of the HDF5 group where the feature should be written to; defaults to the "events" group, but a different group can be - specified for storing e.g. internal basin features. + specified for storing e.g. internal basin features. """ if group_name == "events": egroup = self.events @@ -336,7 +336,7 @@ def create_with_basins( basin_paths: The paths to the basins written to `path_out`. This can be either a list of paths (to different basins) or a list of - lists for paths (for basins containing the same information, + lists of paths (for basins containing the same information, commonly used for relative and absolute paths). """ path_out = pathlib.Path(path_out) From 8dc625ebf22384edeb47d1d0a8437c330b18e7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Mon, 23 Nov 2026 16:09:07 +0100 Subject: [PATCH 2/2] Update hdf5_concat.py --- dcnum/read/hdf5_concat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dcnum/read/hdf5_concat.py b/dcnum/read/hdf5_concat.py index 224dda3..212b2cc 100644 --- a/dcnum/read/hdf5_concat.py +++ b/dcnum/read/hdf5_concat.py @@ -28,7 +28,7 @@ def concatenated_hdf5_data(paths: list[pathlib.Path], If `None`, then the dataset is created in memory. If `True` (default), create a file on disk. If a pathlib.Path is specified, the dataset is written to that file. Note that datasets in memory - are likely not picklable (so don't use them for multiprocessing). + are likely not ``pickle``able (so don't use them for multiprocessing). compute_frame: Whether to compute the "events/frame" feature, taking the frame data from the input files and properly incrementing them along