Fixes a bug when the source and target run in opposite directions#407
Open
HGWright wants to merge 3 commits intoSciTools:mainfrom
Open
Fixes a bug when the source and target run in opposite directions#407HGWright wants to merge 3 commits intoSciTools:mainfrom
HGWright wants to merge 3 commits intoSciTools:mainfrom
Conversation
HGWright
commented
Feb 18, 2026
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]) |
Contributor
Author
There was a problem hiding this comment.
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.]
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 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 = Nonewe use the first 2 points of the source to determinerising, we then also use the same method for the target. Comparingrising(for the source) totgt_risingif they do not match, we flip the source and source data on the axis of interpolation.