Skip to content

Comments

Fixes a bug when the source and target run in opposite directions#407

Open
HGWright wants to merge 3 commits intoSciTools:mainfrom
HGWright:r_opposite_dir
Open

Fixes a bug when the source and target run in opposite directions#407
HGWright wants to merge 3 commits intoSciTools:mainfrom
HGWright:r_opposite_dir

Conversation

@HGWright
Copy link
Contributor

🚀 Pull Request

Description

Closes #50

This is a replacement PR for #343 that uses a simpler approach to achieve the same goal. In the cases that rising = None we use the first 2 points of the source to determine rising, we then also use the same method for the target. Comparing rising (for the source) to tgt_rising if they do not match, we flip the source and source data on the axis of interpolation.


Comment on lines 115 to +117
def test_wrong_rising_target(self):
r = self.interpolate([2, 1], [1, 2])
assert_array_equal(r, [1, np.inf])
assert_array_equal(r, [0.0, 1.0])
Copy link
Contributor Author

@HGWright HGWright Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know that there are extra steps taking place in this test. But it is not indicative of the simple interpolation of this data, as shown by the example below.

import numpy as np
import stratify

z_targ = np.array([2, 1])

z_source = np.array([1, 2])
data_source = z_source.copy()
out  = stratify.interpolate(z_targ, z_source, data_source)
print(out)

[2. 1.]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

stratify gives strange results if heights run in opposite directions

1 participant