|
| 1 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 2 | +using System; |
| 3 | +using System.Numerics; |
| 4 | +using System.Collections.Generic; |
| 5 | +using System.Text; |
| 6 | +using System.Linq; |
| 7 | +using NumSharp; |
| 8 | +using NumSharp.Generic; |
| 9 | + |
| 10 | +namespace NumSharp.UnitTest.Generic |
| 11 | +{ |
| 12 | + [TestClass] |
| 13 | + public class NDArrayGenericTest |
| 14 | + { |
| 15 | + |
| 16 | + [TestMethod] |
| 17 | + public void Generic1DBool_NDArray() |
| 18 | + { |
| 19 | + var np1 = new NDArray<bool>(new [] { true, true, false, false }, new Shape(4)); |
| 20 | + var np2 = new NDArray<bool>(new Shape(2)); |
| 21 | + var np3 = new NDArray<bool>(); |
| 22 | + Assert.IsTrue(Enumerable.SequenceEqual(new [] { true, true, false, false }, np1.Storage.GetData<bool>())); |
| 23 | + Assert.AreEqual(4, np1.size); |
| 24 | + Assert.AreEqual(1, np1.ndim); |
| 25 | + Assert.IsTrue(Enumerable.SequenceEqual(new[] { false, false }, np2.Storage.GetData<bool>())); |
| 26 | + Assert.AreEqual(2, np2.size); |
| 27 | + Assert.AreEqual(1, np2.ndim); |
| 28 | + Assert.IsTrue(Enumerable.SequenceEqual(new[] { false }, np3.Storage.GetData<bool>())); |
| 29 | + Assert.AreEqual(1, np3.size); |
| 30 | + Assert.AreEqual(1, np3.ndim); |
| 31 | + } |
| 32 | + |
| 33 | + [TestMethod] |
| 34 | + public void Generic2DBool_NDArrayOR() |
| 35 | + { |
| 36 | + var np1 = new NDArray<bool>(new Shape(2, 3)); |
| 37 | + np1.Storage.SetData(new bool[] { true, true, false, false, true, false }); |
| 38 | + Assert.IsTrue(Enumerable.SequenceEqual(new[] { true, true, false, false, true, false }, np1.Storage.GetData<bool>())); |
| 39 | + Assert.AreEqual(6, np1.size); |
| 40 | + Assert.AreEqual(2, np1.ndim); |
| 41 | + } |
| 42 | + } |
| 43 | +} |
0 commit comments