Exemplo n.º 1
0
    def test_sig_from_transpose_data(self):
        # https://github.com/datasig-ac-uk/esig/issues/124
        two_dim_stream1 = np.array([[0.11212, 1.1212], [0.11, 0.22]])
        sig1 = esig.stream2sig(two_dim_stream1, 2)

        two_dim_stream2 = np.transpose(
            np.array([[0.11212, 0.11], [1.1212, 0.22]]))
        sig2 = esig.stream2sig(two_dim_stream2, 2)

        assert_array_equal(sig1, sig2)
Exemplo n.º 2
0
    def test_calculation_width_2_depth_100_error(self):
        # Depth out of bounds for width 2
        width = 2
        depth = 100

        pattern = "Legitimate depth of 2<->\\d+ for records with width 2 exceeds limit"
        with self.assertRaisesRegex(RuntimeError, pattern):
            sig = esig.stream2sig(STREAM, depth)
Exemplo n.º 3
0
    def test_calculation_width_2_depth_2(self):
        # tosig implementation

        width = 2
        depth = 2

        sig = esig.stream2sig(STREAM, depth)
        self.assert_allclose(sig, SIGNATURE)
Exemplo n.º 4
0
    def test_calculation_width_2_depth_1(self):
        # Pure Python implementation
        width = 2
        depth = 1

        sig = esig.stream2sig(STREAM, depth)

        self.assert_allclose(sig, SIGNATURE[:3])
Exemplo n.º 5
0
    def test_dtype_validation_int64_fails(self):

        width = 2
        depth = 2

        stream = np.array([[1, 2], [3, 4], [5, 6]], dtype=np.int64)

        with self.assertRaises(TypeError):
            sig = esig.stream2sig(stream, depth)
Exemplo n.º 6
0
    def test_computed_size_vs_size(self):

        width = 2

        for depth in range(2, 6):
            with self.subTest(depth=depth):
                sig = esig.stream2sig(STREAM, depth)
                size = esig.sigdim(width, depth)
                self.assertEqual(size, sig.size)
Exemplo n.º 7
0
    def test_dtype_validation_float32_passes(self):

        width = 2
        depth = 2

        stream = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]],
                          dtype=np.float32)

        sig = esig.stream2sig(stream, depth)
        self.assertGreater(sig.size, 0)
Exemplo n.º 8
0
 def transform(x):
     return esig.stream2sig(x, self.depth)[1:].reshape(-1, 1)
Exemplo n.º 9
0
    def test_calculation_width_2_depth_0_error(self):
        width = 2
        depth = 0

        with self.assertRaises(ValueError):
            sig = esig.stream2sig(STREAM, depth)