Commit a9b7e0a
Fix error message typo and remove redundant type casts (#3503)
Addresses code review findings and Pyrefly warnings in metrics module.
## Error Message Correction
`MeanPairwiseDistance.compute()` raised `NotComputableError` with
incorrect class name reference:
```python
# Before
raise NotComputableError("MeanAbsoluteError must have at least one example...")
# After
raise NotComputableError("MeanPairwiseDistance must have at least one example...")
```
Updated corresponding test expectation in
`test_mean_pairwise_distance.py::test_zero_sample`.
## Redundant Cast Removal
Removed unnecessary `cast()` calls in `Loss.update()` where function
signature already provides type narrowing:
```python
def update(self, output: tuple[Tensor, Tensor] | tuple[Tensor, Tensor, dict]) -> None:
if len(output) == 2:
y_pred, y = output # cast() removed - type already constrained
else:
y_pred, y, kwargs = output # cast() removed - type already constrained
```
Removed unused `cast` import from `typing`.
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: vfdev-5 <2459423+vfdev-5@users.noreply.github.com>1 parent ae54b27 commit a9b7e0a
3 files changed
Lines changed: 8 additions & 8 deletions
File tree
- ignite/metrics
- tests/ignite/metrics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
0 commit comments