Esempio n. 1
0
        public void TestBinaryOperations()
        {
            DataFrame df = DataFrameTests.MakeTestTableWithTwoColumns(10);

            // Binary ops always return a copy
            Assert.Equal(5, df.Add(5)[0, 0]);
            IReadOnlyList <int> listOfInts = new List <int>()
            {
                5, 5
            };

            Assert.Equal(5, df.Add(listOfInts)[0, 0]);
            Assert.Equal(-5, df.Subtract(5)[0, 0]);
            Assert.Equal(-5, df.Subtract(listOfInts)[0, 0]);
            Assert.Equal(5, df.Multiply(5)[1, 0]);
            Assert.Equal(5, df.Multiply(listOfInts)[1, 0]);
            Assert.Equal(1, df.Divide(5)[5, 0]);
            Assert.Equal(1, df.Divide(listOfInts)[5, 0]);
            Assert.Equal(0, df.Modulo(5)[5, 0]);
            Assert.Equal(0, df.Modulo(listOfInts)[5, 0]);
            Assert.Equal(5, df.And(5)[5, 0]);
            Assert.Equal(5, df.And(listOfInts)[5, 0]);
            Assert.Equal(5, df.Or(5)[5, 0]);
            Assert.Equal(5, df.Or(listOfInts)[5, 0]);
            Assert.Equal(0, df.Xor(5)[5, 0]);
            Assert.Equal(0, df.Xor(listOfInts)[5, 0]);
            Assert.Equal(2, df.LeftShift <int>(1)[1, 0]);
            Assert.Equal(1, df.RightShift <int>(1)[2, 0]);
            Assert.Equal(true, df.Equals(5)[5, 0]);
            Assert.Equal(true, df.Equals(listOfInts)[5, 0]);
            Assert.Equal(true, df.NotEquals(5)[4, 0]);
            Assert.Equal(true, df.NotEquals(listOfInts)[4, 0]);
            Assert.Equal(true, df.GreaterThanOrEqual(5)[6, 0]);
            Assert.Equal(true, df.GreaterThanOrEqual(listOfInts)[6, 0]);
            Assert.Equal(true, df.LessThanOrEqual(5)[4, 0]);
            Assert.Equal(true, df.LessThanOrEqual(listOfInts)[4, 0]);
            Assert.Equal(false, df.GreaterThan(5)[5, 0]);
            Assert.Equal(false, df.GreaterThan(listOfInts)[5, 0]);
            Assert.Equal(false, df.LessThan(5)[5, 0]);
            Assert.Equal(false, df.LessThan(listOfInts)[5, 0]);

            // The original DF is untouched
            Assert.Equal(0, df[0, 0]);
        }