Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type error suppressions for upcoming upgrade #1429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion captum/_utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ def _select_targets(output: Tensor, target: TargetType) -> Tensor:
raise AssertionError(f"Target type {type(target)} is not valid.")


# pyre-fixme[24]: Generic type `slice` expects 3 type parameters.
def _contains_slice(target: Union[int, Tuple[Union[int, slice], ...]]) -> bool:
if isinstance(target, tuple):
for index in target:
Expand All @@ -690,7 +691,10 @@ def _contains_slice(target: Union[int, Tuple[Union[int, slice], ...]]) -> bool:


def _verify_select_column(
output: Tensor, target: Union[int, Tuple[Union[int, slice], ...]]
# pyre-fixme[24]: Generic type `slice` expects 3 type parameters.
output: Tensor,
# pyre-fixme[24]: Generic type `slice` expects 3 type parameters.
target: Union[int, Tuple[Union[int, slice], ...]],
) -> Tensor:
target = (target,) if isinstance(target, int) else target
assert (
Expand Down
2 changes: 2 additions & 0 deletions captum/metrics/_core/infidelity.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ def _generate_perturbations(
repeated instances per example.
"""

# pyre-fixme[53]: Captured variable `baselines_expanded` is not annotated.
# pyre-fixme[53]: Captured variable `inputs_expanded` is not annotated.
def call_perturb_func() -> (
Tuple[TensorOrTupleOfTensorsGeneric, TensorOrTupleOfTensorsGeneric]
):
Expand Down
2 changes: 2 additions & 0 deletions captum/metrics/_core/sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def max_values(input_tnsr: Tensor) -> Tensor:
# pyre-fixme[33]: Given annotation cannot be `Any`.
kwargs_copy: Any = None

# pyre-fixme[53]: Captured variable `bsz` is not annotated.
# pyre-fixme[53]: Captured variable `expl_inputs` is not annotated.
def _next_sensitivity_max(current_n_perturb_samples: int) -> Tensor:
inputs_perturbed = _generate_perturbations(current_n_perturb_samples)

Expand Down