Пример #1
0
    def test_plot_1d_fill(self, plt):
        fbf_fn = "fake1.real4"
        fbf_arr = numpy.array([1, 2, 3, 4, 5], dtype=numpy.float32)
        fbf_arr.tofile(fbf_fn)

        try:
            plot_fn = plot_binary_file(fbf_fn, fill_value=2)
        finally:
            os.remove(fbf_fn)

        plt.savefig.assert_called_with(plot_fn)
        self.assertTrue(plt.plot.called)
        self.assertEqual(plt.plot.call_count, 1)
Пример #2
0
    def test_plot_2d_fill(self, plt):
        fbf_fn = "fake1.real4.5"
        fbf_arr = numpy.array(range(25), dtype=numpy.float32).reshape((5, 5))
        fbf_arr.tofile(fbf_fn)

        try:
            plot_fn = plot_binary_file(fbf_fn, fill_value=2)
        finally:
            os.remove(fbf_fn)

        plt.savefig.assert_called_with(plot_fn)
        self.assertTrue(plt.imshow.called)
        self.assertEqual(plt.imshow.call_count, 1)
        self.assertTrue(plt.colorbar.called)