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

Adjust import statements to match convention #43

Merged
merged 9 commits into from
Jan 12, 2025

Conversation

arniw2
Copy link
Contributor

@arniw2 arniw2 commented Jan 6, 2025

Summary

Adjusted all numpy import statements to match and create continuous scheme.

PR checklist

  • I have written tests that fail without my changes. Or I did not add them on purpose.
  • I have included instructions on how to test this, assuming they are not already apparent from the linked issue.

Closes/Fixes/Related to

Copy link
Contributor

@Madddiiiin Madddiiiin left a comment

Choose a reason for hiding this comment

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

Good job overall! I only marked two spots where you missed the np. prefix, both times before the 'sum' function. We gotta be careful with this specifically, since there is a function called 'sum' in standard python, so removing the import for 'sum' from numpy does not lead to a syntax error.

@@ -24,12 +21,12 @@ def calculate_tau_final(
if len(tau_i_values) == 0:
return -1, -1

weights: ndarray = 1 / power(delta_tau_i_values, 2)
weights: np.ndarray = 1 / np.power(delta_tau_i_values, 2)

# Calculate the weighted mean of tau_i
weighted_mean: float = sum(weights * tau_i_values) / sum(weights)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
weighted_mean: float = sum(weights * tau_i_values) / sum(weights)
weighted_mean: float = np.sum(weights * tau_i_values) / np.sum(weights)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Its concerning, that the tests didn't catch that, could you have a look at why this wasn't tested?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's what I thought as well. Turns out I forgot to verify the mocked functions in tau_final are called correctly. I now added the tests for this.

napytau/core/tau_final.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@Benedikt-Brunner Benedikt-Brunner left a comment

Choose a reason for hiding this comment

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

One tiny thing, which applies to 2 files i think

from numpy import sum
from numpy import mean
from numpy import power
import numpy as np
from scipy import optimize
from scipy.optimize import OptimizeResult
Copy link
Collaborator

Choose a reason for hiding this comment

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

this does not match the import convention

Copy link
Collaborator

@Benedikt-Brunner Benedikt-Brunner left a comment

Choose a reason for hiding this comment

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

image

@Benedikt-Brunner Benedikt-Brunner merged commit ff87607 into main Jan 12, 2025
3 checks passed
@Benedikt-Brunner Benedikt-Brunner deleted the core/tasks/refactor-import-statements branch January 12, 2025 08:54
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.

Adjust import statements to match convention
3 participants