Skip to content

Commit

Permalink
Fix assorted unbound variables [4/n] (#1365)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1365

Fix unbound variables that flake8 is complaining about

Reviewed By: cyrjano

Differential Revision: D64261231

fbshipit-source-id: ecc85a72c8d309fe900e4f559566a7bd0ea95ef9
  • Loading branch information
csauper authored and facebook-github-bot committed Oct 30, 2024
1 parent 07470af commit 87a0a9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/attr/test_class_summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def test_classes(self) -> None:
for batch_size in [None, 1, 4]:
for sizes, classes in zip(sizes_to_test, list_of_classes):

def create_batch_labels(batch_idx):
def create_batch_labels(
batch_idx, batch_size=batch_size, classes=classes
):
if batch_size is None:
# batch_size = 1
return classes[batch_idx]
Expand Down
11 changes: 9 additions & 2 deletions tests/attr/test_input_layer_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

class InputLayerMeta(type):
def __new__(metacls, name: str, bases: Tuple, attrs: Dict):
global layer_methods_to_test_with_equiv
for (
layer_method,
equiv_method,
Expand All @@ -56,7 +57,7 @@ def __new__(metacls, name: str, bases: Tuple, attrs: Dict):
+ f"_{equiv_method.__name__}_{multi_layer}"
)
attrs[test_name] = (
lambda self: self.layer_method_with_input_layer_patches(
lambda self, layer_method=layer_method, equiv_method=equiv_method, multi_layer=multi_layer: self.layer_method_with_input_layer_patches( # noqa: E501
layer_method, equiv_method, multi_layer
)
)
Expand Down Expand Up @@ -107,8 +108,14 @@ def layer_method_with_input_layer_patches(

real_attributions = equivalent_method.attribute(*args_to_use, target=0)

if not isinstance(a1, tuple):
if isinstance(a1, list):
a1 = tuple(a1)
elif not isinstance(a1, tuple):
a1 = (a1,)

if isinstance(a2, list):
a2 = tuple(a2)
elif not isinstance(a2, tuple):
a2 = (a2,)

if not isinstance(real_attributions, tuple):
Expand Down

0 comments on commit 87a0a9e

Please sign in to comment.