-
Notifications
You must be signed in to change notification settings - Fork 22
Native astype #642
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
Native astype #642
Changes from all commits
f6eb548
04f4764
af02a37
e75921d
e3c4fe5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-float64] | ||
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-float32] | ||
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-int64] | ||
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-int32] | ||
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-bool] | ||
tests/test_dparray.py::test_astype[[-2, -1, 0, 1, 2]-complex-bool_] | ||
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-float64] | ||
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-float32] | ||
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-int64] | ||
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-int32] | ||
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-bool] | ||
tests/test_dparray.py::test_astype[[[-2, -1], [1, 2]]-complex-bool_] | ||
tests/test_dparray.py::test_astype[[]-complex-float64] | ||
tests/test_dparray.py::test_astype[[]-complex-float32] | ||
tests/test_dparray.py::test_astype[[]-complex-int64] | ||
tests/test_dparray.py::test_astype[[]-complex-int32] | ||
tests/test_dparray.py::test_astype[[]-complex-bool] | ||
tests/test_dparray.py::test_astype[[]-complex-bool_] | ||
tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]] | ||
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]] | ||
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]] | ||
|
@@ -154,7 +172,6 @@ tests/test_linalg.py::test_svd[(5,3)-complex128] | |
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[ lambda x: x] | ||
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[ lambda x: dpnp.asarray(x).astype(dpnp.int8)] | ||
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[ lambda x: dpnp.asarray(x).astype(dpnp.complex64)] | ||
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[ lambda x: dpnp.asarray(x).astype(object)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[ lambda x: [(i, i) for i in x]] | ||
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[ lambda x: dpnp.vstack([x, x]).T] | ||
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[ lambda x: (dpnp.asarray([(i, i) for i in x], [("a", int), ("b", int)]).view(dpnp.recarray))] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import dpnp | ||
import numpy | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("res_dtype", | ||
[numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool, numpy.bool_, numpy.complex], | ||
ids=['float64', 'float32', 'int64', 'int32', 'bool', 'bool_', 'complex']) | ||
@pytest.mark.parametrize("arr_dtype", | ||
[numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool, numpy.bool_, numpy.complex], | ||
ids=['float64', 'float32', 'int64', 'int32', 'bool', 'bool_', 'complex']) | ||
@pytest.mark.parametrize("arr", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if array is empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. outdated. |
||
[[-2, -1, 0, 1, 2], [[-2, -1], [1, 2]], []], | ||
ids=['[-2, -1, 0, 1, 2]', '[[-2, -1], [1, 2]]', '[]']) | ||
def test_astype(arr, arr_dtype, res_dtype): | ||
numpy_array = numpy.array(arr, dtype=arr_dtype) | ||
dpnp_array = dpnp.array(numpy_array) | ||
expected = numpy_array.astype(res_dtype) | ||
result = dpnp_array.astype(res_dtype) | ||
numpy.testing.assert_array_equal(expected, result) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2881,6 +2881,7 @@ tests/test_umath.py::test_rint_big_int | |
tests/test_umath.py::TestRoundingFunctions::test_object_direct | ||
tests/test_umath.py::TestRoundingFunctions::test_object_indirect | ||
tests/test_umath.py::test_signaling_nan_exceptions | ||
tests/test_umath.py::TestSign::test_sign_dtype_nan_object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the reason? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test failed with error: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You can fallback on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, my fault. It is bad proposal, just leave it as is. |
||
tests/test_umath.py::TestSign::test_sign | ||
tests/test_umath.py::TestSign::test_sign_dtype_object | ||
tests/test_umath.py::test_spacing | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dtype_target
might be diffrent. It can contain some object with nodtype
. I think this is the cause of the error you saw