@@ -9,25 +9,55 @@ PMNDArrayTest >> testArray [
99
1010 | t1 t2 |
1111 t1 := PMNDArray fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
12- self assert: t1 array equals: #( 1 2 3 4 5 6 7 8 ) .
12+ self assert: t1 asArray equals: #( 1 2 3 4 5 6 7 8 ) .
1313
1414 t2 := PMNDArray fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
1515 #( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
1616 self
17- assert: t2 array
17+ assert: t2 asArray
1818 equals: #( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 )
1919]
2020
2121{ #category : #tests }
22- PMNDArrayTest >> testCreateScalarTensor [
22+ PMNDArrayTest >> testAt [
23+
24+ | t1 t2 |
25+ t1 := PMNDArray fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
26+ self assert: (t1 at: #( 2 2 ) ) equals: 6 .
27+
28+ t2 := PMNDArray fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
29+ #( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
30+ self assert: (t2 at: #( 3 2 1 ) ) equals: 11 .
31+
32+ self should: [t1 at: #( 4 4 ) ] raise: Error
33+ ]
34+
35+ { #category : #tests }
36+ PMNDArrayTest >> testAtPut [
37+
38+ | t1 t2 |
39+ t1 := PMNDArray fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
40+ t1 at: #( 2 2 ) put: 3 .
41+ self assert: (t1 at: #( 2 2 ) ) equals: 3 .
42+
43+ t2 := PMNDArray fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) )
44+ #( #( 5 6 ) #( 7 8 ) )
45+ #( #( 9 10 ) #( 11 12 ) )
46+ #( #( 13 14 ) #( 15 16 ) ) ).
47+ t2 at: #( 2 2 1) put: 10 .
48+ self assert: (t2 at: #( 2 2 1 ) ) equals: 10
49+ ]
50+
51+ { #category : #tests }
52+ PMNDArrayTest >> testCreateScalarNDArray [
2353
2454 | s |
25- s := PMNDArray newWith : 2 .
26- self assert: (s get : #( ) ) equals: 2 .
27- self should: [ s get : #( 1 1 ) ] raise: Error .
55+ s := PMNDArray fromScalar : 2 .
56+ self assert: (s at : #( ) ) equals: 2 .
57+ self should: [ s at : #( 1 1 ) ] raise: Error .
2858 self assert: s rank equals: 0 .
29- s set : #( ) value : 1 .
30- self assert: (s get : #( ) ) equals: 1 .
59+ s at : #( ) put : 1 .
60+ self assert: (s at : #( ) ) equals: 1 .
3161 self assert: s shape equals: #( ) .
3262 self assert: s size equals: 1
3363]
@@ -46,8 +76,8 @@ PMNDArrayTest >> testFirst [
4676PMNDArrayTest >> testFlattenedIndexOf [
4777
4878 | t1 t2 |
49- t1 := PMNDArray fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
50- self assert: (t1 flattenedIndexOf: #( 1 2 ) ) equals: 2 .
79+ t1 := PMNDArray fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8) #( 9 10 11 12) ).
80+ self assert: (t1 flattenedIndexOf: #( 3 2 ) ) equals: 10 .
5181
5282 t2 := PMNDArray fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
5383 #( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
@@ -70,20 +100,6 @@ PMNDArrayTest >> testFromNestedArray [
70100
71101]
72102
73- { #category : #tests }
74- PMNDArrayTest >> testGet [
75-
76- | t1 t2 |
77- t1 := PMNDArray fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
78- self assert: (t1 get: #( 2 2 ) ) equals: 6 .
79-
80- t2 := PMNDArray fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
81- #( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
82- self assert: (t2 get: #( 3 2 1 ) ) equals: 11 .
83-
84- self should: [t1 get: #( 4 4 ) ] raise: Error
85- ]
86-
87103{ #category : #tests }
88104PMNDArrayTest >> testRank [
89105
@@ -106,23 +122,7 @@ PMNDArrayTest >> testReshape [
106122
107123 self assert: t shape equals: #( 3 2 ) .
108124 self assert: t1 shape equals: #( 2 3 ) .
109- self assert: t1 array == t array equals: true
110- ]
111-
112- { #category : #tests }
113- PMNDArrayTest >> testSetValue [
114-
115- | t1 t2 |
116- t1 := PMNDArray fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
117- t1 set: #( 2 2 ) value: 3 .
118- self assert: (t1 get: #( 2 2 ) ) equals: 3 .
119-
120- t2 := PMNDArray fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) )
121- #( #( 5 6 ) #( 7 8 ) )
122- #( #( 9 10 ) #( 11 12 ) )
123- #( #( 13 14 ) #( 15 16 ) ) ).
124- t2 set: #( 2 2 1) value: 10 .
125- self assert: (t2 get: #( 2 2 1 ) ) equals: 10
125+ self assert: t1 asArray == t asArray equals: true
126126]
127127
128128{ #category : #tests }
@@ -180,7 +180,7 @@ PMNDArrayTest >> testView [
180180 #( 23 24 25 ) #( 26 27 28 ) )
181181 #( #( 30 31 32 ) #( 33 34 35 ) #( 36 37 38 ) ) ).
182182 t1 := t view.
183- self assert: t array == t1 array equals: true .
183+ self assert: t asArray == t1 asArray equals: true .
184184 self assert: t shape equals: t1 shape.
185185 self assert: t shape == t1 shape equals: false .
186186 self assert: t strides equals: t1 strides.
0 commit comments