File: chempybrick.py

package info (click to toggle)
pymol 3.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 74,084 kB
  • sloc: cpp: 482,660; python: 89,328; ansic: 29,512; javascript: 6,792; sh: 84; makefile: 25
file content (27 lines) | stat: -rw-r--r-- 735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from chempy import cpv
from pymol import cmd, testing, stored

class TestChempyBrick(testing.PyMOLTestCase):

    def test(self):
        try:
            import numpy
        except ImportError:
            self.skip('requires numpy')

        from chempy.brick import Brick

        spacing = (.5, .5, .5)
        origin = (3., 4., 5.)
        shape = (10, 10, 10)
        range_ =  [a * (b - 1) for (a, b) in zip (spacing, shape)]

        data = numpy.zeros(shape, float)

        brick = Brick.from_numpy(data, spacing, origin)
        self.assertArrayEqual(brick.range, range_)

        cmd.load_brick(brick, 'map')

        extent = cmd.get_extent('map')
        self.assertArrayEqual(extent, [origin, cpv.add(origin, range_)])