Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ml_metrics/_src/aggregates/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,12 @@ def _apply_vocab_at_k(
k_list = set(k_list) # pyrefly: ignore[bad-assignment]
for j in range(max(k_list)):
if multioutput:
for i, row in enumerate(rows): # pyrefly: ignore[bad-argument-type, not-iterable]
for i, row in enumerate(rows): # pyrefly: ignore[not-iterable]
if j < len(row): # pyrefly: ignore[bad-argument-type]
result[i][vocab[row[j]]] = True # pyrefly: ignore[bad-index]
else:
if j == 0:
for i, elem in enumerate(rows): # pyrefly: ignore[bad-argument-type, not-iterable]
for i, elem in enumerate(rows): # pyrefly: ignore[not-iterable]
result[i][vocab[elem]] = True # pyrefly: ignore[bad-index]
if j + 1 in k_list:
yield j + 1, result
Expand Down
4 changes: 2 additions & 2 deletions ml_metrics/_src/aggregates/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def new(
) -> Histogram:
new_histogram, new_bin_edges = np.histogram( # pyrefly: ignore[no-matching-overload]
inputs,
bins=self.bins, # pyrefly: ignore[bad-argument-type]
bins=self.bins,
range=self.range,
weights=weights,
)
Expand Down Expand Up @@ -428,7 +428,7 @@ def new(self, batch: types.NumbersT) -> types.NumbersT:
batch = np.asarray(
self.batch_score_fn(batch) if self.batch_score_fn else batch
)
return self.__class__( # pytype: disable=wrong-keyword-args
return self.__class__(
_count=np.sum(~np.isnan(batch), axis=0),
_mean=np.nanmean(batch, axis=0),
_var=np.nanvar(batch, axis=0),
Expand Down
2 changes: 1 addition & 1 deletion ml_metrics/_src/signals/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def content_metadata(image_bytes: bytes) -> dict[str, int | float | str]:

img = Image.open(io.BytesIO(image_bytes))
width, height = img.size
return { # pytype: disable=bad-return-type # pillow-102-upgrade
return {
'mode': img.mode,
'format': img.format,
'pixel_width': width,
Expand Down
6 changes: 3 additions & 3 deletions ml_metrics/_src/utils/proto_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ def dict_to_tf_example(data: dict[str, Any]) -> example_pb2.Example:
assert isinstance(v, str), f'bad str type: {value}'
feature[key].bytes_list.value.append(v.encode())
elif isinstance(value[0], bytes):
feature[key].bytes_list.value.extend(value) # pyrefly: ignore[bad-argument-type]
feature[key].bytes_list.value.extend(value)
elif isinstance(value[0], (int, np.integer)):
feature[key].int64_list.value.extend(value) # pyrefly: ignore[bad-argument-type]
feature[key].int64_list.value.extend(value)
elif isinstance(value[0], (float, np.floating)):
feature[key].float_list.value.extend(value) # pyrefly: ignore[bad-argument-type]
feature[key].float_list.value.extend(value)
else:
raise TypeError(f'Value for "{key}" is not a supported type.')
return example
Loading