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

Small coding style improvements #659

Conversation

kevindlewis23
Copy link
Collaborator

@kevindlewis23 kevindlewis23 commented Jul 1, 2024

No functional changes made here, mainly just removing unnecessary pass statements and putting underscores to mark unused variables. There are a couple bugfixes as well

@pep8speaks
Copy link

pep8speaks commented Jul 1, 2024

Hello @kevindlewis23! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-07-02 18:28:29 UTC

@@ -77,7 +75,6 @@ def quad_fit_obj(x, a, b, c):

def quad_fit_jac(x, a, b, c):
x = np.asarray(x)
return a*x**2 + b*x + c
return np.vstack([x**2, x, np.ones_like(x)]).T
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actual functionality change here, I assume the previous one was a bug

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is quad_fit_jac meant to do? If the removed return statement was incorrect, then does that mean the function doesn't need a, b, or c as arguments?

hexrd/config/utils.py Show resolved Hide resolved
hexrd/findorientations.py Show resolved Hide resolved
@@ -58,15 +56,15 @@ def cnst_fit_obj(x, b):
return np.ones_like(x)*b


def cnst_fit_jac(x, b):
def cnst_fit_jac(x, _b):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function doesn't use _b. I'm not sure that changing the variable name is the right choice - if we're going to change this, we should consider fixing the signature to not have a second argument at all. Though, it may affect downstream user workflows unexpectedly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe these functions are used by the optimizer, and this is the interface the optimizer uses

return np.vstack([np.ones_like(x)]).T


def lin_fit_obj(x, m, b):
return m*np.asarray(x) + b


def lin_fit_jac(x, m, b):
def lin_fit_jac(x, _m, _b):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as prior - if _m and _b aren't being used by the function, we shouldn't have them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as above

@@ -77,7 +75,6 @@ def quad_fit_obj(x, a, b, c):

def quad_fit_jac(x, a, b, c):
x = np.asarray(x)
return a*x**2 + b*x + c
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure this is the incorrect return? The return that's staying doesn't seem to include a, b, or c.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure, but it is actually a matrix which seems to make more sense. Doesn't affect the test cases which is unfortunate, so I couldn't tell.

hexrd/nf_config/experiment.py Outdated Show resolved Hide resolved
hexrd/nf_config/experiment.py Outdated Show resolved Hide resolved
hexrd/projections/polar.py Outdated Show resolved Hide resolved
hexrd/projections/spherical.py Outdated Show resolved Hide resolved
hexrd/sampleOrientations/conversions.py Outdated Show resolved Hide resolved
@donald-e-boyce
Copy link
Collaborator

donald-e-boyce commented Jul 1, 2024 via email

@kevindlewis23
Copy link
Collaborator Author

Null change was reverted

@ZackAttack614
Copy link
Collaborator

I would like to consider removing the class. It seems its only use is as a substitute for None. I'm not convinced that it's useful.

@kevindlewis23
Copy link
Collaborator Author

I did try to replace it with None but the test cases threw errors because the comparisons ended up not working. I couldn't figure out why immediately, but I can try to fix it if you think it's worth it

Copy link
Collaborator Author

@kevindlewis23 kevindlewis23 left a comment

Choose a reason for hiding this comment

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

Accidental review, just supposed to be comments

hexrd/config/utils.py Show resolved Hide resolved
@@ -77,7 +75,6 @@ def quad_fit_obj(x, a, b, c):

def quad_fit_jac(x, a, b, c):
x = np.asarray(x)
return a*x**2 + b*x + c
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure, but it is actually a matrix which seems to make more sense. Doesn't affect the test cases which is unfortunate, so I couldn't tell.

hexrd/sampleOrientations/conversions.py Outdated Show resolved Hide resolved
@donald-e-boyce
Copy link
Collaborator

I would like to consider removing the class. It seems its only use is as a substitute for None. I'm not convinced that it's useful.

It's such a minor change, I don't think it's worth the effort. I think the choice to not use None was intentional.

@psavery
Copy link
Collaborator

psavery commented Jul 2, 2024

Be sure to squash these commits, or cherry-pick the relevant ones.

@@ -77,7 +75,6 @@ def quad_fit_obj(x, a, b, c):

def quad_fit_jac(x, a, b, c):
x = np.asarray(x)
return a*x**2 + b*x + c
return np.vstack([x**2, x, np.ones_like(x)]).T
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is quad_fit_jac meant to do? If the removed return statement was incorrect, then does that mean the function doesn't need a, b, or c as arguments?

@kevindlewis23
Copy link
Collaborator Author

I don't feel like resolving these merge conflicts

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.

5 participants