Esempio n. 1
0
    def test_text(self):
        # TODO test that the right type of object is produced?
        title_block = Title('timestep {num}', num=[1, 2])

        ax = plt.gca()
        assert ax.get_title() == 'timestep 1'
        title_block._update(1)
        assert ax.get_title() == 'timestep 2'
        plt.close('all')
Esempio n. 2
0
 def test_multiple_replacements(self):
     actual = Title('timestep {num}, max density {n}',
                    num=[1, 2],
                    n=[500, 10]).titles
     expected = [
         'timestep {num}, max density {n}'.format(num=1, n=500),
         'timestep {num}, max density {n}'.format(num=2, n=10)
     ]
     assert actual == expected
Esempio n. 3
0
 def test_mpl_kwargs(self):
     expected = {'loc': 'left', 'fontstyle': 'italic'}
     actual = Title('timestep {num}', num=[1, 2], **expected)
     assert actual._mpl_kwargs == expected
Esempio n. 4
0
 def test_format_str_numpy_arrays(self):
     actual = Title('timestep {num}', num=np.array([1, 2])).titles
     assert actual == ['timestep 1', 'timestep 2']
Esempio n. 5
0
 def test_string_formatting(self):
     actual = Title('timestep {values:.2f}', values=[5e7]).titles
     assert actual == ['timestep 50000000.00']
Esempio n. 6
0
 def test_no_replacements(self):
     actual = Title('Name').titles
     assert actual == ['Name']
Esempio n. 7
0
    def test_format_str(self):
        actual = Title('timestep {num}', num=[1, 2]).titles
        assert actual == ['timestep 1', 'timestep 2']

        actual = Title('timestep {num}', num=[1]).titles
        assert actual == ['timestep 1']
Esempio n. 8
0
 def test_invalid_input(self):
     with pytest.raises(TypeError):
         Title(0)
     with pytest.raises(TypeError):
         Title([6, 7])
Esempio n. 9
0
 def test_list_of_str(self):
     labels = ['timestep 0', 'timestep 1']
     result = Title(labels)
     assert labels == result.titles
     assert len(result) == 2