Skip to content

Commit

Permalink
Fix typing
Browse files Browse the repository at this point in the history
Signed-off-by: Beat Buesser <[email protected]>
  • Loading branch information
beat-buesser committed Jan 20, 2025
1 parent 3378220 commit d7e9f2b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import logging
import math
from packaging.version import parse
from typing import Any, TYPE_CHECKING
from typing import Any, cast, TYPE_CHECKING

import numpy as np
from tqdm.auto import trange
Expand Down Expand Up @@ -513,13 +513,15 @@ def generate( # type: ignore

if hasattr(self.estimator, "nb_classes"):

y_array: np.ndarray

if y is None: # pragma: no cover
logger.info("Setting labels to estimator classification predictions.")
y_array: np.ndarray = to_categorical(
y_array = to_categorical(
np.argmax(self.estimator.predict(x=x), axis=1), nb_classes=self.estimator.nb_classes
)
else:
y_array: np.ndarray = y
y_array = cast(np.ndarray, y)

Check warning on line 524 in art/attacks/evasion/adversarial_patch/adversarial_patch_pytorch.py

View check run for this annotation

Codecov / codecov/patch

art/attacks/evasion/adversarial_patch/adversarial_patch_pytorch.py#L524

Added line #L524 was not covered by tests

y = check_and_transform_label_format(labels=y_array, nb_classes=self.estimator.nb_classes)

Check warning on line 526 in art/attacks/evasion/adversarial_patch/adversarial_patch_pytorch.py

View check run for this annotation

Codecov / codecov/patch

art/attacks/evasion/adversarial_patch/adversarial_patch_pytorch.py#L526

Added line #L526 was not covered by tests

Expand Down

0 comments on commit d7e9f2b

Please sign in to comment.