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

Bugfix for _replace_units #2110

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

Conversation

samwaseda
Copy link

@samwaseda samwaseda commented Jan 4, 2025

Closes #2111

I encountered the following bug:

This one works:

def f(C, x, P):
    return np.linalg.norm(P) / np.linalg.norm(C) / x**2

f(np.random.randn(2, 3, 4), np.random.randn(5, 6), np.random.randn(7, 8))

This one doesn't:

@ureg.wraps("=P/C/x**2", ("=C", "=x", "=P"))
def f(C, x, P):
    return np.linalg.norm(P) / np.linalg.norm(C) / x**2

f(np.random.randn(2, 3, 4) * ureg.gigapascal, np.random.randn(5, 6) * ureg.meter, np.random.randn(7, 8) * ureg.joule)

The fix I'm proposing here would solve the problem.

  • Closes # (insert issue number)
  • Executed pre-commit run --all-files with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
  • Added an entry to the CHANGES file

Copy link

codspeed-hq bot commented Jan 4, 2025

CodSpeed Performance Report

Merging #2110 will not alter performance

Comparing samwaseda:patch-1 (73a51f0) with master (74b7086)

Summary

✅ 437 untouched benchmarks

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.

Bug with ureg.wraps when different numpy shapes are used
1 participant