-
Notifications
You must be signed in to change notification settings - Fork 23
Increase code coverage for .py
files
#2268
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 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9cbf764
Add test_logspace_list_input
vlad-perevezentsev ca5ba5b
Add TestMgrid
vlad-perevezentsev 25a2c6a
Add test_create_from_usm_ndarray_error
vlad-perevezentsev 2027b27
Add TestAttributes to test_arraycreation.py
vlad-perevezentsev feb1ca8
Update test_flat.py
vlad-perevezentsev 60607bd
Add test_identity_error
vlad-perevezentsev 5f3d90b
Add test_ihfft_error to TestHfft
vlad-perevezentsev 7e7b773
Merge master into increase_coverage
vlad-perevezentsev 11b8f95
Test single slice without start in TestMgrid
vlad-perevezentsev 1092d77
Add test logspace with list base to test_array_creation
vlad-perevezentsev c30be6b
Expand TestMgrid
vlad-perevezentsev 6675ca8
Add test_inplace_scalar to TestFloorDivideRemainder
vlad-perevezentsev 84a52e4
Apply remarks
vlad-perevezentsev 3e694af
Merge master into increase_coverage
vlad-perevezentsev 5345a4d
Merge master into increase_coverage
vlad-perevezentsev 2fbef53
Update dpnp/tests/test_ndarray.py
antonwolfy 624c97b
Merge master into increase_coverage
vlad-perevezentsev 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
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 |
---|---|---|
@@ -1,34 +1,52 @@ | ||
import numpy | ||
import numpy as np | ||
import pytest | ||
|
||
import dpnp as inp | ||
|
||
|
||
@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"]) | ||
def test_flat(type): | ||
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9]) | ||
ia = inp.array(a) | ||
|
||
result = ia.flat[0] | ||
expected = a.flat[0] | ||
numpy.testing.assert_array_equal(expected, result) | ||
|
||
|
||
@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"]) | ||
def test_flat2(type): | ||
a = numpy.arange(1, 7).reshape(2, 3) | ||
ia = inp.array(a) | ||
|
||
result = ia.flat[3] | ||
expected = a.flat[3] | ||
numpy.testing.assert_array_equal(expected, result) | ||
|
||
|
||
@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"]) | ||
def test_flat3(type): | ||
a = numpy.arange(1, 7).reshape(2, 3).T | ||
ia = inp.array(a) | ||
|
||
result = ia.flat[3] | ||
expected = a.flat[3] | ||
numpy.testing.assert_array_equal(expected, result) | ||
from numpy.testing import assert_array_equal, assert_raises | ||
|
||
import dpnp | ||
|
||
|
||
class TestFlatiter: | ||
@pytest.mark.parametrize( | ||
"a, index", | ||
[ | ||
(np.array([1, 0, 2, -3, -1, 2, 21, -9]), 0), | ||
(np.arange(1, 7).reshape(2, 3), 3), | ||
(np.arange(1, 7).reshape(2, 3).T, 3), | ||
], | ||
ids=["1D array", "2D array", "2D.T array"], | ||
) | ||
def test_flat_getitem(self, a, index): | ||
a_dp = dpnp.array(a) | ||
result = a_dp.flat[index] | ||
expected = a.flat[index] | ||
assert_array_equal(expected, result) | ||
|
||
def test_flat_iteration(self): | ||
a = np.array([[1, 2], [3, 4]]) | ||
a_dp = dpnp.array(a) | ||
for dp_val, np_val in zip(a_dp.flat, a.flat): | ||
assert dp_val == np_val | ||
|
||
def test_init_error(self): | ||
assert_raises(TypeError, dpnp.flatiter, [1, 2, 3]) | ||
|
||
def test_flat_key_error(self): | ||
a_dp = dpnp.array(42) | ||
with pytest.raises(KeyError): | ||
_ = a_dp.flat[1] | ||
|
||
def test_flat_invalid_key(self): | ||
a_dp = dpnp.array([1, 2, 3]) | ||
flat = dpnp.flatiter(a_dp) | ||
# check __getitem__ | ||
with pytest.raises(TypeError): | ||
_ = flat["invalid"] | ||
# check __setitem__ | ||
with pytest.raises(TypeError): | ||
flat["invalid"] = 42 | ||
|
||
def test_flat_out_of_bounds(self): | ||
a_dp = dpnp.array([1, 2, 3]) | ||
flat = dpnp.flatiter(a_dp) | ||
with pytest.raises(IndexError): | ||
_ = flat[10] |
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
Oops, something went wrong.
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.