Skip to content

Commit

Permalink
adding image tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Alan Weaver committed Nov 12, 2015
1 parent 00e3cf6 commit a0a60f9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
44 changes: 44 additions & 0 deletions pydl/pydlutils/tests/test_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
import numpy as np
from ..image import djs_maskinterp1


class TestImage(object):
"""Test the functions in pydl.pydlutils.image.
"""

def setup(self):
pass

def teardown(self):
pass

def test_djs_maskinterp1(self):
y = np.array([0.0, 1.0, 2.0, 3.0, 4.0], dtype=np.float64)
# Test all good
yi = djs_maskinterp1(y, np.zeros(y.shape, dtype=np.int32))
assert (yi == y).all()
# Test all bad
yi = djs_maskinterp1(y, np.ones(y.shape, dtype=np.int32))
assert (yi == y).all()
# Test one good value
yt = np.zeros(y.shape, dtype=y.dtype) + y[0]
yi = djs_maskinterp1(y, np.arange(len(y)))
assert (yi == yt).all()
# Test two bad values
yi = djs_maskinterp1(y, np.array([0, 1, 0, 1, 0]))
assert np.allclose(y, yi)
# Because of the default behavior of np.interp(), the 'const'
# keyword has no actual effect, because it performs the
# same operation.
yt = y.copy()
yt[4] = 3.0
yi = djs_maskinterp1(y, np.array([0, 1, 0, 0, 1]))
assert np.allclose(yt, yi)
yi = djs_maskinterp1(y, np.array([0, 1, 0, 0, 1]), const=True)
assert np.allclose(yt, yi)
yt = y.copy()
yt[0] = 1.0
yi = djs_maskinterp1(y, np.array([1, 0, 1, 0, 0]), const=True)
assert np.allclose(yt, yi)
4 changes: 2 additions & 2 deletions pydl/pydlutils/tests/test_yanny.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def json2dtype(self, data):
return np.dtype(stuff)


class TestWriteNdarray(YannyTestCase):
"""Test class for ndarray to yanny conversions.
class TestYanny(YannyTestCase):
"""Test class for yanny files.
"""
save_temp = False

Expand Down

0 comments on commit a0a60f9

Please sign in to comment.