Skip to content

Commit

Permalink
enh: minor optimization of min/max feature algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Nov 15, 2023
1 parent 9368a64 commit 9bdfbe0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2.14.1
- fix: perform sanity check for contour spacing before plotting
- enh: minor optimization of min/max feature algorithm
- setup: bump dclab to 0.55.5 (new scalar features)
2.14.0
- ref: don't set RTDCBase.identifier to slot identifier
Expand Down
20 changes: 16 additions & 4 deletions shapeout2/pipeline/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import dclab
import numpy as np

from ..idiom import SLOPING_FEATURES

from .dataslot import Dataslot
from .filter import Filter
from .filter_ray import FilterRay
Expand Down Expand Up @@ -453,10 +455,20 @@ def get_min_max(self, feat, plot_id=None, margin=0.0):
if np.any(ds.filter.all):
if feat in ds:
fdata = ds[feat][ds.filter.all]
invalid = np.logical_or(np.isnan(fdata), np.isinf(fdata))
vdata = fdata[~invalid]
vmin = np.min(vdata)
vmax = np.max(vdata)
invalid = np.isinf(fdata)
if np.any(invalid):
vdata = fdata[~invalid]
else:
vdata = fdata
if feat in SLOPING_FEATURES:
# We are a little faster here.
vmin = min(np.nanmin(vdata[:1000]),
np.nanmin(vdata[-1000:]))
vmax = max(np.nanmax(vdata[:1000]),
np.nanmax(vdata[-1000:]))
else:
vmin = np.nanmin(vdata)
vmax = np.nanmax(vdata)
fmin = min(fmin, vmin)
fmax = max(fmax, vmax)
else:
Expand Down

0 comments on commit 9bdfbe0

Please sign in to comment.