Commit 74f4e01
* 🐛 fix(quantity): improve bitwise ops for dimensionful quantities (#791)
Bitwise/logical operations on dimensionful quantities previously leaked an
internal `UnitConversionError` from `ustrip`, producing the misleading
message that `'m'` and `''` were not convertible even when both operands
had the same unit.
Require bitwise operands to be dimensionless before dispatching to JAX and
raise a clear `ValueError` identifying the operation and the offending
units instead. Apply this consistently across all bitwise entry points,
including quantity/quantity, quantity/array (both operand orders), and
unary `not`. Bitwise operations on genuinely dimensionless quantities are
unchanged.
Expand the test suite to cover every dispatch path, verify the operation
name appears in the error message, and add regression coverage for the
dimensionless success cases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 9a570a3 commit 74f4e01
2 files changed
Lines changed: 100 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
46 | 67 | | |
47 | 68 | | |
48 | 69 | | |
| |||
397 | 418 | | |
398 | 419 | | |
399 | 420 | | |
| 421 | + | |
400 | 422 | | |
401 | 423 | | |
402 | 424 | | |
| |||
418 | 440 | | |
419 | 441 | | |
420 | 442 | | |
| 443 | + | |
421 | 444 | | |
422 | 445 | | |
423 | 446 | | |
| |||
438 | 461 | | |
439 | 462 | | |
440 | 463 | | |
| 464 | + | |
441 | 465 | | |
442 | 466 | | |
443 | 467 | | |
| |||
3860 | 3884 | | |
3861 | 3885 | | |
3862 | 3886 | | |
| 3887 | + | |
3863 | 3888 | | |
3864 | 3889 | | |
3865 | 3890 | | |
| |||
3885 | 3910 | | |
3886 | 3911 | | |
3887 | 3912 | | |
| 3913 | + | |
3888 | 3914 | | |
3889 | 3915 | | |
3890 | 3916 | | |
| |||
3907 | 3933 | | |
3908 | 3934 | | |
3909 | 3935 | | |
| 3936 | + | |
3910 | 3937 | | |
3911 | 3938 | | |
3912 | 3939 | | |
| |||
3927 | 3954 | | |
3928 | 3955 | | |
3929 | 3956 | | |
| 3957 | + | |
3930 | 3958 | | |
3931 | 3959 | | |
3932 | 3960 | | |
| |||
5360 | 5388 | | |
5361 | 5389 | | |
5362 | 5390 | | |
| 5391 | + | |
5363 | 5392 | | |
5364 | 5393 | | |
5365 | 5394 | | |
| |||
5382 | 5411 | | |
5383 | 5412 | | |
5384 | 5413 | | |
| 5414 | + | |
5385 | 5415 | | |
5386 | 5416 | | |
5387 | 5417 | | |
| |||
5402 | 5432 | | |
5403 | 5433 | | |
5404 | 5434 | | |
| 5435 | + | |
5405 | 5436 | | |
5406 | 5437 | | |
5407 | 5438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
0 commit comments