예제 #1
0
 def test_variant_array_dim(self):
     v = ua.Variant([1, 2, 3, 4, 5, 6], dimensions=[2, 3])
     self.assertEqual(v.Value[1], 2)
     v2 = variant_from_binary(ua.utils.Buffer(variant_to_binary(v)))
     self.assertEqual(_reshape(v.Value, (2, 3)), v2.Value)
     self.assertEqual(v.VariantType, v2.VariantType)
     self.assertEqual(v.Dimensions, v2.Dimensions)
     self.assertEqual(v2.Dimensions, [2, 3])
예제 #2
0
 def test_variant_array_dim(self):
     v = ua.Variant([1, 2, 3, 4, 5, 6], dimensions=[2, 3])
     self.assertEqual(v.Value[1], 2)
     v2 = variant_from_binary(ua.utils.Buffer(variant_to_binary(v)))
     self.assertEqual(_reshape(v.Value, (2, 3)), v2.Value)
     self.assertEqual(v.VariantType, v2.VariantType)
     self.assertEqual(v.Dimensions, v2.Dimensions)
     self.assertEqual(v2.Dimensions, [2, 3])
예제 #3
0
    def test_flatten(self):
        l = [[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]], [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]]
        l2 = flatten(l)
        dims = get_shape(l)
        self.assertEqual(dims, [2, 3, 4])
        self.assertNotEqual(l, l2)

        l3 = _reshape(l2, (2, 3, 4))
        self.assertEqual(l, l3)


        l = [[[], [], []], [[], [], []]]
        l2 = flatten(l)
        dims = get_shape(l)
        self.assertEqual(dims, [2, 3, 0])

        l = [1, 2, 3, 4]
        l2 = flatten(l)
        dims = get_shape(l)
        self.assertEqual(dims, [4])
        self.assertEqual(l, l2)
예제 #4
0
    def test_flatten(self):
        l = [[[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]], [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]]]
        l2 = flatten(l)
        dims = get_shape(l)
        self.assertEqual(dims, [2, 3, 4])
        self.assertNotEqual(l, l2)

        l3 = _reshape(l2, (2, 3, 4))
        self.assertEqual(l, l3)


        l = [[[], [], []], [[], [], []]]
        l2 = flatten(l)
        dims = get_shape(l)
        self.assertEqual(dims, [2, 3, 0])

        l = [1, 2, 3, 4]
        l2 = flatten(l)
        dims = get_shape(l)
        self.assertEqual(dims, [4])
        self.assertEqual(l, l2)