Пример #1
0
        public void Case2()
        {
            Console.WriteLine();
            var nd  = np.arange(10);
            var sh  = new NDIterator <int>(nd, true);
            int acc = 0;

            for (int i = 0; i < nd.size * 10; i++, sh.HasNext())
            {
                var val = sh.MoveNext();
                Console.WriteLine((acc += val) + " | " + val);
            }

            acc.Should().Be(Enumerable.Range(0, 10).Sum() * 10);
        }
Пример #2
0
        public void Case3_GetData_All()
        {
            var lhs   = np.full(5, (6, 3, 3), NPTypeCode.Int32);
            var slice = lhs.Storage.GetData(new int[0]);

            slice.Count.Should().Be(6 * 3 * 3);
            slice.Shape.IsScalar.Should().BeFalse();
            slice.Shape.IsSliced.Should().BeFalse("Slicing should occurs only when lhs is already sliced.");

            //via enumerator
            var iter = new NDIterator <int>(slice);

            for (int i = 0; i < 6 * 3 * 3; i++, iter.HasNext())
            {
                iter.MoveNext().Should().Be(5);
            }
        }