Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the __correct_for_negatives function to work properly. It used … #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fabcamo
Copy link
Collaborator

@fabcamo fabcamo commented Feb 26, 2025

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.

if data.size != 0 and not data.ndim:
     data[data < 0] = 0

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. ❌

…"and not data.ndim" which is incorrect. Tests have the same 3 errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant