Skip to content

Commit 600154a

Browse files
committed
linting
1 parent 814008f commit 600154a

File tree

22 files changed

+85
-124
lines changed

22 files changed

+85
-124
lines changed

.github/workflows/full-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
# stop the build if there are Python syntax errors or undefined names
7171
flake8 pyNN --count --select=E9,F63,F7,F82 --show-source --statistics
7272
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
73-
flake8 pyNN --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
73+
flake8 pyNN --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics
7474
- name: Run unit and system tests
7575
run: |
7676
pytest -v --cov=pyNN --cov-report=term test

pyNN/arbor/cells.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _build_decor(self, i):
101101
decor.set_ion(ion_name,
102102
int_con=ionic_species.internal_concentration,
103103
ext_con=ionic_species.external_concentration,
104-
rev_pot=ionic_species.reversal_potential) #method="nernst/na")
104+
rev_pot=ionic_species.reversal_potential) # method="nernst/na")
105105
for native_name, region_params in mechanism_parameters.items():
106106
for region, params in region_params.items():
107107
if native_name == "hh":
@@ -124,14 +124,15 @@ def _build_decor(self, i):
124124
for current_source in self.current_sources[i]:
125125
location_generator = current_source["location_generator"]
126126
mechanism = getattr(arbor, current_source["model_name"])
127-
for locset, label in location_generator.generate_locations(morph, label=f"{current_source['model_name']}_label"):
128-
#decor.place(locset, mechanism(start, stop - start, current=amplitude), "iclamp_label")
127+
for locset, label in location_generator.generate_locations(morph, label=f"{current_source['model_name']}_label"):
129128
decor.place(locset, mechanism(**current_source["parameters"].evaluate()), label)
130129

131130
# add spike source
132-
decor.place('"root"', arbor.threshold_detector(-10), "detector") # todo: allow user to choose location and threshold value
131+
decor.place('"root"', arbor.threshold_detector(-10), "detector")
132+
# todo: allow user to choose location and threshold value
133133

134-
policy = arbor.cv_policy_max_extent(10.0) # to do: allow user to specify this value and/or the policy more generally
134+
policy = arbor.cv_policy_max_extent(10.0)
135+
# to do: allow user to specify this value and/or the policy more generally
135136
decor.discretization(policy)
136137

137138
return decor

pyNN/arbor/morphology.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from .. import morphology as base_morphology
77

88

9-
109
# --- MorphologyFilters ---
1110

1211
class with_label(base_morphology.with_label):
@@ -48,7 +47,6 @@ def get_region(self):
4847
raise NotImplementedError
4948

5049

51-
5250
# --- IonChannelDistributions ---
5351

5452

@@ -68,11 +66,13 @@ def resolve(self):
6866
value = self.value_provider.get_value()
6967
return region, value
7068

69+
7170
class by_distance(base_morphology.by_distance, HasSelector):
7271

7372
def resolve(self):
7473
raise NotImplementedError
7574

75+
7676
class by_diameter(base_morphology.by_diameter, HasSelector):
7777

7878
def resolve(self):

pyNN/arbor/projections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def arbor_connections(self, gid):
9191
cg.weight,
9292
cg.delay
9393
)
94-
)
94+
)
9595
else:
9696
raise NotImplementedError()
9797
return connections

pyNN/arbor/recording.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ def _localize_variables(self, variables, locations):
4848
location_generator = item
4949
else:
5050
raise ValueError("'locations' should be a str, list, LocationGenerator or None")
51-
morphology = self.population.celltype.parameter_space["morphology"].base_value # todo: handle inhomogeneous morphologies in a Population
51+
morphology = self.population.celltype.parameter_space["morphology"].base_value
52+
# todo: handle inhomogeneous morphologies in a Population
5253
for locset, label in location_generator.generate_locations(morphology, label="recording-point"):
53-
short_label = label[len("recording-point-"):] # not sure we need the 'recording-point' in the first place
54+
short_label = label[len("recording-point-"):]
55+
# not sure we need the 'recording-point' in the first place
5456
for var_name in variables:
5557
resolved_variables.append(recording.Variable(location=locset, name=var_name, label=short_label))
5658
return resolved_variables

pyNN/arbor/simulator.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,12 @@ def build_mechanisms():
3535
return mech_path
3636

3737

38-
class Cell(int): # (, common.IDMixin):
38+
class Cell(int):
3939

4040
def __init__(self, n):
4141
"""Create an ID object with numerical value `n`."""
42-
#int.__init__(n)
43-
#common.IDMixin.__init__(self)
4442
self.gid = n
45-
#self.morph = None #morph
46-
#self.decor = None # decor
47-
#self.labels = None # labels
4843
self.local = True
49-
#self.decor.place('"root"', arbor.threshold_detector(-10), f"detector-{self.gid}")
50-
51-
# def __lt__(self, other):
52-
# return self.gid < other.gid
53-
54-
# def __lte__(self, other):
55-
# return self.gid <= other.gid
56-
57-
# def __gt__(self, other):
58-
# return self.gid > other.gid
59-
60-
# def __gte__(self, other):
61-
# return self.gid >= other.gid
62-
63-
# def __eq__(self, other):
64-
# return self.gid == other.gid
65-
66-
# def __ne__(self, other):
67-
# return self.gid != other.gid
6844

6945

7046
class NetworkRecipe(arbor.recipe):
@@ -206,7 +182,8 @@ def run(self, simtime):
206182
hints = {}
207183
decomp = arbor.partition_load_balance(recipe, self.arbor_context, hints)
208184
self.arbor_sim = arbor.simulation(recipe, self.arbor_context, decomp, self.rng_seed)
209-
self.arbor_sim.record(arbor.spike_recording.all) # todo: for now record all, but should be controlled by population.record()
185+
self.arbor_sim.record(arbor.spike_recording.all)
186+
# todo: for now record all, but should be controlled by population.record()
210187
for recorder in self.recorders:
211188
recorder._set_arbor_sim(self.arbor_sim)
212189
self.t += simtime

pyNN/arbor/standardmodels.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ def get_schema(self):
244244
"cl": IonicSpecies
245245
}
246246
}
247-
#for name, ion_channel in self.ion_channels.items():
248-
# schema[name] = ion_channel.get_schema()
249247
return schema
250248

251249
def translate(self, parameters, copy=True):
@@ -254,7 +252,6 @@ def translate(self, parameters, copy=True):
254252
_parameters = deepcopy(parameters)
255253
else:
256254
_parameters = parameters
257-
cls = self.__class__
258255
if parameters.schema != self.get_schema():
259256
# should replace this with a PyNN-specific exception type
260257
raise Exception(f"Schemas do not match: {parameters.schema} != {self.get_schema()}")

pyNN/brian2/recording.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ def _create_device(self, group, variable):
3939
varname = translations[variable.name]['translated_name']
4040
neurons_to_record = np.sort(np.fromiter(
4141
self.recorded[variable], dtype=int)) - self.population.first_id
42-
self._devices[variable.name] = brian2.StateMonitor(group, varname,
43-
record=neurons_to_record,
44-
when='end',
45-
dt=self.sampling_interval * ms)
42+
self._devices[variable.name] = brian2.StateMonitor(
43+
group, varname,
44+
record=neurons_to_record,
45+
when='end',
46+
dt=self.sampling_interval * ms)
4647
simulator.state.network.add(self._devices[variable.name])
4748

4849
def _record(self, variable, new_ids, sampling_interval=None):

pyNN/connectors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def _standard_connect(self, projection, connection_map_generator, distance_map=N
195195
_proceed = False
196196
if source_mask is True or source_mask.any():
197197
_proceed = True
198-
elif type(source_mask) == np.ndarray:
198+
elif isinstance(source_mask, np.ndarray):
199199
if source_mask.dtype == bool:
200200
if source_mask.any():
201201
_proceed = True

pyNN/morphology.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919

2020

2121
def _download_file(url):
22-
import requests # consider rewriting using just standard library
23-
# to avoid adding another dependency
22+
import requests
23+
# consider rewriting using just standard library
24+
# to avoid adding another dependency
2425
local_filename = url.split('/')[-1]
2526
r = requests.get(url, stream=True)
2627
with open(local_filename, 'wb') as f:
@@ -61,7 +62,6 @@ def soma_index(self):
6162
return self._soma_index
6263

6364

64-
6565
class NeuroMLMorphology(Morphology):
6666
"""
6767
@@ -100,7 +100,8 @@ def labels(self):
100100

101101
@property
102102
def soma_index(self):
103-
return self.labels().get("soma", 0) # todo: more robust way to handle morphologies without a declared soma, e.g. single dendrites
103+
return self.labels().get("soma", 0)
104+
# todo: more robust way to handle morphologies without a declared soma, e.g. single dendrites
104105

105106
@property
106107
def path_lengths(self):
@@ -185,7 +186,6 @@ class SynapseDistribution(NeuriteDistribution):
185186
pass
186187

187188

188-
189189
class uniform(IonChannelDistribution, SynapseDistribution):
190190
# we inherit from two parents, because we want to use the name "uniform" for both
191191
# the implementation behaves differently depending on context
@@ -219,12 +219,10 @@ def value_in(self, morphology, index):
219219
return self.absence
220220

221221

222-
223222
class MorphologyFilter(object):
224223
pass
225224

226225

227-
228226
class dendrites(MorphologyFilter):
229227

230228
def __init__(self, fraction_along=None):
@@ -274,7 +272,6 @@ def __init__(self, *labels):
274272
self.labels = labels
275273

276274

277-
278275
class LocationGenerator:
279276

280277
def lazily_evaluate(self, mask=None, shape=None):

0 commit comments

Comments
 (0)