Esempio n. 1
0
 def test_plot_3(self):
     matplotlib_scalar(self.grid,
                       pyplot.gca(), (0.1, 0.1, 0.1),
                       'z',
                       show_cell=True)
     l = list(i for i in pyplot.gca().get_children()
              if isinstance(i, Line2D))
     assert len(l) == 12
Esempio n. 2
0
    def test_plot(self):
        im = matplotlib_scalar(self.grid, pyplot.gca(), (0.1, 0.1, 0.1), 'z')

        axes = pyplot.gcf().axes
        assert len(axes) == 1
        axes = axes[0]

        ai = axes.findobj(AxesImage)
        assert len(ai) == 1
        ai = ai[0]
        assert ai == im

        testing.assert_allclose(axes.get_xlim(), (-0.55, 0.95))
        testing.assert_allclose(axes.get_ylim(),
                                (-0.1 * 3.**.5 / 2, 0.9 * 3.**.5 / 2))
Esempio n. 3
0
    def test_plot_2(self):
        expected_shape = (17, 10)

        def pp(x):
            testing.assert_equal(x.shape, expected_shape)
            return x

        im = matplotlib_scalar(self.grid,
                               pyplot.gca(), (0.1, 0.1, 0.1),
                               'z',
                               ppu=10,
                               margins=0,
                               postproc=pp)
        pyplot.colorbar(im)
        testing.assert_equal(im.get_size(), expected_shape[::-1])
Esempio n. 4
0
 def test_plot(self):
         
     im = matplotlib_scalar(self.grid, pyplot.gca(), (0.1,0.1,0.1), 'z')
     
     axes = pyplot.gcf().axes
     assert len(axes) == 1
     axes = axes[0]
     
     ai = axes.findobj(AxesImage)
     assert len(ai) == 1
     ai = ai[0]
     assert ai == im
     
     testing.assert_allclose(axes.get_xlim(), (-0.55, 0.95))
     testing.assert_allclose(axes.get_ylim(), (-0.1*3.**.5/2, 0.9*3.**.5/2))
Esempio n. 5
0
from dfttools.types import Basis, Grid
from dfttools import presentation

from numericalunits import angstrom
from matplotlib import pyplot
import numpy

grid = Grid(
    Basis((1*angstrom,1*angstrom,1*angstrom,0,0,-0.5), kind = 'triclinic'),
    (
        numpy.linspace(0,1,30,endpoint = False),
        numpy.linspace(0,1,30,endpoint = False),
        numpy.linspace(0,1,30,endpoint = False),
    ),
    numpy.zeros((30,30,30)),
)
grid.values = numpy.prod(numpy.sin(grid.explicit_coordinates()*2*numpy.pi), axis = -1)

presentation.matplotlib_scalar(grid, pyplot.gca(), (0.1,0.1,0.1), 'z', show_cell = True)
pyplot.show()
Esempio n. 6
0
 def test_plot_error_1(self):
     with self.assertRaises(ValueError):
         matplotlib_scalar(self.wrong_dims, pyplot.gca(), (0.1, 0.1, 0.1),
                           'z')
Esempio n. 7
0
from dfttools.types import Basis, Grid
from dfttools import presentation

from numericalunits import angstrom
from matplotlib import pyplot
import numpy

grid = Grid(
    Basis((1 * angstrom, 1 * angstrom, 1 * angstrom, 0, 0, -0.5),
          kind='triclinic'),
    (
        numpy.linspace(0, 1, 30, endpoint=False),
        numpy.linspace(0, 1, 30, endpoint=False),
        numpy.linspace(0, 1, 30, endpoint=False),
    ),
    numpy.zeros((30, 30, 30)),
)
grid.values = numpy.prod(numpy.sin(grid.explicit_coordinates() * 2 * numpy.pi),
                         axis=-1)

presentation.matplotlib_scalar(grid,
                               pyplot.gca(), (0.1, 0.1, 0.1),
                               'z',
                               show_cell=True)
pyplot.show()
Esempio n. 8
0
 def test_plot_error_1(self):
     with self.assertRaises(TypeError):
         matplotlib_scalar(self.wrong_dims, pyplot.gca(), (0.1,0.1,0.1), 'z')
Esempio n. 9
0
 def test_plot_3(self):
     im = matplotlib_scalar(self.grid, pyplot.gca(), (0.1,0.1,0.1), 'z', show_cell = True)
     l = list(i for i in pyplot.gca().get_children() if isinstance(i, Line2D))
     print len(l)
     assert len(l) == 12
Esempio n. 10
0
 def test_plot_2(self):
     im = matplotlib_scalar(self.grid, pyplot.gca(), (0.1,0.1,0.1), 'z', ppu = 10)
     testing.assert_equal(im.get_size(), (round(10*3.**.5/2), 15))