コード例 #1
0
    def test_inverse_transform(self, example_shp, expected):
        x, y, _ = spatial_efd.ProcessGeometryNorm(example_shp[2])
        coeffs = spatial_efd.CalculateEFD(x, y, 10)
        a, b = spatial_efd.inverse_transform(coeffs)

        ntest.assert_almost_equal(a[:5], expected['inverse_transform']['a'])
        ntest.assert_almost_equal(b[:5], expected['inverse_transform']['b'])
コード例 #2
0
 def test_process_geometry_norm(self, example_shp, expected):
     x, y, c = spatial_efd.ProcessGeometryNorm(example_shp[1])
     ntest.assert_almost_equal(c, expected['process_geometry_norm']['c'])
     ntest.assert_almost_equal(x[:10],
                               expected['process_geometry_norm']['x'])
     ntest.assert_almost_equal(y[:10],
                               expected['process_geometry_norm']['y'])
コード例 #3
0
    def test_normalize_efd(self, example_shp, expected):
        x, y, _ = spatial_efd.ProcessGeometryNorm(example_shp[0])
        coeffs = spatial_efd.CalculateEFD(x, y, 10)
        coeffs, rotation = spatial_efd.normalize_efd(coeffs)

        ntest.assert_almost_equal(coeffs[9],
                                  expected['normalize_efd']['coeffs'])
        assert pytest.approx(rotation) == expected['normalize_efd']['rotation']
コード例 #4
0
 def test_plotting_savefig(self, example_shp, tmpdir):
     matplotlib.pyplot.clf()
     x, y, _ = spatial_efd.ProcessGeometryNorm(example_shp[2])
     coeffs = spatial_efd.CalculateEFD(x, y, 10)
     a, b = spatial_efd.inverse_transform(coeffs)
     ax = spatial_efd.InitPlot()
     spatial_efd.PlotEllipse(ax, a, b, color='k', width=1.)
     spatial_efd.SavePlot(ax, 5, tmpdir, 'png')
     assert os.path.isfile('{0}_5.png'.format(tmpdir))
コード例 #5
0
    def test_average_sd(self, example_shp, expected):
        coeffsList = []

        for i in range(3):
            x, y, _ = spatial_efd.ProcessGeometryNorm(example_shp[i])
            coeffsList.append(spatial_efd.CalculateEFD(x, y, 10))

        avg = spatial_efd.AverageCoefficients(coeffsList)
        sd = spatial_efd.AverageSD(coeffsList, avg)
        ntest.assert_almost_equal(sd[3], expected['average_sd']['sd'])
コード例 #6
0
 def test_calculate_dc_coefficients(self, example_shp, expected):
     x, y, _ = spatial_efd.ProcessGeometryNorm(example_shp[2])
     dc = spatial_efd.calculate_dc_coefficients(x, y)
     assert pytest.approx(dc) == expected['calculate_dc_coefficients']['dc']
コード例 #7
0
 def test_fourier_power(self, example_shp):
     x, y, _ = spatial_efd.ProcessGeometryNorm(example_shp[2])
     coeffs = spatial_efd.CalculateEFD(x, y, 500)
     n = spatial_efd.FourierPower(coeffs, x)
     assert n == 19
コード例 #8
0
 def test_calculate_efd(self, example_shp, expected):
     x, y, _ = spatial_efd.ProcessGeometryNorm(example_shp[2])
     coeffs = spatial_efd.CalculateEFD(x, y, 10)
     ntest.assert_almost_equal(coeffs[6],
                               expected['calculate_efd']['coeffs'])