MCPcopy Create free account
hub / github.com/numpy/numpy / test_object_logical

Method test_object_logical

numpy/core/tests/test_ufunc.py:1347–1371  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1345 assert_array_equal(result, a.cumsum())
1346
1347 def test_object_logical(self):
1348 a = np.array([3, None, True, False, "test", ""], dtype=object)
1349 assert_equal(np.logical_or(a, None),
1350 np.array([x or None for x in a], dtype=object))
1351 assert_equal(np.logical_or(a, True),
1352 np.array([x or True for x in a], dtype=object))
1353 assert_equal(np.logical_or(a, 12),
1354 np.array([x or 12 for x in a], dtype=object))
1355 assert_equal(np.logical_or(a, "blah"),
1356 np.array([x or "blah" for x in a], dtype=object))
1357
1358 assert_equal(np.logical_and(a, None),
1359 np.array([x and None for x in a], dtype=object))
1360 assert_equal(np.logical_and(a, True),
1361 np.array([x and True for x in a], dtype=object))
1362 assert_equal(np.logical_and(a, 12),
1363 np.array([x and 12 for x in a], dtype=object))
1364 assert_equal(np.logical_and(a, "blah"),
1365 np.array([x and "blah" for x in a], dtype=object))
1366
1367 assert_equal(np.logical_not(a),
1368 np.array([not x for x in a], dtype=object))
1369
1370 assert_equal(np.logical_or.reduce(a), 3)
1371 assert_equal(np.logical_and.reduce(a), None)
1372
1373 def test_object_comparison(self):
1374 class HasComparisons:

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
reduceMethod · 0.45

Tested by

no test coverage detected