|
1 | 1 | from __future__ import absolute_import, division |
2 | 2 |
|
| 3 | +import pytest |
| 4 | + |
3 | 5 | import numpy as np |
4 | 6 | from numpy.testing import (assert_almost_equal, |
5 | 7 | assert_equal) |
6 | 8 |
|
7 | | -from gridData import Grid |
| 9 | +from gridData import Grid, CCP4 |
8 | 10 |
|
9 | 11 | from . import datafiles |
10 | 12 |
|
11 | | -def test_ccp4(): |
12 | | - g = Grid(datafiles.CCP4) |
| 13 | +@pytest.fixture(scope="module") |
| 14 | +def g(): |
| 15 | + return Grid(datafiles.CCP4) |
| 16 | + |
| 17 | +def test_ccp4(g): |
13 | 18 | POINTS = 192 |
14 | 19 | assert_equal(g.grid.flat, np.arange(1, POINTS+1)) |
15 | 20 | assert_equal(g.grid.size, POINTS) |
16 | 21 | assert_almost_equal(g.delta, [3./4, .5, 2./3]) |
17 | 22 | assert_equal(g.origin, np.zeros(3)) |
| 23 | + |
| 24 | +@pytest.fixture(scope="module") |
| 25 | +def ccp4data(): |
| 26 | + return CCP4.CCP4(datafiles.CCP4_1JZV) |
| 27 | + |
| 28 | +@pytest.mark.parametrize('name,value', [ |
| 29 | + ('nc', 96), |
| 30 | + ('nr', 76), |
| 31 | + ('ns', 70), |
| 32 | + ('mode', 2), |
| 33 | + ('ncstart', -4), |
| 34 | + ('nrstart', -23), |
| 35 | + ('nsstart', 102), |
| 36 | + ('nx', 84), |
| 37 | + ('ny', 84), |
| 38 | + ('nz', 160), |
| 39 | + ('xlen', 45.79999923706055), |
| 40 | + ('ylen', 45.79999923706055), |
| 41 | + ('zlen', 89.6500015258789), |
| 42 | + ('alpha', 90.0), |
| 43 | + ('beta', 90.0), |
| 44 | + ('gamma', 90.0), |
| 45 | + ('mapc', 2), |
| 46 | + ('mapr', 1), |
| 47 | + ('maps', 3), |
| 48 | + ('amin', -0.9930942058563232), |
| 49 | + ('amax', 9.050403594970703), |
| 50 | + ('amean', -0.0005801090155728161), |
| 51 | + ('ispg', 92), |
| 52 | + ('nsymbt', 640), |
| 53 | + ('lskflg', 0), |
| 54 | + ('bsaflag', '@'), |
| 55 | + ('skwmat', None), |
| 56 | + ('skwtrn', None), |
| 57 | + ('endianness', 'little'), |
| 58 | + ('arms', 0.4034915268421173), |
| 59 | + ('nlabl', 1), |
| 60 | + ('label', ' Map from fft '), |
| 61 | +]) |
| 62 | +def test_ccp4_integer_reading(ccp4data, name, value): |
| 63 | + assert_equal(ccp4data.header[name], value) |
| 64 | + |
0 commit comments