-
Notifications
You must be signed in to change notification settings - Fork 23
Implement dpnp.isreal, dpnp.isrealobj, dpnp.iscomplex, dpnp.iscomplexobj. #1916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d475db4
Implement dpnp.isreal, dpnp.iscomplex
npolina4 ed8eba7
Applied review comments
npolina4 6a13ade
Merge branch 'master' into impl_isreal
npolina4 e16f847
Applied review comments
npolina4 0c12a2a
Merge branch 'master' into impl_isreal
npolina4 b379e74
Simplified isreal and iscomplex tests
npolina4 8e1604c
Merge branch 'master' into impl_isreal
npolina4 b4b1df7
Merge branch 'master' into impl_isreal
antonwolfy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| import unittest | ||
|
|
||
| import numpy | ||
| import pytest | ||
|
|
||
| from tests.third_party.cupy import testing | ||
|
|
||
|
|
||
| class TestIsScalar(testing.NumpyAliasBasicTestBase): | ||
|
|
||
| func = "isscalar" | ||
|
|
||
| @testing.with_requires("numpy>=1.18") | ||
| def test_argspec(self): | ||
| super().test_argspec() | ||
|
|
||
|
|
||
| @testing.parameterize( | ||
npolina4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| *testing.product( | ||
| { | ||
| "value": [ | ||
| 0, | ||
| 0.0, | ||
| True, | ||
| numpy.int32(1), | ||
| numpy.array([1, 2], numpy.int32), | ||
| numpy.complex128(1), | ||
| numpy.complex128(1j), | ||
| numpy.complex128(1 + 1j), | ||
| None, | ||
| "abc", | ||
| "", | ||
| int, | ||
| numpy.int32, | ||
| ] | ||
| } | ||
| ) | ||
| ) | ||
| class TestIsScalarValues(testing.NumpyAliasValuesTestBase): | ||
|
|
||
| func = "isscalar" | ||
|
|
||
| def setUp(self): | ||
| self.args = (self.value,) | ||
|
|
||
|
|
||
| class TestIsScalarValues2(testing.NumpyAliasValuesTestBase): | ||
|
|
||
| func = "isscalar" | ||
|
|
||
| def setUp(self): | ||
| value = object() | ||
| self.args = (value,) | ||
|
|
||
|
|
||
| @pytest.mark.skip("isfortran not implemented") | ||
| @testing.parameterize( | ||
| *testing.product( | ||
| { | ||
| "value": [ | ||
| # C and F | ||
| numpy.ones(24, order="C"), | ||
| # C and not F | ||
| numpy.ones((4, 6), order="C"), | ||
| # not C and F | ||
| numpy.ones((4, 6), order="F"), | ||
| # not C and not F | ||
| numpy.ones((4, 6), order="C")[1:3][1:3], | ||
| ] | ||
| } | ||
| ) | ||
| ) | ||
| class TestIsFortran(unittest.TestCase): | ||
|
|
||
| @pytest.mark.skip("isfortran not implemented") | ||
npolina4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @testing.numpy_cupy_equal() | ||
| def test(self, xp): | ||
| return xp.isfortran(xp.asarray(self.value)) | ||
|
|
||
|
|
||
| @testing.parameterize( | ||
| {"func": "iscomplex"}, | ||
| {"func": "isreal"}, | ||
| ) | ||
| class TestTypeTestingFunctions(unittest.TestCase): | ||
|
|
||
| @testing.for_all_dtypes() | ||
| @testing.numpy_cupy_array_equal() | ||
| def test(self, xp, dtype): | ||
| return getattr(xp, self.func)(xp.ones(5, dtype=dtype)) | ||
|
|
||
| @pytest.mark.skip("support for scalar not implemented") | ||
| @testing.for_all_dtypes() | ||
| @testing.numpy_cupy_equal() | ||
| def test_scalar(self, xp, dtype): | ||
| return getattr(xp, self.func)(dtype(3)) | ||
|
|
||
| @pytest.mark.skip("tolist not implemented") | ||
| @testing.for_all_dtypes() | ||
| @testing.numpy_cupy_array_equal() | ||
| def test_list(self, xp, dtype): | ||
| return getattr(xp, self.func)( | ||
| testing.shaped_arange((2, 3), xp, dtype).tolist() | ||
| ) | ||
|
|
||
|
|
||
| @testing.parameterize( | ||
| {"func": "iscomplexobj"}, | ||
| {"func": "isrealobj"}, | ||
| ) | ||
| class TestTypeTestingObjFunctions(unittest.TestCase): | ||
|
|
||
| @testing.for_all_dtypes() | ||
| @testing.numpy_cupy_equal() | ||
| def test(self, xp, dtype): | ||
| return getattr(xp, self.func)(xp.ones(5, dtype=dtype)) | ||
|
|
||
| @testing.for_all_dtypes() | ||
| @testing.numpy_cupy_equal() | ||
| def test_scalar(self, xp, dtype): | ||
| return getattr(xp, self.func)(dtype(3)) | ||
|
|
||
| @pytest.mark.skip("tolist not implemented") | ||
| @testing.for_all_dtypes() | ||
| @testing.numpy_cupy_equal() | ||
| def test_list(self, xp, dtype): | ||
| return getattr(xp, self.func)( | ||
| testing.shaped_arange((2, 3), xp, dtype).tolist() | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.