Skip to content

Commit af0bd28

Browse files
committed
small fixes and comment
1 parent 51d25c3 commit af0bd28

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/stratify/_vinterp.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def interpolate(z_target, z_src, fz_src, axis=-1, rising=None,
520520
# Dask array
521521
import dask.array as da
522522

523-
# Ensure z_target is an array that runs in the same direction as z_src otherwise flip z_src and fz_src.
523+
# Ensure z_target is an array.
524524
if not isinstance(z_target, (np.ndarray, da.Array)):
525525
z_target = np.array(z_target)
526526

@@ -622,6 +622,10 @@ cdef class _Interpolation(object):
622622
emsg = 'Shape for z_src {} is not a subset of fz_src {}.'
623623
raise ValueError(emsg.format(z_src.shape, fz_src.shape))
624624

625+
# If rising is not provided, work it out from the first two values of z_src.
626+
# Then do the same thing for the target, and if the target is rising in the
627+
# opposite direction to the source, then we flip the source and the source data
628+
# on the interpolation axis.
625629
if rising is None:
626630
if z_src.shape[zp_axis] < 2:
627631
raise ValueError('The rising keyword must be defined when '

src/stratify/tests/test_vinterp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_no_levels(self):
113113
assert_array_equal(r, [])
114114

115115
def test_wrong_rising_target(self):
116-
r = self.interpolate([1, 2], [2, 1])
116+
r = self.interpolate([2, 1], [1, 2])
117117
assert_array_equal(r, [0.0, 1.0])
118118

119119
def test_wrong_rising_source(self):

0 commit comments

Comments
 (0)