From 0ab1f27deec920e3b7cd4eb0d8f05fe623d142d0 Mon Sep 17 00:00:00 2001 From: hcwinsemius Date: Tue, 10 Dec 2024 16:28:19 +0100 Subject: [PATCH] fix #22 version bump to 0.1.2 --- CHANGELOG.md | 11 +++++++++++ ffpiv/__init__.py | 2 +- ffpiv/api.py | 23 +++++++++++++---------- ffpiv/window.py | 2 +- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ea3f12..504f8a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [0.1.2] - 2024-12-10 +### Added +### Changed +* `api.cross_corr` now only reports possible memory issues when `verbose=True` + +### Deprecated +### Removed +### Fixed +### Security + + ## [0.1.1] - 2024-12-01 ### Added * Additional documentation for FF-PIV API diff --git a/ffpiv/__init__.py b/ffpiv/__init__.py index bf540d9..a84fdad 100644 --- a/ffpiv/__init__.py +++ b/ffpiv/__init__.py @@ -1,6 +1,6 @@ """FF-PIV: Fast and Flexible Particle Image Velocimetry analysis powered by numba.""" -__version__ = "0.1.1" +__version__ = "0.1.2" from . import pnb, pnp, sample_data, window from .api import * diff --git a/ffpiv/api.py b/ffpiv/api.py index 9c36142..74dcdac 100644 --- a/ffpiv/api.py +++ b/ffpiv/api.py @@ -157,6 +157,7 @@ def cross_corr( search_area_size: Optional[Tuple[int, int]] = None, engine: Literal["numba", "numpy"] = "numba", normalize: bool = False, + verbose: bool = True, ): """Compute correlations over a stack of images using interrogation windows. @@ -175,6 +176,8 @@ def cross_corr( The engine to use for calculation, by default "numba". normalize : bool, optional if set, each window will be normalized with spatial mean and standard deviation, and numbers capped to 0. + verbose : bool, optional + if set (default), warnings will be displayed if the amount of available memory is low. Returns ------- @@ -210,16 +213,16 @@ def cross_corr( len(imgs), dim_size=dim_size, window_size=window_size, overlap=overlap, search_area_size=search_area_size ) avail_mem = window.available_memory() - if avail_mem - req_mem < 0: - warnings.warn( - f"You have too little physical memory ({avail_mem / 1e9} GB) available for this problem. " - f"You may need {req_mem / 1e9} GB. ffpiv may slow down or crash! Reduce the amount of frames interpreted " - f"in one go.", - stacklevel=2, - ) - # wait for a while so that user can read the message - time.sleep(1) - time.sleep(1) + if verbose: + if avail_mem - req_mem < 0: + warnings.warn( + f"You may have too little physical memory ({avail_mem / 1e9} GB) available for this problem. " + f"You may need {req_mem / 1e9} GB. ffpiv may slow down or crash! Reduce the amount of frames " + f" interpreted in one go.", + stacklevel=2, + ) + # wait for a while so that user can read the message + time.sleep(1) x, y, window_stack = subwindows( imgs, window_size=window_size, diff --git a/ffpiv/window.py b/ffpiv/window.py index 6281eff..eabb570 100644 --- a/ffpiv/window.py +++ b/ffpiv/window.py @@ -11,7 +11,7 @@ def round_to_even(input_tuple: Tuple[int]): return tuple((x + 1) if x % 2 != 0 else x for x in input_tuple) -def available_memory(safety=1e9): +def available_memory(safety=0.0): """Get available memory in bytes.""" return psutil.virtual_memory().free - safety # + psutil.swap_memory().free