-
Notifications
You must be signed in to change notification settings - Fork 313
Multi-dimensional array added #256
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
Changes from 42 commits
6adc171
0147664
41e4126
6a51719
bf55961
c736ee5
65365ec
ed73085
c84fd4d
96fe82f
464c05f
7ea7a43
d35900f
a8b3340
5507c58
ecd5d20
4b04734
7211a98
d8db935
d6c1f14
bcb2ee6
8e1b86f
db6fd14
e7a10cb
0dc9c6c
388abf1
f176f46
b842d54
cce3f28
a25e465
3427792
427fd5b
c306463
19ceaad
7027671
e691e93
17ee7a9
806965e
a204a64
b8db3e5
7a780c7
9b502d7
176afd9
8a6bba6
2abae14
5145abd
182f8f7
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,5 +1,5 @@ | ||
| from pydatastructs.linear_data_structures import ( | ||
| OneDimensionalArray, DynamicOneDimensionalArray) | ||
| OneDimensionalArray, DynamicOneDimensionalArray, MultiDimensionalArray) | ||
| from pydatastructs.utils.raises_util import raises | ||
|
|
||
|
|
||
JeanPierreMR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
@@ -21,6 +21,35 @@ def test_OneDimensionalArray(): | |
| assert raises(TypeError, lambda: ODA(int, set([1, 2, 3]))) | ||
| assert raises(ValueError, lambda: ODA(int, 3, [1])) | ||
|
|
||
|
|
||
| def test_MultiDimensionalArray(): | ||
| array = MultiDimensionalArray(int, 5, 9, 3, 8) | ||
czgdp1807 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert array.shape == (5, 9, 3, 8) | ||
|
Member
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 isn't working as expected.
Member
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. @JeanPierreMR Can you please look into the issue?
Contributor
Author
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. Yes, sure I could:
Member
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. Earlier we weren't saving the |
||
| array.fill(5) | ||
| array[1, 3, 2, 5] = 2.0 | ||
| assert array | ||
| assert array[1, 3, 2, 5] == 2.0 | ||
| assert array[1, 3, 0, 5] == 5 | ||
| assert array[1, 2, 2, 5] == 5 | ||
| assert array[2, 3, 2, 5] == 5 | ||
| assert raises(IndexError, lambda: array[5]) | ||
| assert raises(IndexError, lambda: array[4, 10]) | ||
| assert raises(IndexError, lambda: array[-1]) | ||
| assert raises(ValueError, lambda: MultiDimensionalArray()) | ||
| assert raises(ValueError, lambda: MultiDimensionalArray(int)) | ||
| assert raises(TypeError, lambda: MultiDimensionalArray(int, 5, 6, "")) | ||
| array = MultiDimensionalArray(int, 3, 2, 2) | ||
| array.fill(1) | ||
| array[0, 0, 0] = 0 | ||
| array[0, 0, 1] = 0 | ||
| array[1, 0, 0] = 0 | ||
| array[2, 1, 1] = 0 | ||
| assert str(array) == '[0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0]' | ||
| array = MultiDimensionalArray(int, 4) | ||
| array.fill(5) | ||
| array[3] = 3 | ||
| assert array[3] == 3 | ||
|
|
||
| def test_DynamicOneDimensionalArray(): | ||
| DODA = DynamicOneDimensionalArray | ||
| A = DODA(int, 0) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.