Skip to content

Commit e74efba

Browse files
committed
np.math.Test: separated unit-tests.
1 parent f475dc7 commit e74efba

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

test/NumSharp.UnitTest/Math/np.math.Test.cs

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void DivideUInt16()
135135
}
136136

137137
[TestMethod]
138-
public void Maximum_Minimum_Slice()
138+
public void Minimum_Slice()
139139
{
140140
//>>> boxes1 = np.array([12.875, 14.125, 39.75, 49]).reshape(1, 4)
141141
//>>> boxes2 = np.array([25.875, 30.6875, 27.125, 32.3125, 25.5, 29.625, 27.5, 33.375, 24.4375, 30.0625, 28.5625, 32.9375]).reshape(3, 4)
@@ -160,17 +160,44 @@ public void Maximum_Minimum_Slice()
160160
24.4375, 30.0625, 28.5625, 32.9375
161161
}).reshape(3, 4);
162162

163-
var left_up = boxes1[Slice.Ellipsis, new Slice(":2")];
164-
var right_down = boxes2[Slice.Ellipsis, new Slice(":2")];
165-
left_up.Should().BeOfValues(12.875, 14.125).And.BeShaped(1, 2);
166-
right_down.Should().BeOfValues(25.875, 30.6875, 25.5, 29.625, 24.4375, 30.0625).And.BeShaped(3,2);
167-
var z = np.maximum(left_up, right_down);
168-
z.Should().BeOfValues(25.875, 30.6875, 25.5, 29.625, 24.4375, 30.0625).And.BeShaped(3, 2);
169-
170-
left_up = boxes1[Slice.Ellipsis, new Slice("2:")];
171-
right_down = boxes2[Slice.Ellipsis, new Slice("2:")];
172-
z = np.minimum(left_up, right_down);
163+
var left_up = boxes1[Slice.Ellipsis, new Slice("2:")];
164+
var right_down = boxes2[Slice.Ellipsis, new Slice("2:")];
165+
var z = np.minimum(left_up, right_down);
173166
z.Should().BeOfValues(27.125, 32.3125, 27.5, 33.375, 28.5625, 32.9375).And.BeShaped(3, 2);
167+
}
168+
169+
[TestMethod]
170+
public void Maximum_Slice()
171+
{
172+
//>>> boxes1 = np.array([12.875, 14.125, 39.75, 49]).reshape(1, 4)
173+
//>>> boxes2 = np.array([25.875, 30.6875, 27.125, 32.3125, 25.5, 29.625, 27.5, 33.375, 24.4375, 30.0625, 28.5625, 32.9375]).reshape(3, 4)
174+
//>>> x = boxes1[..., :2]
175+
//>>> x
176+
//array([[12.875, 14.125]])
177+
//>>> y = boxes2[..., :2]
178+
//>>> y
179+
//array([[25.875 , 30.6875],
180+
// [25.5 , 29.625 ],
181+
// [24.4375, 30.0625]])
182+
//>>> z = np.maximum(x, y)
183+
//>>> z
184+
//array([[25.875, 30.6875],
185+
// [25.5 , 29.625 ],
186+
// [24.4375, 30.0625]])
187+
var boxes1 = np.array(new double[] { 12.875, 14.125, 39.75, 49 }).reshape(1, 4);
188+
var boxes2 = np.array(new double[]
189+
{
190+
25.875, 30.6875, 27.125, 32.3125,
191+
25.5, 29.625 , 27.5, 33.375,
192+
24.4375, 30.0625, 28.5625, 32.9375
193+
}).reshape(3, 4);
194+
195+
var x = boxes1[Slice.Ellipsis, new Slice(":2")];
196+
var y = boxes2[Slice.Ellipsis, new Slice(":2")];
197+
x.Should().BeOfValues(12.875, 14.125).And.BeShaped(1, 2);
198+
y.Should().BeOfValues(25.875, 30.6875, 25.5, 29.625, 24.4375, 30.0625).And.BeShaped(3, 2);
199+
var z = np.maximum(x, y);
200+
z.Should().BeOfValues(25.875, 30.6875, 25.5, 29.625, 24.4375, 30.0625).And.BeShaped(3, 2);
174201
}
175202
}
176203
}

0 commit comments

Comments
 (0)