Skip to content

Commit 2c9d247

Browse files
committed
Modification of the tests taking into account the modified methods
1 parent d4f52de commit 2c9d247

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

src/Math-Matrix/PMTensorTest.class.st

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Class {
88
PMTensorTest >> testArray [
99

1010
| t1 t2 |
11-
t1 := PMTensor rows: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
11+
t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
1212
self assert: t1 array equals: #( 1 2 3 4 5 6 7 8 ).
1313

14-
t2 := PMTensor rows: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
14+
t2 := PMTensor fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
1515
#( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
1616
self
1717
assert: t2 array
@@ -36,20 +36,36 @@ PMTensorTest >> testCreateScalarTensor [
3636
PMTensorTest >> testFirst [
3737

3838
| a b |
39-
a := PMTensor rows: (1 to: 6) asArray.
39+
a := PMTensor fromNestedArray: (1 to: 6) asArray.
4040
self assert: a first equals: #( 1).
4141
b := a reshape: #( 3 2 ).
4242
self assert: b first equals: #( 1 1 )
4343
]
4444

45+
{ #category : #tests }
46+
PMTensorTest >> testFromNestedArray [
47+
48+
| t1 t2 |
49+
t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 )
50+
#( 5 6 7 8 ) ).
51+
self assert: t1 class equals: PMTensor.
52+
53+
t2 := PMTensor fromNestedArray: #( #( #( 1 1 ) #( 2 2 ) )
54+
#( #( 3 3 ) #( 4 4 ) )
55+
#( #( 4 4 ) #( 4 4 ) )
56+
#( #( 4 4 ) #( 4 4 ) ) ).
57+
self assert: t2 class equals: PMTensor.
58+
59+
]
60+
4561
{ #category : #tests }
4662
PMTensorTest >> testGet [
4763

4864
| t1 t2 |
49-
t1 := PMTensor rows: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
65+
t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
5066
self assert: (t1 get: #( 2 2 )) equals: 6.
5167

52-
t2 := PMTensor rows: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
68+
t2 := PMTensor fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
5369
#( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
5470
self assert: (t2 get: #( 3 2 1 )) equals: 11.
5571

@@ -60,10 +76,10 @@ PMTensorTest >> testGet [
6076
PMTensorTest >> testGetPosition [
6177

6278
| t1 t2 |
63-
t1 := PMTensor rows: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
79+
t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
6480
self assert: (t1 getPosition: #( 1 2 )) equals: 2.
6581

66-
t2 := PMTensor rows: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
82+
t2 := PMTensor fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
6783
#( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
6884
self assert: (t2 getPosition: #( 1 2 2 )) equals: 4
6985
]
@@ -73,10 +89,10 @@ PMTensorTest >> testRank [
7389

7490
| t1 t2 |
7591

76-
t1 := PMTensor rows: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
92+
t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
7793
self assert: t1 rank equals: 2.
7894

79-
t2 := PMTensor rows: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
95+
t2 := PMTensor fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
8096
#( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
8197
self assert: t2 rank equals: 3
8298
]
@@ -85,39 +101,23 @@ PMTensorTest >> testRank [
85101
PMTensorTest >> testReshape [
86102

87103
| t t1 |
88-
t := PMTensor rows: #( #( 0 1 ) #( 2 3 ) #( 4 5 ) ).
104+
t := PMTensor fromNestedArray: #( #( 0 1 ) #( 2 3 ) #( 4 5 ) ).
89105
t1 := t reshape: #( 2 3 ).
90106

91107
self assert: t shape equals: #( 3 2 ).
92108
self assert: t1 shape equals: #( 2 3 ).
93109
self assert: t1 array == t array equals: true
94110
]
95111

96-
{ #category : #tests }
97-
PMTensorTest >> testRows [
98-
99-
| t1 t2 |
100-
t1 := PMTensor rows: #( #( 1 2 3 4 )
101-
#( 5 6 7 8 ) ).
102-
self assert: t1 class equals: PMTensor.
103-
104-
t2 := PMTensor rows: #( #( #( 1 1 ) #( 2 2 ) )
105-
#( #( 3 3 ) #( 4 4 ) )
106-
#( #( 4 4 ) #( 4 4 ) )
107-
#( #( 4 4 ) #( 4 4 ) ) ).
108-
self assert: t2 class equals: PMTensor.
109-
110-
]
111-
112112
{ #category : #tests }
113113
PMTensorTest >> testSetValue [
114114

115115
| t1 t2 |
116-
t1 := PMTensor rows: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
116+
t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
117117
t1 set: #( 2 2 ) value: 3.
118118
self assert: (t1 get: #( 2 2 ) ) equals: 3.
119119

120-
t2 := PMTensor rows: #( #( #( 1 2 ) #( 3 4 ) )
120+
t2 := PMTensor fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) )
121121
#( #( 5 6 ) #( 7 8 ) )
122122
#( #( 9 10 ) #( 11 12 ) )
123123
#( #( 13 14 ) #( 15 16 ) ) ).
@@ -129,11 +129,11 @@ PMTensorTest >> testSetValue [
129129
PMTensorTest >> testShape [
130130

131131
| t1 t2 |
132-
t1 := PMTensor rows: #( #( 1 2 3 4 )
132+
t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 )
133133
#( 5 6 7 8 ) ).
134134
self assert: t1 shape equals: #( 2 4 ).
135135

136-
t2 := PMTensor rows: #( #( #( 1 1 ) #( 2 2 ) )
136+
t2 := PMTensor fromNestedArray: #( #( #( 1 1 ) #( 2 2 ) )
137137
#( #( 3 3 ) #( 4 4 ) )
138138
#( #( 4 4 ) #( 4 4 ) )
139139
#( #( 4 4 ) #( 4 4 ) ) ).
@@ -144,10 +144,10 @@ PMTensorTest >> testShape [
144144
PMTensorTest >> testSize [
145145

146146
| t1 t2 |
147-
t1 := PMTensor rows: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
147+
t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
148148
self assert: t1 size equals: 8.
149149

150-
t2 := PMTensor rows: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
150+
t2 := PMTensor fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
151151
#( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
152152
self assert: t2 size equals: 16
153153
]
@@ -156,7 +156,7 @@ PMTensorTest >> testSize [
156156
PMTensorTest >> testStrides [
157157

158158
| a b |
159-
a := PMTensor rows: (1 to: 24) asArray.
159+
a := PMTensor fromNestedArray: (1 to: 24) asArray.
160160
self assert: a strides equals: #( 1 ).
161161
b := a reshape: #( 4 6 ).
162162
self assert: b strides equals: #( 6 1 ).
@@ -175,7 +175,7 @@ PMTensorTest >> testStrides [
175175
PMTensorTest >> testView [
176176

177177
| t t1 |
178-
t := PMTensor rows:
178+
t := PMTensor fromNestedArray:
179179
#( #( 10 11 12 ) #( 13 14 15 ) #( 16 17 18 ) #( #( 20 21 22 )
180180
#( 23 24 25 ) #( 26 27 28 ) )
181181
#( #( 30 31 32 ) #( 33 34 35 ) #( 36 37 38 ) ) ).

0 commit comments

Comments
 (0)