fixed the __correct_for_negatives function to work properly. It used … #45
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.
The negative values were not properly replaced with zero for the friction, tip and friciton_nbr; in the __correct_for_negatives function in the pre_process steps... I checked the tests and 3 remain failing as it was before the changes....
In the original code, the condition is never True, and thus data never gets fixed.
Why the condition is never True?
data.ndim returns the number of dimensions (or axes) of a NumPy array
If data is:
A scalar (single number) → data.ndim == 0
A 1D array (like a list) → data.ndim == 1
A 2D array (like a table) → data.ndim == 2, and so on
Then, the condition:
if data.size != 0 and not data.ndim:
--> is only true if data.ndim == 0 (meaning data is a single scalar value).
What Happens?
If data is a scalar
(e.g., np.array(5)):
not data.ndim → True, so the function executes data[data < 0] = 0.
✅ Works fine.
If data is a 1D or 2D array (which it usually is in real use cases):
not data.ndim → False, because data.ndim is 1 or greater.
The condition fails, so negative values are NOT changed. ❌