Exemplo n.º 1
0
 def test_incorrect_spacing(self):
     fl = ScalarFormatterLocator(unit=u.m)
     fl.spacing = 0.032 * u.m
     with pytest.warns(UserWarning,
                       match=r'Spacing is not a multiple of base spacing'):
         fl.format = 'x.xx'
     assert_almost_equal(fl.spacing.to_value(u.m), 0.03)
Exemplo n.º 2
0
    def test_spacing(self):

        fl = ScalarFormatterLocator(spacing=3. * u.m)
        assert fl.values is None
        assert fl.number is None
        assert fl.spacing == 3. * u.m

        values, spacing = fl.locator(34.3, 55.4)
        assert_almost_equal(values.value, [36., 39., 42., 45., 48., 51., 54.])

        fl.spacing = 0.5 * u.m
        values, spacing = fl.locator(34.3, 36.1)
        assert_almost_equal(values.value, [34.5, 35., 35.5, 36.])

        with pytest.warns(UserWarning, match=r'Spacing is too small'):
            fl.format = 'x'
        values, spacing = fl.locator(34.3, 36.1)
        assert_almost_equal(values.value, [35., 36.])
Exemplo n.º 3
0
    def test_spacing(self):

        fl = ScalarFormatterLocator(spacing=3. * u.m)
        assert fl.values is None
        assert fl.number is None
        assert fl.spacing == 3. * u.m

        values, spacing = fl.locator(34.3, 55.4)
        assert_almost_equal(values.value, [36., 39., 42., 45., 48., 51., 54.])

        fl.spacing = 0.5 * u.m
        values, spacing = fl.locator(34.3, 36.1)
        assert_almost_equal(values.value, [34.5, 35., 35.5, 36.])

        with pytest.warns(UserWarning, match='Spacing is too small'):
            fl.format = 'x'
        values, spacing = fl.locator(34.3, 36.1)
        assert_almost_equal(values.value, [35., 36.])
Exemplo n.º 4
0
 def test_incorrect_spacing(self):
     fl = ScalarFormatterLocator(unit=u.m)
     fl.spacing = 0.032 * u.m
     with pytest.warns(UserWarning, match='Spacing is not a multiple of base spacing'):
         fl.format = 'x.xx'
     assert_almost_equal(fl.spacing.to_value(u.m), 0.03)