Commit 3271b3a
committed
Improve handling of zero division in mod_c and intdiv_c
* In python, when computing x % 0, we get ZeroDivisionError("division by zero"). mod_c should thus probably behave the same when t2 is the zero vector.
* Change ValueError to ZeroDivisionError in intdiv_c
* Make mod_c reuse intdiv_c. This makes it raise ZeroDivisionError when called with t2=0.1 parent 322717a commit 3271b3a
File tree
2 files changed
+10
-11
lines changed- src/torchjd/sparse
- tests/unit/sparse
2 files changed
+10
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 45 | + | |
51 | 46 | | |
52 | 47 | | |
53 | 48 | | |
| |||
63 | 58 | | |
64 | 59 | | |
65 | 60 | | |
66 | | - | |
67 | 61 | | |
68 | 62 | | |
| 63 | + | |
69 | 64 | | |
70 | 65 | | |
71 | 66 | | |
72 | 67 | | |
73 | | - | |
| 68 | + | |
74 | 69 | | |
75 | 70 | | |
76 | 71 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
433 | 432 | | |
434 | 433 | | |
435 | 434 | | |
| |||
442 | 441 | | |
443 | 442 | | |
444 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
445 | 449 | | |
446 | 450 | | |
447 | 451 | | |
| |||
461 | 465 | | |
462 | 466 | | |
463 | 467 | | |
464 | | - | |
| 468 | + | |
465 | 469 | | |
0 commit comments