| 530 | assert_(x['one'] > 1 and x['two'] > 2) |
| 531 | |
| 532 | def test_method_args(self): |
| 533 | # Make sure methods and functions have same default axis |
| 534 | # keyword and arguments |
| 535 | funcs1 = ['argmax', 'argmin', 'sum', 'any', 'all', 'cumsum', |
| 536 | 'cumprod', 'prod', 'std', 'var', 'mean', |
| 537 | 'round', 'min', 'max', 'argsort', 'sort'] |
| 538 | funcs2 = ['compress', 'take', 'repeat'] |
| 539 | |
| 540 | for func in funcs1: |
| 541 | arr = np.random.rand(8, 7) |
| 542 | arr2 = arr.copy() |
| 543 | res1 = getattr(arr, func)() |
| 544 | res2 = getattr(np, func)(arr2) |
| 545 | if res1 is None: |
| 546 | res1 = arr |
| 547 | |
| 548 | if res1.dtype.kind in 'uib': |
| 549 | assert_((res1 == res2).all(), func) |
| 550 | else: |
| 551 | assert_(abs(res1 - res2).max() < 1e-8, func) |
| 552 | |
| 553 | for func in funcs2: |
| 554 | arr1 = np.random.rand(8, 7) |
| 555 | arr2 = np.random.rand(8, 7) |
| 556 | res1 = None |
| 557 | if func == 'compress': |
| 558 | arr1 = arr1.ravel() |
| 559 | res1 = getattr(arr2, func)(arr1) |
| 560 | else: |
| 561 | arr2 = (15 * arr2).astype(int).ravel() |
| 562 | if res1 is None: |
| 563 | res1 = getattr(arr1, func)(arr2) |
| 564 | res2 = getattr(np, func)(arr1, arr2) |
| 565 | assert_(abs(res1 - res2).max() < 1e-8, func) |
| 566 | |
| 567 | def test_mem_lexsort_strings(self): |
| 568 | # Ticket #298 |