Python bottleneck.nanmin() Examples
The following are 6
code examples of bottleneck.nanmin().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bottleneck
, or try the search function
.
Example #1
Source File: ImageView.py From tf-pose with Apache License 2.0 | 6 votes |
def quickMinMax(self, data): """ Estimate the min/max values of *data* by subsampling. Returns [(min, max), ...] with one item per channel """ while data.size > 1e6: ax = np.argmax(data.shape) sl = [slice(None)] * data.ndim sl[ax] = slice(None, None, 2) data = data[sl] cax = self.axes['c'] if cax is None: return [(float(nanmin(data)), float(nanmax(data)))] else: return [(float(nanmin(data.take(i, axis=cax))), float(nanmax(data.take(i, axis=cax)))) for i in range(data.shape[-1])]
Example #2
Source File: accessors.py From vectorbt with GNU General Public License v3.0 | 6 votes |
def reduce_to_array(self, reduce_func_nb, *args, **kwargs): """See `vectorbt.tseries.nb.reduce_to_array_nb`. `**kwargs` will be passed to `vectorbt.tseries.common.TSArrayWrapper.wrap_reduced`. Example: ```python-repl >>> min_max_nb = njit(lambda col, a: np.array([np.nanmin(a), np.nanmax(a)])) >>> print(df.vbt.tseries.reduce_to_array(min_max_nb, index=['min', 'max'])) a b c min 1.0 1.0 1.0 max 5.0 5.0 3.0 ```""" checks.assert_numba_func(reduce_func_nb) result = nb.reduce_to_array_nb(self.to_2d_array(), reduce_func_nb, *args) return self.wrap_reduced(result, **kwargs)
Example #3
Source File: accessors.py From vectorbt with GNU General Public License v3.0 | 5 votes |
def min(self, **kwargs): """Return min of non-NaN elements.""" return self.wrap_reduced(nanmin(self.to_2d_array(), axis=0), **kwargs)
Example #4
Source File: ImageView.py From soapy with GNU General Public License v3.0 | 5 votes |
def quickMinMax(self, data): """ Estimate the min/max values of *data* by subsampling. """ while data.size > 1e6: ax = np.argmax(data.shape) sl = [slice(None)] * data.ndim sl[ax] = slice(None, None, 2) data = data[sl] return nanmin(data), nanmax(data)
Example #5
Source File: ImageView.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def quickMinMax(self, data): """ Estimate the min/max values of *data* by subsampling. """ while data.size > 1e6: ax = np.argmax(data.shape) sl = [slice(None)] * data.ndim sl[ax] = slice(None, None, 2) data = data[sl] return nanmin(data), nanmax(data)
Example #6
Source File: region.py From mHTM with MIT License | 4 votes |
def _phase2(self): """ Execute phase 2 of the SP region. This phase is used to compute the active columns. Note - This should only be called after phase 1 has been called and after the inhibition radius and neighborhood have been updated. """ # Shift the outputs self.y[:, 1:] = self.y[:, :-1] self.y[:, 0] = 0 # Calculate k # - For a column to be active its overlap must be at least as large # as the overlap of the k-th largest column in its neighborhood. k = self._get_num_cols() if self.global_inhibition: # The neighborhood is all columns, thus the set of active columns # is simply columns that have an overlap >= the k-th largest in the # entire region # Compute the winning column indexes ix = np.argpartition(-self.overlap[:, 0], k - 1)[:k] # Set the active columns self.y[ix, 0] = self.overlap[ix, 0] > 0 else: # The neighborhood is bounded by the inhibition radius, therefore # each column's neighborhood must be considered for i in xrange(self.ncolumns): # Get the neighbors ix = np.where(self.neighbors[i])[0] # Compute the minimum top overlap if ix.shape[0] <= k: # Desired number of candidates is at or below the desired # activity level, so find the overall min m = max(bn.nanmin(self.overlap[ix, 0]), 1) else: # Desired number of candidates is above the desired # activity level, so find the k-th largest m = max(-np.partition(-self.overlap[ix, 0], k - 1)[k - 1], 1) # Set the column activity if self.overlap[i, 0] >= m: self.y[i, 0] = True