-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix failure to write OpenDX file (Issue #21)
- change delta to DxD array if it is 1D - added additional test (currently failing) - use tempdir (added to travis and tests_require) - fixes #21
- Loading branch information
Showing
5 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
import tempdir | ||
import os | ||
|
||
import numpy as np | ||
from numpy.testing import assert_array_equal | ||
from numpy.testing import assert_array_equal, assert_array_almost_equal | ||
from nose.tools import assert_equal | ||
|
||
from gridData import Grid | ||
|
||
|
||
def test_dx(): | ||
def test_read_dx(): | ||
g = Grid('gridData/tests/test.dx') | ||
POINTS = 8 | ||
assert_array_equal(g.grid.flat, np.ones(POINTS)) | ||
assert_equal(g.grid.size, POINTS) | ||
assert_array_equal(g.delta, np.ones(3)) | ||
assert_array_equal(g.origin, np.zeros(3)) | ||
|
||
def test_write_dx(counts=100, ndim=3): | ||
h, edges = np.histogramdd(np.random.random((counts, ndim)), bins=10) | ||
g = Grid(h, edges) | ||
assert_equal(g.grid.sum(), counts) | ||
|
||
with tempdir.in_tempdir(): | ||
outfile = "grid.dx" | ||
g.export(outfile) | ||
g2 = Grid(outfile) | ||
|
||
assert_array_almost_equal(g.grid, g2.grid, | ||
err_msg="written grid does not match original") | ||
assert_array_almost_equal(g.delta, g2.delta, | ||
err_msg="deltas of written grid do not match original") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters