Skip to content

Conversation

@em1208
Copy link
Contributor

@em1208 em1208 commented Mar 4, 2024

  • 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

I fixed a bug related to unit conversion when using context. Without the single line change in pint/facets/context/registry.py calling compatible_units fails with KeyError: <UnitsContainer({'[mass]': 1, '[time]': -1})>.

I hope this change can be merged and released soon!

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 4, 2024

CodSpeed Performance Report

Merging #1944 will degrade performances by 27.45%

Comparing em1208:enrico/bug-context (6d25704) with master (8f12bb9)

Summary

❌ 9 regressions
✅ 428 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark master em1208:enrico/bug-context Change
test_parse_units[False-angstrom] 50.7 µs 66.7 µs -24.02%
test_parse_units[False-meter] 52.2 µs 68.6 µs -23.87%
test_parse_units[False-minute] 51.4 µs 67.8 µs -24.14%
test_parse_units[False-second] 50.7 µs 66.7 µs -24.02%
test_parse_units[True-angstrom] 51.6 µs 64.7 µs -20.26%
test_to_units_container_detached[False-angstrom] 45.2 µs 62 µs -27.1%
test_to_units_container_detached[False-meter] 45.4 µs 62.2 µs -27.03%
test_to_units_container_registry[False-angstrom] 45.1 µs 61.6 µs -26.75%
test_to_units_container_registry[False-meter] 45.2 µs 62.3 µs -27.45%

@hgrecco
Copy link
Owner

hgrecco commented Mar 13, 2024

If I understand correctly, the problem is that after adding definitions, the cache is not rebuilt. Right? I think I have a better solution. I will try to put it in another PR

@em1208
Copy link
Contributor Author

em1208 commented Mar 15, 2024

@hgrecco Yes, the problem is that when the context is enabled the cache should be rebuilt otherwise currently an exception is raised.

@hgrecco
Copy link
Owner

hgrecco commented Mar 17, 2024

@em1208 This is the proposal #1779

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.

2 participants