Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Oct 20, 2017
1 parent 7f90e30 commit 916bb0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion qpformat/file_formats/single_npy_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

class SingleNpyNumpy(DataSet):
"""Field data stored in numpy's .npy file format
The experimental data given in `path` consist of a single
2D ndarray (no pickled objects). The ndarray is either
complex-valued (scattered field) or real-valued (phase).
"""

def __len__(self):
return 1

Expand Down
12 changes: 6 additions & 6 deletions tests/test_single_npy_numpy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os.path import abspath, dirname, join
from os.path import abspath, dirname
import sys
import tempfile

Expand All @@ -13,9 +13,9 @@ def test_load_phase():
# generate test data
tf = tempfile.mktemp(suffix=".npy", prefix="qpformat_test_")
phase = np.ones((20, 20), dtype=float)
phase *= np.linspace(0, .3, 20).reshape(-1,1)
phase *= np.linspace(0, .3, 20).reshape(-1, 1)
np.save(tf, phase)

ds = qpformat.load_data(tf)
assert np.allclose(ds.get_qpimage().pha, phase, atol=1e-15, rtol=0)
assert ds.path == tf
Expand All @@ -26,12 +26,12 @@ def test_load_field():
# generate test data
tf = tempfile.mktemp(suffix=".npy", prefix="qpformat_test_")
phase = np.ones((20, 20), dtype=float)
phase *= np.linspace(0, .3, 20).reshape(-1,1)
phase *= np.linspace(0, .3, 20).reshape(-1, 1)
amplitude = np.ones((20, 20), dtype=float)
amplitude += np.linspace(-.1, .12, 20).reshape(1,-1)
amplitude += np.linspace(-.1, .12, 20).reshape(1, -1)
field = amplitude * np.exp(1j * phase)
np.save(tf, field)

ds = qpformat.load_data(tf)
assert np.allclose(ds.get_qpimage().pha, phase, atol=1e-15, rtol=0)
assert np.allclose(ds.get_qpimage().amp, amplitude, atol=1e-15, rtol=0)
Expand Down

0 comments on commit 916bb0e

Please sign in to comment.