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

Method _setup

numpy/core/tests/test_numeric.py:2520–2563  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2518 atol = 1e-8
2519
2520 def _setup(self):
2521 atol = self.atol
2522 rtol = self.rtol
2523 arr = np.array([100, 1000])
2524 aran = np.arange(125).reshape((5, 5, 5))
2525
2526 self.all_close_tests = [
2527 ([1, 0], [1, 0]),
2528 ([atol], [0]),
2529 ([1], [1 + rtol + atol]),
2530 (arr, arr + arr*rtol),
2531 (arr, arr + arr*rtol + atol),
2532 (aran, aran + aran*rtol),
2533 (np.inf, np.inf),
2534 (np.inf, [np.inf]),
2535 ([np.inf, -np.inf], [np.inf, -np.inf]),
2536 ]
2537 self.none_close_tests = [
2538 ([np.inf, 0], [1, np.inf]),
2539 ([np.inf, -np.inf], [1, 0]),
2540 ([np.inf, np.inf], [1, -np.inf]),
2541 ([np.inf, np.inf], [1, 0]),
2542 ([np.nan, 0], [np.nan, -np.inf]),
2543 ([atol*2], [0]),
2544 ([1], [1 + rtol + atol*2]),
2545 (aran, aran + rtol*1.1*aran + atol*1.1),
2546 (np.array([np.inf, 1]), np.array([0, np.inf])),
2547 ]
2548 self.some_close_tests = [
2549 ([np.inf, 0], [np.inf, atol*2]),
2550 ([atol, 1, 1e6*(1 + 2*rtol) + atol], [0, np.nan, 1e6]),
2551 (np.arange(3), [0, 1, 2.1]),
2552 (np.nan, [np.nan, np.nan, np.nan]),
2553 ([0], [atol, np.inf, -np.inf, np.nan]),
2554 (0, [atol, np.inf, -np.inf, np.nan]),
2555 ]
2556 self.some_close_results = [
2557 [True, False],
2558 [True, False, False],
2559 [True, True, False],
2560 [False, False, False],
2561 [True, False, False, False],
2562 [True, False, False, False],
2563 ]
2564
2565 def test_ip_isclose(self):
2566 self._setup()

Callers 4

test_ip_iscloseMethod · 0.95
test_ip_all_iscloseMethod · 0.95
test_ip_none_iscloseMethod · 0.95

Calls 1

reshapeMethod · 0.80

Tested by

no test coverage detected