Exemple #1
0
    def test_srsf_conversion(self):
        """Converts to srsf and pull backs"""

        srsf = SRSF()

        converted = srsf.fit_transform(self.unimodal_samples)
        converted = srsf.inverse_transform(converted)

        # Distances between original samples and s -> to_srsf -> from_srsf
        distances = np.diag(metric(converted, self.unimodal_samples))

        np.testing.assert_allclose(distances, 0, atol=8e-3)
Exemple #2
0
    def test_from_srsf_with_output_points(self):
        """Test from srsf"""

        # Checks SRSF conversion
        srsf_transformer = SRSF(
            initial_value=0,
            output_points=self.dummy_sample.grid_points[0])
        srsf = srsf_transformer.inverse_transform(self.dummy_sample)

        data_matrix = [[[0.], [-0.23449228], [-0.83464009],
                        [-1.38200046], [-1.55623723], [-1.38200046],
                        [-0.83464009], [-0.23449228], [0.]]]

        np.testing.assert_almost_equal(data_matrix, srsf.data_matrix)
Exemple #3
0
    def test_from_srsf(self):
        """Test from srsf"""

        # Checks SRSF conversion
        srsf = SRSF(initial_value=0).inverse_transform(self.dummy_sample)

        data_matrix = [[[0.], [-0.23449228], [-0.83464009],
                        [-1.38200046], [-1.55623723], [-1.38200046],
                        [-0.83464009], [-0.23449228], [0.]]]

        np.testing.assert_almost_equal(data_matrix, srsf.data_matrix)
Exemple #4
0
    def test_to_srsf(self):
        """Test to srsf"""
        # Checks SRSF conversion

        srsf = SRSF().fit_transform(self.dummy_sample)

        data_matrix = [[[-1.061897], [-0.75559027], [0.25355399],
                        [0.81547327], [0.95333713], [0.81547327],
                        [0.25355399], [-0.75559027], [-1.06189697]]]

        np.testing.assert_almost_equal(data_matrix, srsf.data_matrix)