Skip to content

Commit 4b6a2e4

Browse files
committed
switched to np.greater_equal, np.less_equal, and np.is_real
1 parent 938bfeb commit 4b6a2e4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/qinfer/domains.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,12 @@ def in_domain(self, points):
257257
258258
:rtype: `bool`
259259
"""
260-
return np.all(points >= self._min) and np.all(points <= self._max) and np.all(np.real(points) == points)
260+
if np.all(np.isreal(points)):
261+
are_greater = np.all(np.greater_equal(points, self._min))
262+
are_smaller = np.all(np.less_equal(points, self._max))
263+
return are_greater and are_smaller
264+
else:
265+
return False
261266

262267
class IntegerDomain(Domain):
263268
"""
@@ -382,13 +387,13 @@ def in_domain(self, points):
382387
383388
:rtype: `bool`
384389
"""
385-
if np.all(np.real(points) == points):
390+
if np.all(np.isreal(points)):
386391
try:
387392
are_integer = np.all(np.mod(points, 1) == 0)
388393
except TypeError:
389394
are_integer = False
390-
are_greater = np.all(points >= self._min)
391-
are_smaller = np.all(points <= self._max)
395+
are_greater = np.all(np.greater_equal(points, self._min))
396+
are_smaller = np.all(np.less_equal(points, self._max))
392397
return are_integer and are_greater and are_smaller
393398
else:
394399
return False
@@ -533,4 +538,6 @@ def in_domain(self, points):
533538
:rtype: `bool`
534539
"""
535540
array_view = self.to_regular_array(points)
536-
return np.all(array_view >= 0) and np.all(np.sum(array_view, axis=-1) == self.n_meas)
541+
non_negative = np.all(np.greater_equal(array_view, 0))
542+
correct_sum = np.all(np.sum(array_view, axis=-1) == self.n_meas)
543+
return non_negative and correct_sum

0 commit comments

Comments
 (0)