def testNone(self): a = None self.assertFalse(debug_data.has_inf_or_nan(self._dummy_datum, a))
def testNoNanOrInf(self): a = np.array([0.0, 0.0, 7.0]) self.assertFalse(debug_data.has_inf_or_nan(self._dummy_datum, a))
def testEmpty(self): a = np.array([]) self.assertFalse(debug_data.has_inf_or_nan(self._dummy_datum, a))
def testDTypeObjectGivesFalse(self): dt = np.dtype([("spam", np.str_, 16), ("eggs", np.float64, (2,))]) a = np.array([("spam", (8.0, 7.0)), ("eggs", (6.0, 5.0))], dtype=dt) self.assertFalse(debug_data.has_inf_or_nan(self._dummy_datum, a))
def testNanAndInf(self): a = np.array([np.inf, np.nan, 7.0]) self.assertTrue(debug_data.has_inf_or_nan(self._dummy_datum, a))
def testDTypeIntegerWorks(self): a = np.array([1, 3, 3, 7], dtype=np.int16) self.assertFalse(debug_data.has_inf_or_nan(self._dummy_datum, a))
def testDTypeStringGivesFalse(self): """isnan and isinf are not applicable to strings.""" a = np.array(["s", "p", "a", "m"]) self.assertFalse(debug_data.has_inf_or_nan(self._dummy_datum, a))
def testDTypeComplexWorks(self): a = np.array([1j, 3j, 3j, 7j], dtype=np.complex128) self.assertFalse(debug_data.has_inf_or_nan(self._dummy_datum, a)) b = np.array([1j, 3j, 3j, 7j, np.nan], dtype=np.complex256) self.assertTrue(debug_data.has_inf_or_nan(self._dummy_datum, b))