Skip to content

Commit 33d2b75

Browse files
amyreesefacebook-github-bot
authored andcommitted
apply import merging for fbcode (8 of 11)
Summary: Applies new import merging and sorting from µsort v1.0. When merging imports, µsort will make a best-effort to move associated comments to match merged elements, but there are known limitations due to the diynamic nature of Python and developer tooling. These changes should not produce any dangerous runtime changes, but may require touch-ups to satisfy linters and other tooling. Note that µsort uses case-insensitive, lexicographical sorting, which results in a different ordering compared to isort. This provides a more consistent sorting order, matching the case-insensitive order used when sorting import statements by module name, and ensures that "frog", "FROG", and "Frog" always sort next to each other. For details on µsort's sorting and merging semantics, see the user guide: https://usort.readthedocs.io/en/stable/guide.html#sorting Reviewed By: lisroach Differential Revision: D36402214 fbshipit-source-id: b641bfa9d46242188524d4ae2c44998922a62b4c
1 parent f3d3e1d commit 33d2b75

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

captum/influence/_core/tracincp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
Callable,
1010
Iterator,
1111
List,
12+
NamedTuple,
1213
Optional,
13-
Union,
1414
Tuple,
15-
NamedTuple,
1615
Type,
16+
Union,
1717
)
1818

1919
import torch

captum/influence/_core/tracincp_fast_rand_proj.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
#!/usr/bin/env python3
22

33
import warnings
4-
from typing import Any, Callable, Iterator, List, Optional, Union, Tuple
4+
from typing import Any, Callable, Iterator, List, Optional, Tuple, Union
55

66
import torch
7-
from captum._utils.common import _get_module_from_name, _format_inputs
7+
from captum._utils.common import _format_inputs, _get_module_from_name
88
from captum._utils.progress import progress
99
from captum.influence._core.tracincp import (
10-
TracInCPBase,
11-
KMostInfluentialResults,
1210
_influence_route_to_helpers,
11+
KMostInfluentialResults,
12+
TracInCPBase,
1313
)
1414
from captum.influence._utils.common import (
15+
_DatasetFromList,
16+
_get_k_most_influential_helper,
1517
_jacobian_loss_wrt_inputs,
1618
_load_flexible_state_dict,
1719
_tensor_batch_dot,
18-
_get_k_most_influential_helper,
19-
_DatasetFromList,
2020
)
2121
from captum.influence._utils.nearest_neighbors import (
22-
NearestNeighbors,
2322
AnnoyNearestNeighbors,
23+
NearestNeighbors,
2424
)
2525
from captum.log import log_usage
2626
from torch import Tensor

captum/influence/_utils/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
from typing import Callable, Optional, Tuple, Union, Any, List
3+
from typing import Any, Callable, List, Optional, Tuple, Union
44

55
import torch
66
import torch.nn as nn

tests/influence/_core/test_tracin_show_progress.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66

77
import torch.nn as nn
88
from captum.influence._core.tracincp import TracInCP
9-
from captum.influence._core.tracincp_fast_rand_proj import (
10-
TracInCPFast,
11-
)
9+
from captum.influence._core.tracincp_fast_rand_proj import TracInCPFast
1210
from parameterized import parameterized
1311
from tests.helpers.basic import BaseTest
1412
from tests.influence._utils.common import (
15-
get_random_model_and_data,
16-
DataInfluenceConstructor,
1713
build_test_name_func,
14+
DataInfluenceConstructor,
15+
get_random_model_and_data,
1816
)
1917

2018

0 commit comments

Comments
 (0)