-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Amanda Potts <ajpotts@users.noreply.github.com>
- Loading branch information
Showing
20 changed files
with
1,196 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -5,7 +5,7 @@ ArgSortMsg | |
CastMsg | ||
EfuncMsg | ||
IndexingMsg | ||
# LinalgMsg | ||
#LinalgMsg | ||
LogMsg | ||
ManipulationMsg | ||
OperatorMsg | ||
|
This file contains 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,53 @@ | ||
import json | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
import arkouda as ak | ||
import arkouda.array_api as xp | ||
|
||
# requires the server to be built with 2D array support | ||
SHAPES = [(), (0,), (0, 0), (1,), (5,), (2, 2), (5, 10)] | ||
SIZES = [1, 0, 0, 1, 5, 4, 50] | ||
DIMS = [0, 1, 2, 1, 1, 2, 2] | ||
|
||
def get_server_max_array_dims(): | ||
try: | ||
return json.load(open('serverConfig.json', 'r'))['max_array_dims'] | ||
except (ValueError, FileNotFoundError, TypeError, KeyError): | ||
return 1 | ||
|
||
class TestArrayCreation: | ||
@pytest.mark.skipif(get_server_max_array_dims() < 2, reason="test_zeros requires server with 'max_array_dims' >= 2") | ||
def test_zeros(self): | ||
for shape, size, dim in zip(SHAPES, SIZES, DIMS): | ||
for dtype in ak.ScalarDTypes: | ||
a = xp.zeros(shape, dtype=dtype) | ||
assert a.size == size | ||
assert a.ndim == dim | ||
assert a.shape == shape | ||
assert a.dtype == dtype | ||
assert a.tolist() == np.zeros(shape, dtype=dtype).tolist() | ||
|
||
@pytest.mark.skipif(get_server_max_array_dims() < 2, reason="test_ones requires server with 'max_array_dims' >= 2") | ||
def test_ones(self): | ||
for shape, size, dim in zip(SHAPES, SIZES, DIMS): | ||
for dtype in ak.ScalarDTypes: | ||
a = xp.ones(shape, dtype=dtype) | ||
assert a.size == size | ||
assert a.ndim == dim | ||
assert a.shape == shape | ||
assert a.dtype == dtype | ||
assert a.tolist() == np.ones(shape, dtype=dtype).tolist() | ||
|
||
@pytest.mark.skipif(get_server_max_array_dims() < 2, reason="test_from_numpy requires server with 'max_array_dims' >= 2") | ||
def test_from_numpy(self): | ||
# TODO: support 0D (scalar) arrays | ||
# (need changes to the create0D command from #2967) | ||
for shape in SHAPES[1:]: | ||
a = np.random.randint(0, 10, size=shape, dtype=np.int64) | ||
b = xp.asarray(a) | ||
assert b.size == a.size | ||
assert b.ndim == a.ndim | ||
assert b.shape == a.shape | ||
assert b.tolist() == a.tolist() |
Oops, something went wrong.