Recursively walk through the values and references, assert almost equal. Correctly handle: * Both the sparse and dense data representations * None in the reference type maps to not a value.
(value: np.ndarray, reference: Any)
| 489 | |
| 490 | |
| 491 | def assert_almost_equal(value: np.ndarray, reference: Any): |
| 492 | """Recursively walk through the values and references, assert almost equal. |
| 493 | |
| 494 | Correctly handle: |
| 495 | * Both the sparse and dense data representations |
| 496 | * None in the reference type maps to not a value. |
| 497 | """ |
| 498 | if isinstance(reference, list): |
| 499 | assert len(value) == len(reference) |
| 500 | for v, r in zip(value, reference): |
| 501 | assert_almost_equal(v, r) |
| 502 | elif isinstance(reference, dict): |
| 503 | assert len(value) == len(reference) |
| 504 | assert value.dtype.names is not None |
| 505 | for attribute in value.dtype.names: |
| 506 | if attribute in reference: |
| 507 | assert_almost_equal(value[attribute], reference[attribute]) |
| 508 | else: |
| 509 | assert_not_a_value(reference[attribute]) |
| 510 | elif reference is None: |
| 511 | assert_not_a_value(value) |
| 512 | else: |
| 513 | np.testing.assert_almost_equal(value, reference) |
| 514 | |
| 515 | |
| 516 | def assert_single_dataset_entries( |
no test coverage detected