|
14 | 14 | import numpy as np |
15 | 15 | from numpy.testing import ( |
16 | 16 | assert_raises, assert_warns, assert_, assert_array_equal, SkipTest, |
17 | | - KnownFailureException, break_cycles, |
| 17 | + KnownFailureException, break_cycles, temppath |
18 | 18 | ) |
19 | 19 |
|
20 | 20 | from numpy._core._multiarray_tests import fromstring_null_term_c_api |
@@ -716,3 +716,26 @@ class TestDeprecatedDTypeParenthesizedRepeatCount(_DeprecationTestCase): |
716 | 716 | @pytest.mark.parametrize("string", ["(2)i,", "(3)3S,", "f,(2)f"]) |
717 | 717 | def test_parenthesized_repeat_count(self, string): |
718 | 718 | self.assert_deprecated(np.dtype, args=(string,)) |
| 719 | + |
| 720 | + |
| 721 | +class TestDeprecatedSaveFixImports(_DeprecationTestCase): |
| 722 | + # Deprecated in Numpy 2.1, 2024-05 |
| 723 | + message = "The 'fix_imports' flag is deprecated and has no effect." |
| 724 | + |
| 725 | + def test_deprecated(self): |
| 726 | + with temppath(suffix='.npy') as path: |
| 727 | + sample_args = (path, np.array(np.zeros((1024, 10)))) |
| 728 | + self.assert_not_deprecated(np.save, args=sample_args) |
| 729 | + self.assert_deprecated(np.save, args=sample_args, |
| 730 | + kwargs={'fix_imports': True}) |
| 731 | + self.assert_deprecated(np.save, args=sample_args, |
| 732 | + kwargs={'fix_imports': False}) |
| 733 | + for allow_pickle in [True, False]: |
| 734 | + self.assert_not_deprecated(np.save, args=sample_args, |
| 735 | + kwargs={'allow_pickle': allow_pickle}) |
| 736 | + self.assert_deprecated(np.save, args=sample_args, |
| 737 | + kwargs={'allow_pickle': allow_pickle, |
| 738 | + 'fix_imports': True}) |
| 739 | + self.assert_deprecated(np.save, args=sample_args, |
| 740 | + kwargs={'allow_pickle': allow_pickle, |
| 741 | + 'fix_imports': False}) |
0 commit comments