Beispiel #1
0
        public void Case1_Axis_minus1()
        {
            var a   = np.ones((3, 3, 3), NPTypeCode.Int32);
            var ret = a.sum(-1);

            ret.Shape.IsScalar.Should().BeFalse();
            ret.size.Should().Be(9);
            FluentExtension.Should(ret.Shape).Be(new Shape(3, 3));
            ret.Cast <int>().Should().AllBeEquivalentTo(3);
        }
Beispiel #2
0
        public void Case2_Axis_minus1_keepdims()
        {
            var a   = np.ones((2, 1, 3, 5, 1), np.int32);
            var ret = a.sum(-1, keepdims: true);

            ret.Shape.IsScalar.Should().BeFalse();
            ret.size.Should().Be(30);
            FluentExtension.Should(ret.Shape).Be(new Shape(2, 1, 3, 5, 1));
            ret.Cast <int>().Should().AllBeEquivalentTo(1);
        }
Beispiel #3
0
        public void Case2_Axis2()
        {
            var a   = np.ones((2, 1, 3, 5, 1), np.int32);
            var ret = a.sum(2);

            ret.Shape.IsScalar.Should().BeFalse();
            ret.size.Should().Be(10);
            FluentExtension.Should(ret.Shape).Be(new Shape(2, 1, 5, 1));
            ret.Cast <int>().Should().AllBeEquivalentTo(3);
        }
Beispiel #4
0
        public void Case3_TurnIntoScalar()
        {
            NDArray a;
            NDArray ret;

            // >>> a = np.array(5)
            // >>> print(np.prod(a))
            // >>> print(np.prod(a).shape)
            // 5
            // ()

            a   = np.array(5);
            ret = np.prod(a);
            FluentExtension.Should(ret).BeScalar(5);

            ret = np.sum(a);
            FluentExtension.Should(ret).BeScalar(5);
        }