Skip to content

Commit 6975d06

Browse files
Merge pull request #706 from analysiscenter/normalizer_update
Move inplace parameter
2 parents 8740032 + 2629771 commit 6975d06

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

batchflow/plotter/plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def update(self, data):
195195
data = self.preprocess(data)
196196
self.main_object.set_data(data)
197197

198-
vmin, vmax = self._parse_v_ranges(data)
198+
vmin, vmax = self._parse_vrange(data)
199199
self.main_object.set_clim([vmin, vmax])
200200

201201
if self.mode == 'histogram':
@@ -255,7 +255,7 @@ def image(self, data):
255255
image_keys = ['alpha', 'vmin', 'vmax', 'extent']
256256
image_config = self.config.filter(keys=image_keys, prefix='image_')
257257

258-
vmin, vmax = self._parse_v_ranges(data)
258+
vmin, vmax = self._parse_vrange(data)
259259
image_config['vmin'] = vmin
260260
image_config['vmax'] = vmax
261261

@@ -268,7 +268,7 @@ def matrix(self, data):
268268
matrix_keys = ['cmap', 'vmin', 'vmax']
269269
matrix_config = self.config.filter(keys=matrix_keys, prefix='matrix_')
270270

271-
vmin, vmax = self._parse_v_ranges(data)
271+
vmin, vmax = self._parse_vrange(data)
272272
matrix_config['vmin'] = vmin
273273
matrix_config['vmax'] = vmax
274274

batchflow/utils_transforms.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@ class Normalizer:
2020
normalization_stats : dict, optional
2121
If provided, then used to get statistics for normalization.
2222
Otherwise, compute them from a given array.
23-
inplace : bool
24-
Whether to apply operation inplace or return a new array.
2523
"""
2624

2725
def __init__(self, mode='meanstd', clip_to_quantiles=False, q=(0.01, 0.99),
28-
normalization_stats=None, inplace=False):
26+
normalization_stats=None):
2927
self.mode = mode
3028
self.clip_to_quantiles = clip_to_quantiles
3129
self.q = q
3230
self.normalization_stats = normalization_stats
33-
self.inplace = inplace
3431

35-
def normalize(self, array, normalization_stats=None, mode=None, return_stats=False):
32+
def normalize(self, array, normalization_stats=None, mode=None, return_stats=False, inplace=False,
33+
clip_to_quantiles=None):
3634
""" Normalize image with provided stats.
3735
3836
Parameters
@@ -45,14 +43,16 @@ def normalize(self, array, normalization_stats=None, mode=None, return_stats=Fal
4543
If self.normalization_stats is also None, then statistics will by computed by array.
4644
return_stats : bool, optional
4745
Whether to return stats used for normalization, by default False
46+
inplace : bool
47+
Whether to apply operation inplace or return a new array.
4848
4949
Returns
5050
-------
5151
numpy.ndarray or (numpy.ndarray, dict)
5252
"""
53-
clip_to_quantiles = self.clip_to_quantiles
53+
clip_to_quantiles = self.clip_to_quantiles if clip_to_quantiles is None else clip_to_quantiles
5454
mode = self.mode if mode is None else mode
55-
array = array if self.inplace else array.copy()
55+
array = array if inplace else array.copy()
5656

5757
normalization_stats = normalization_stats if normalization_stats is not None else self.normalization_stats
5858

@@ -101,7 +101,7 @@ def normalize(self, array, normalization_stats=None, mode=None, return_stats=Fal
101101

102102
__call__ = normalize
103103

104-
def denormalize(self, array, normalization_stats=None, mode=None):
104+
def denormalize(self, array, normalization_stats=None, mode=None, inplace=False):
105105
""" Denormalize image with provided stats.
106106
107107
Parameters
@@ -118,7 +118,7 @@ def denormalize(self, array, normalization_stats=None, mode=None):
118118
-------
119119
numpy.ndarray or (numpy.ndarray, dict)
120120
"""
121-
array = array if self.inplace else array.copy()
121+
array = array if inplace else array.copy()
122122
mode = self.mode if mode is None else mode
123123

124124
if self.normalization_stats is not None:

0 commit comments

Comments
 (0)