Skip to content

Commit 6fba140

Browse files
committed
applied isort; converted all relative imports to absolute
1 parent 66342c7 commit 6fba140

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+469
-382
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
repos:
22
- repo: local
33
hooks:
4+
- id: isort
5+
name: isort
6+
entry: isort . --settings-file pyproject.toml
7+
language: system
8+
pass_filenames: false
49
- id: black
510
name: black
611
entry: black .
712
language: system
813
pass_filenames: false
14+
- id: autoflake
15+
name: autoflake
16+
entry: autoflake
17+
language: system
18+
types: [ python ]
19+
args: [ --in-place, --remove-all-unused-imports, --remove-duplicate-keys ]
20+
files: ^bindsnet/|test/

bindsnet/__init__.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
from pathlib import Path
22

3-
from . import (
4-
utils,
5-
network,
6-
models,
3+
from bindsnet import (
74
analysis,
8-
preprocessing,
5+
conversion,
96
datasets,
107
encoding,
11-
pipeline,
12-
learning,
13-
evaluation,
148
environment,
15-
conversion,
9+
evaluation,
10+
learning,
11+
models,
12+
network,
13+
pipeline,
14+
preprocessing,
15+
utils,
1616
)
1717

1818
ROOT_DIR = Path(__file__).parents[0].parents[0]
19+
20+
21+
__all__ = [
22+
"utils",
23+
"network",
24+
"models",
25+
"analysis",
26+
"preprocessing",
27+
"datasets",
28+
"encoding",
29+
"pipeline",
30+
"learning",
31+
"evaluation",
32+
"environment",
33+
"conversion",
34+
"ROOT_DIR",
35+
]

bindsnet/analysis/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
from . import plotting, visualization, pipeline_analysis
1+
from bindsnet.analysis import pipeline_analysis, plotting, visualization
2+
3+
__all__ = ["plotting", "visualization", "pipeline_analysis"]

bindsnet/analysis/dotTrace_plotter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import numpy as np
21
import glob
32
import sys
43

54
import matplotlib.pyplot as plt
5+
import numpy as np
66

77
# Define grid dimensions globally
88
ROWS = 28

bindsnet/analysis/pipeline_analysis.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from tensorboardX import SummaryWriter
99
from torchvision.utils import make_grid
1010

11-
from .plotting import plot_spikes, plot_voltages, plot_conv2d_weights
1211
from ..utils import reshape_conv2d_weights
12+
from .plotting import plot_conv2d_weights, plot_spikes, plot_voltages
1313

1414

1515
class PipelineAnalyzer(ABC):
@@ -25,7 +25,6 @@ def finalize_step(self) -> None:
2525
"""
2626
Flush the output from the current step.
2727
"""
28-
pass
2928

3029
@abstractmethod
3130
def plot_obs(self, obs: torch.Tensor, tag: str = "obs", step: int = None) -> None:
@@ -38,7 +37,6 @@ def plot_obs(self, obs: torch.Tensor, tag: str = "obs", step: int = None) -> Non
3837
:param tag: A unique tag to associate the data with.
3938
:param step: The step of the pipeline.
4039
"""
41-
pass
4240

4341
@abstractmethod
4442
def plot_reward(
@@ -57,7 +55,6 @@ def plot_reward(
5755
:param tag: A unique tag to associate the data with.
5856
:param step: The step of the pipeline.
5957
"""
60-
pass
6158

6259
@abstractmethod
6360
def plot_spikes(
@@ -75,7 +72,6 @@ def plot_spikes(
7572
:param tag: A unique tag to associate the data with.
7673
:param step: The step of the pipeline.
7774
"""
78-
pass
7975

8076
@abstractmethod
8177
def plot_voltages(
@@ -96,7 +92,6 @@ def plot_voltages(
9692
:param tag: A unique tag to associate the data with.
9793
:param step: The step of the pipeline.
9894
"""
99-
pass
10095

10196
@abstractmethod
10297
def plot_conv2d_weights(
@@ -110,7 +105,6 @@ def plot_conv2d_weights(
110105
:param tag: A unique tag to associate the data with.
111106
:param step: The step of the pipeline.
112107
"""
113-
pass
114108

115109

116110
class MatplotlibAnalyzer(PipelineAnalyzer):
@@ -313,7 +307,6 @@ def finalize_step(self) -> None:
313307
"""
314308
No-op for ``TensorboardAnalyzer``.
315309
"""
316-
pass
317310

318311
def plot_obs(self, obs: torch.Tensor, tag: str = "obs", step: int = None) -> None:
319312
# language=rst

bindsnet/analysis/plotting.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import torch
2-
import numpy as np
3-
import matplotlib.pyplot as plt
1+
from typing import Dict, List, Optional, Sized, Tuple, Union
42

3+
import matplotlib.pyplot as plt
4+
import numpy as np
5+
import torch
56
from matplotlib.axes import Axes
6-
from matplotlib.image import AxesImage
7-
from torch.nn.modules.utils import _pair
87
from matplotlib.collections import PathCollection
8+
from matplotlib.image import AxesImage
99
from mpl_toolkits.axes_grid1 import make_axes_locatable
10-
from typing import Tuple, List, Optional, Sized, Dict, Union
10+
from torch.nn.modules.utils import _pair
1111

12-
from ..utils import reshape_locally_connected_weights, reshape_conv2d_weights
12+
from bindsnet.utils import reshape_conv2d_weights, reshape_locally_connected_weights
1313

1414
plt.ion()
1515

bindsnet/analysis/visualization.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import torch
2-
import numpy as np
3-
import matplotlib.pyplot as plt
4-
import matplotlib.animation as animation
1+
from typing import List, Optional, Tuple
52

6-
from typing import List, Tuple, Optional
3+
import matplotlib.animation as animation
4+
import matplotlib.pyplot as plt
5+
import numpy as np
6+
import torch
77

88

99
def plot_weights_movie(ws: np.ndarray, sample_every: int = 1) -> None:

bindsnet/conversion/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
from .conversion import (
2-
Permute,
1+
from bindsnet.conversion.conversion import (
2+
ConstantPad2dConnection,
33
FeatureExtractor,
4-
SubtractiveResetIFNodes,
54
PassThroughNodes,
5+
Permute,
66
PermuteConnection,
7-
ConstantPad2dConnection,
8-
data_based_normalization,
7+
SubtractiveResetIFNodes,
98
ann_to_snn,
9+
data_based_normalization,
1010
)
11+
12+
__all__ = [
13+
"Permute",
14+
"FeatureExtractor",
15+
"SubtractiveResetIFNodes",
16+
"PassThroughNodes",
17+
"PermuteConnection",
18+
"ConstantPad2dConnection",
19+
"data_based_normalization",
20+
"ann_to_snn",
21+
]

bindsnet/conversion/conversion.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import torch
1+
from copy import deepcopy
2+
from typing import Dict, Optional, Sequence, Union
3+
24
import numpy as np
5+
import torch
36
import torch.nn as nn
4-
import torch.nn.functional as F
5-
67
from torch.nn.modules.utils import _pair
78

8-
from copy import deepcopy
9-
from typing import Union, Sequence, Optional, Tuple, Dict, Iterable
10-
119
import bindsnet.network.nodes as nodes
1210
import bindsnet.network.topology as topology
13-
11+
from bindsnet.conversion.nodes import PassThroughNodes, SubtractiveResetIFNodes
12+
from bindsnet.conversion.topology import ConstantPad2dConnection, PermuteConnection
1413
from bindsnet.network import Network
15-
from .nodes import SubtractiveResetIFNodes, PassThroughNodes
16-
from .topology import PermuteConnection, ConstantPad2dConnection
1714

1815

1916
class Permute(nn.Module):

bindsnet/conversion/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Iterable, Union
1+
from typing import Iterable, Optional, Union
22

33
import torch
44

0 commit comments

Comments
 (0)