Пример #1
0
    def test4(self):
        x = quantities.arange(0 | units.yr, 10 | units.yr, 1 | units.yr)
        y = (2.0 | units.km) * (x / (2.0 | units.yr))**2 + (20.0 | units.km)

        fit = quantities.polyfit(x, y, 2)

        self.assertEquals(len(fit), 3)
        self.assertEquals(fit[0].unit, units.km / units.yr**2)

        fit_values = quantities.polyval(fit, x)

        self.assertEquals(fit_values.shape, x.shape)
        self.assertEquals(y.unit, fit_values.unit)

        self.assertAlmostRelativeEquals(y, fit_values, 1)
Пример #2
0
    def test4(self):
        x = quantities.arange(0 | units.yr, 10 | units.yr, 1 | units.yr)
        y = (2.0|units.km) * (x/ (2.0|units.yr))**2 + (20.0|units.km)

        fit = quantities.polyfit(x, y, 2)

        self.assertEquals(len(fit), 3)
        self.assertEquals(fit[0].unit, units.km/units.yr**2)

        fit_values = quantities.polyval(fit, x)

        self.assertEquals(fit_values.shape, x.shape)
        self.assertEquals(y.unit, fit_values.unit)

        self.assertAlmostRelativeEquals(y, fit_values, 1)