public void ReShape() { var np = new NumPyGeneric <int>(); var n = np.reshape(np.arange(6), 3, 2); Assert.IsTrue(n[0, 0] == 0); Assert.IsTrue(n[1, 1] == 3); Assert.IsTrue(n[2, 1] == 5); // Assert.IsTrue(np2.ToString().Equals("array([[0, 1], [2, 3], [4, 5]])")); n = np.reshape(np.arange(6), 2, 3, 1); Assert.IsTrue(n[1, 1, 0] == 4); Assert.IsTrue(n[1, 2, 0] == 5); n = np.reshape(np.arange(12), 2, 3, 2); Assert.IsTrue(n[0, 0, 1] == 1); Assert.IsTrue(n[1, 0, 1] == 7); Assert.IsTrue(n[1, 1, 0] == 8); n = np.reshape(np.arange(12), 3, 4); Assert.IsTrue(n[1, 1] == 5); Assert.IsTrue(n[2, 0] == 8); n = np.reshape(n, 2, 6); Assert.IsTrue(n[1, 0] == 6); }
public void absolute() { var np = new NumPyGeneric <double>(); //2D var n = np.arange(-2, 2).reshape(2, 2); var n1 = np.absolute(n); Assert.IsTrue(n1[0, 0] == 2); Assert.IsTrue(n1[0, 1] == 1); Assert.IsTrue(n1[1, 0] == 0); Assert.IsTrue(n1[1, 1] == 1); //3D n = np.arange(-4, 4).reshape(2, 2, 2); n1 = np.absolute(n); Assert.IsTrue(n1[0, 0, 0] == 4); Assert.IsTrue(n1[0, 0, 1] == 3); Assert.IsTrue(n1[1, 0, 0] == 0); Assert.IsTrue(n1[1, 1, 1] == 3); //4D n = np.arange(-12, 12).reshape(2, 3, 2, 2); n1 = np.absolute(n); Assert.IsTrue(n1[0, 0, 0, 0] == 12); Assert.IsTrue(n1[0, 1, 0, 0] == 8); Assert.IsTrue(n1[1, 2, 1, 1] == 11); Assert.IsTrue(n1[1, 2, 0, 1] == 9); }
public void amin0axis() { var nd2 = new NDArrayGeneric <double>(); nd2 = np.arange(1000 * 8 * 8 * 8).reshape(1000, 8, 8, 8); //var nd3 = nd2.AMin(0); }
public void HStackNDArrays() { //1D var np = new NumPyGeneric <double>(); var n1 = np.array(new double[] { 1, 2, 3 }); var n2 = np.array(new double[] { 2, 3, 4 }); var n = np.hstack(n1, n2); Assert.IsTrue(n.Size == (n1.Size + n2.Size)); Assert.IsTrue(n[0] == 1); Assert.IsTrue(n[1] == 2); Assert.IsTrue(n[3] == 2); Assert.IsTrue(n[5] == 4); //2D n1 = np.array(new double[][] { new double[] { 1 }, new double[] { 2 }, new double[] { 3 } }); n2 = np.array(new double[][] { new double[] { 4 }, new double[] { 5 }, new double[] { 6 } }); n = np.hstack(n1, n2); Assert.IsTrue(n.Size == (n1.Size + n2.Size)); Assert.IsTrue(n[0, 0] == 1); Assert.IsTrue(n[1, 0] == 2); Assert.IsTrue(n[2, 0] == 3); Assert.IsTrue(n[0, 1] == 4); Assert.IsTrue(n[1, 1] == 5); Assert.IsTrue(n[2, 1] == 6); //3D n1 = np.arange(12).reshape(2, 3, 2); n2 = np.arange(12).reshape(2, 3, 2); n = np.hstack(n1, n2); Assert.IsTrue(n.Size == (n1.Size + n2.Size)); Assert.IsTrue(n[0, 0, 0] == 0); Assert.IsTrue(n[0, 1, 0] == 2); Assert.IsTrue(n[0, 2, 1] == 5); //4D //n1 = np.arange(24 * 10000000).ReShape(20000, 30, 20, 2); //n2 = np.arange(24 * 10000000).ReShape(20000, 30, 20, 2); //n = np.hstack(n1, n2); //Assert.IsTrue(n.Size == (n1.Size + n2.Size)); }
public void amax() { var np = new NumPyGeneric <double>(); //no axis var n = np.arange(4).reshape(2, 2); var n1 = np.amax(n); Assert.IsTrue(n1[0] == 3); //2D with axis n1 = np.amax(n, 0); Assert.IsTrue(n1[0] == 2); Assert.IsTrue(n1[1] == 3); n1 = np.amax(n, 1); Assert.IsTrue(n1[0] == 1); Assert.IsTrue(n1[1] == 3); //3D n = np.arange(24).reshape(4, 3, 2); n1 = np.amax(n, 0); Assert.IsTrue(n1[0, 1] == 19); Assert.IsTrue(n1[2, 1] == 23); Assert.IsTrue(n1[1, 1] == 21); n1 = np.amax(n, 1); Assert.IsTrue(n1[1, 1] == 11); Assert.IsTrue(n1[2, 1] == 17); Assert.IsTrue(n1[3, 0] == 22); //4D n = np.arange(24).reshape(2, 3, 2, 2); n1 = np.amax(n, 1); Assert.IsTrue(n1[0, 0, 1] == 9); Assert.IsTrue(n1[1, 0, 1] == 21); Assert.IsTrue(n1[1, 1, 1] == 23); n1 = np.amax(n, 3); Assert.IsTrue(n1[0, 1, 1] == 7); Assert.IsTrue(n1[1, 1, 1] == 19); Assert.IsTrue(n1[1, 2, 1] == 23); }
public void Setup() { np = new NumPyGeneric <double>(); nd = np.arange(1000 * 8 * 8 * 8).reshape(1000, 8, 8, 8); }
public void arange() { np.arange(length); }