Skip to content

Commit

Permalink
fix GB
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjinliu committed Oct 3, 2023
1 parent e7b713c commit 0ba0953
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions impy/arrays/imgarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ def rescale(
# Check if output is too large.
gb = -1
if not scale_is_seq and scale > 1:
gb = np.prod(self.shape) * (scale ** len(dims)) / 1e9
gb = np.prod(self.shape) * (scale ** len(dims)) / 2**30
elif scale_is_seq and np.prod(list(scale)) > 1:
gb = np.prod(self.shape) * np.prod(list(scale)) / 1e9
gb = np.prod(self.shape) * np.prod(list(scale)) / 2**30
if gb > Const["MAX_GB"]:
raise MemoryError(f"Output image is too large: {gb} GB")

Expand Down
2 changes: 1 addition & 1 deletion impy/arrays/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def chunksize(self) -> AxesTuple[int]:
@property
def GB(self) -> float:
"""Return the array size in GB."""
return self.value.nbytes / 1e9
return self.value.nbytes / 2**30

gb = GB # alias

Expand Down
2 changes: 1 addition & 1 deletion impy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def imread(

# read tif metadata
if not is_memmap:
size = os.path.getsize(path) / 1e9
size = os.path.getsize(path) / 2**30
if size > Const["MAX_GB"]:
raise MemoryError(f"Too large {size:.2f} GB")

Expand Down
2 changes: 1 addition & 1 deletion impy/viewer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def make_world_scale(obj):
def viewer_imread(viewer: "napari.Viewer", path: str):
"""Read an image into the viewer."""

if "*" in path or os.path.getsize(path)/1e9 < Const["MAX_GB"]:
if "*" in path or os.path.getsize(path)/2**30 < Const["MAX_GB"]:
img = imread(path)
else:
img = lazy_imread(path)
Expand Down

0 comments on commit 0ba0953

Please sign in to comment.