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

bindsnet/conversion/topology.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, Tuple
1+
from typing import Iterable, Optional, Tuple, Union
22

33
import torch
44
import torch.nn.functional as F

bindsnet/datasets/__init__.py

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
from .torchvision_wrapper import create_torchvision_dataset_wrapper
2-
from .spoken_mnist import SpokenMNIST
3-
from .davis import Davis
4-
from .alov300 import ALOV300
5-
6-
from .collate import time_aware_collate
7-
from .dataloader import DataLoader
8-
1+
from bindsnet.datasets.alov300 import ALOV300
2+
from bindsnet.datasets.collate import time_aware_collate
3+
from bindsnet.datasets.dataloader import DataLoader
4+
from bindsnet.datasets.davis import Davis
5+
from bindsnet.datasets.spoken_mnist import SpokenMNIST
6+
from bindsnet.datasets.torchvision_wrapper import create_torchvision_dataset_wrapper
97

108
CIFAR10 = create_torchvision_dataset_wrapper("CIFAR10")
119
CIFAR100 = create_torchvision_dataset_wrapper("CIFAR100")
@@ -31,3 +29,44 @@
3129
SVHN = create_torchvision_dataset_wrapper("SVHN")
3230
VOCDetection = create_torchvision_dataset_wrapper("VOCDetection")
3331
VOCSegmentation = create_torchvision_dataset_wrapper("VOCSegmentation")
32+
33+
34+
__all__ = [
35+
"torchvision_wrapper",
36+
"create_torchvision_dataset_wrapper",
37+
"spoken_mnist",
38+
"SpokenMNIST",
39+
"davis",
40+
"Davis",
41+
"preprocess",
42+
"alov300",
43+
"ALOV300",
44+
"collate",
45+
"time_aware_collate",
46+
"dataloader",
47+
"DataLoader",
48+
"CIFAR10",
49+
"CIFAR100",
50+
"Cityscapes",
51+
"CocoCaptions",
52+
"CocoDetection",
53+
"DatasetFolder",
54+
"EMNIST",
55+
"FakeData",
56+
"FashionMNIST",
57+
"Flickr30k",
58+
"Flickr8k",
59+
"ImageFolder",
60+
"KMNIST",
61+
"LSUN",
62+
"LSUNClass",
63+
"MNIST",
64+
"Omniglot",
65+
"PhotoTour",
66+
"SBU",
67+
"SEMEION",
68+
"STL10",
69+
"SVHN",
70+
"VOCDetection",
71+
"VOCSegmentation",
72+
]

bindsnet/datasets/alov300.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
import os
22
import sys
33
import time
4-
import zipfile
54
import warnings
6-
from glob import glob
5+
import zipfile
76
from urllib.request import urlretrieve
8-
from typing import Optional, Tuple, List, Iterable
97

108
import cv2
11-
import torch
129
import numpy as np
13-
from PIL import Image
1410
from torch.utils.data import Dataset
1511

1612
from bindsnet.datasets.preprocess import (
17-
cropPadImage,
1813
BoundingBox,
19-
crop_sample,
2014
Rescale,
2115
bgr2rgb,
16+
crop_sample,
17+
cropPadImage,
2218
)
2319

2420
warnings.filterwarnings("ignore")

bindsnet/datasets/collate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
Modifications exist to have [time, batch, n_0, ... n_k] instead of batch in dimension 0.
88
"""
99

10-
import torch
11-
from torch._six import string_classes
1210
import collections
1311

12+
import torch
13+
from torch._six import string_classes
1414
from torch.utils.data._utils import collate as pytorch_collate
1515

1616

bindsnet/datasets/dataloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import torch
22

3-
from .collate import time_aware_collate
3+
from bindsnet.datasets.collate import time_aware_collate
44

55

66
class DataLoader(torch.utils.data.DataLoader):

bindsnet/datasets/davis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import os
2+
import shutil
23
import sys
34
import time
4-
import shutil
55
import zipfile
6-
from glob import glob
76
from collections import defaultdict
7+
from glob import glob
88
from urllib.request import urlretrieve
99

10-
import torch
1110
import numpy as np
11+
import torch
1212
from PIL import Image
1313
from tqdm import tqdm
1414

bindsnet/datasets/preprocess.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import math
22
import random
3-
import warnings
43

54
import cv2
6-
import torch
75
import numpy as np
6+
import torch
87
from torchvision import transforms
98

109

0 commit comments

Comments
 (0)