Skip to content

Commit 0baf046

Browse files
committed
FIX: Profile issues with interpolator #395
1 parent 659a1cc commit 0baf046

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pytim/observables/profile.py

+5
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def _sample_random_distribution(self, group):
187187
rnd *= self.interface.universe.dimensions[:3]
188188
rnd_pos = IntrinsicDistance(
189189
self.interface, symmetry=self.symmetry).compute(rnd)
190+
# the interpolator can return NaNs in some cases
191+
rnd_pos = rnd_pos[np.isfinite(rnd_pos)]
190192
rnd_accum, bins, _ = stats.binned_statistic(
191193
rnd_pos,
192194
np.ones(len(rnd_pos)),
@@ -221,6 +223,9 @@ def sample(self, group, **kargs):
221223
rnd_accum, bins = self._sample_random_distribution(group)
222224

223225
values = self.observable.compute(group, **kargs)
226+
# the interpolator can return NaNs in some cases
227+
cond = np.isfinite(pos)
228+
values, pos = values[cond], pos[cond]
224229
accum, bins, _ = stats.binned_statistic(
225230
pos,
226231
values,

0 commit comments

Comments
 (0)