Skip to content

Commit

Permalink
Bug fixes in Snapshot node:
Browse files Browse the repository at this point in the history
Docstring update: add documentation for supported zarr format.
Bugfix: remove depricated `np.asscalar` function

Squashed commit of the following:

commit a5e9870
Author: Larissa Heinrich <heinrichl@janelia.hhmi.org>
Date:   Tue Apr 30 16:02:56 2024 -0400

    Format with black

commit d97e1a9
Author: Larissa Heinrich <heinrichl@janelia.hhmi.org>
Date:   Tue Apr 30 15:12:43 2024 -0400

    clarify snapshot docstring to include zarr file option

    Current docstring only talks about HDF files but node supports
    and defaults to zarr files.

commit 8242a80
Author: Larissa Heinrich <heinrichl@janelia.hhmi.org>
Date:   Tue Apr 30 15:11:46 2024 -0400

    Replace removed numpy function asscalar

    `numpy.asscalar` was deprecated in numpy 1.16.0 and removed in 1.23.0.
    As recommended replaced with `numpy.ndarray.item()`.
    Bug only occured for `store_value_range=True`.
  • Loading branch information
pattonw committed May 2, 2024
1 parent 213725d commit 84dd00b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gunpowder/nodes/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class Snapshot(BatchFilter):
"""Save a passing batch in an HDF file.
"""Save a passing batch in an HDF or Zarr file.
The default behaviour is to periodically save a snapshot after
``every`` iterations.
Expand All @@ -37,7 +37,9 @@ class Snapshot(BatchFilter):
Template for output filenames. ``{id}`` in the string will be
replaced with the ID of the batch. ``{iteration}`` with the training
iteration (if training was performed on this batch).
iteration (if training was performed on this batch). Snapshot will
be saved as zarr file if output_filename ends in ``.zarr`` and as
HDF otherwise.
every (``int``):
Expand Down Expand Up @@ -207,8 +209,8 @@ def process(self, batch, request):

if self.store_value_range:
dataset.attrs["value_range"] = (
np.asscalar(array.data.min()),
np.asscalar(array.data.max()),
array.data.min().item(),
array.data.max().item(),
)

# if array has attributes, add them to the dataset
Expand Down

0 comments on commit 84dd00b

Please sign in to comment.