Exemplo n.º 1
0
    def test_to_tex_scientific_notation(self):

        value = 12.3456e7

        expected = r'1.2\times10^{8}'

        actual = py2tex.to_tex_scientific_notation(value, 2)

        self.assertEqual(expected, actual)
Exemplo n.º 2
0
    def test_to_tex_scientific_notation_no_digits(self):
        '''When we would produce '9\\times10^{X}',
        instead return just '10^{X+1}', when sig_figs==0
        '''

        value = 5.5e70

        expected = r'10^{71}'

        actual = py2tex.to_tex_scientific_notation(value, 0)

        self.assertEqual(expected, actual)
Exemplo n.º 3
0
    def test_to_tex_scientific_notation_small_fraction(self):
        '''Test that when we provide a value between 0.1 and 1 things work
        still
        '''

        value = 0.0067

        expected = r'7\times10^{-3}'

        actual = py2tex.to_tex_scientific_notation(value, 1)

        self.assertEqual(expected, actual)
Exemplo n.º 4
0
    def test_to_tex_scientific_notation_neg_one_to_zero(self):
        '''Test that when we provide a value between 0.1 and 1 things work
        still
        '''

        value = 0.12

        expected = r'1.2\times10^{-1}'

        actual = py2tex.to_tex_scientific_notation(value, 2)

        self.assertEqual(expected, actual)
Exemplo n.º 5
0
    def test_to_tex_scientific_notation_special_case_two(self):
        '''When we would produce 'X\\times10^{0]'
        instead return just X
        '''

        value = 3.45

        expected = r'3'

        actual = py2tex.to_tex_scientific_notation(value, 1)

        self.assertEqual(expected, actual)
Exemplo n.º 6
0
    def test_to_tex_scientific_notation_special_case(self):
        '''When we would produce '1\\times10^{X}',
        instead return just '10^{X}'
        '''

        value = 12.3456e7

        expected = r'10^{8}'

        actual = py2tex.to_tex_scientific_notation(value, 1)

        self.assertEqual(expected, actual)