Skip to content

Commit 588a53a

Browse files
committed
don't compute extrema when we provide override_bins
1 parent c0b8969 commit 588a53a

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

yt/data_objects/profiles.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,9 @@ def create_profile(
14301430
logs_list.append(data_source.ds.field_info[bin_field].take_log)
14311431
logs = logs_list
14321432

1433-
if override_bins is not None:
1433+
if override_bins is None:
1434+
o_bins = [None for _ in bin_fields]
1435+
else:
14341436
o_bins = []
14351437
for bin_field in bin_fields:
14361438
bf_units = data_source.ds.field_info[bin_field].output_units
@@ -1455,15 +1457,21 @@ def create_profile(
14551457
o_bins.append(field_obin)
14561458

14571459
if extrema is None:
1458-
ex = [
1459-
data_source.quantities["Extrema"](f, non_zero=l)
1460-
for f, l in zip(bin_fields, logs, strict=True)
1461-
]
1462-
# pad extrema by epsilon so cells at bin edges are not excluded
1463-
for i, (mi, ma) in enumerate(ex):
1464-
mi = mi - np.spacing(mi)
1465-
ma = ma + np.spacing(ma)
1466-
ex[i][0], ex[i][1] = mi, ma
1460+
ex = []
1461+
for field, log, field_obin in zip(bin_fields, logs, o_bins, strict=True):
1462+
if field_obin is None:
1463+
ex.append(data_source.quantities["Extrema"](field, non_zero=log))
1464+
# pad extrema by epsilon so cells at bin edges are not excluded
1465+
mi, ma = ex[-1]
1466+
mi = mi - np.spacing(mi)
1467+
ma = ma + np.spacing(ma)
1468+
ex[-1][0], ex[-1][1] = mi, ma
1469+
else:
1470+
if field_obin[-1] > field_obin[0]:
1471+
mi, ma = field_obin[0], field_obin[-1]
1472+
else:
1473+
ma, mi = field_obin[0], field_obin[-1]
1474+
ex.append([mi, ma])
14671475
else:
14681476
ex = []
14691477
for bin_field in bin_fields:

0 commit comments

Comments
 (0)