Skip to content

Commit f7951c7

Browse files
galenlynchclaude
andcommitted
fix: E722, E701, F401, F507 lint errors and configure suppressions
- E722: Replace 55 bare `except:` with `except Exception:` (32 files) - E701: Split 29 single-line compound statements onto separate lines - F401: Add `__all__` to 5 `__init__.py` re-export files, noqa 2 keras availability checks - F507: Fix format string placeholder mismatch in glif_optimizer_neuron - Configure ruff and flake8 to suppress E402, E741, F403, F405 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b8adcea commit f7951c7

63 files changed

Lines changed: 188 additions & 138 deletions

File tree

Some content is hidden

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

.flake8

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
[flake8]
2-
extend-ignore = E203
2+
max-line-length = 120
3+
extend-ignore =
4+
E203,
5+
E402,
6+
E741,
7+
F403,
8+
F405,
9+
W503

allensdk/api/queries/biophysical_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def is_well_known_file_type(self, wkf, name):
237237
'''
238238
try:
239239
return wkf['well_known_file_type']['name'] == name
240-
except:
240+
except Exception:
241241
return False
242242

243243
def get_well_known_file_ids(self, neuronal_model_id):

allensdk/api/queries/cell_types_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def save_reconstruction(self, specimen_id, file_name):
361361
try:
362362
file_url = results[0]['neuron_reconstructions'][
363363
0]['well_known_files'][0]['download_link']
364-
except:
364+
except Exception:
365365
raise Exception("Specimen %d has no reconstruction" % specimen_id)
366366

367367
self.retrieve_file_over_http(self.api_url + file_url, file_name)
@@ -394,7 +394,7 @@ def save_reconstruction_markers(self, specimen_id, file_name):
394394
try:
395395
file_url = results[0]['neuron_reconstructions'][
396396
0]['well_known_files'][0]['download_link']
397-
except:
397+
except Exception:
398398
raise LookupError("Specimen %d has no marker file" % specimen_id)
399399

400400
self.retrieve_file_over_http(self.api_url + file_url, file_name)

allensdk/brain_observatory/brain_observatory_exceptions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@
3333
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3434
# POSSIBILITY OF SUCH DAMAGE.
3535
#
36-
class BrainObservatoryAnalysisException(Exception): pass
36+
class BrainObservatoryAnalysisException(Exception):
37+
pass
3738

38-
class MissingStimulusException(Exception): pass
39+
class MissingStimulusException(Exception):
40+
pass
3941

40-
class NoEyeTrackingException(Exception): pass
42+
class NoEyeTrackingException(Exception):
43+
pass
4144

4245
class EpochSeparationException(Exception):
4346

allensdk/brain_observatory/brain_observatory_plotting.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def plot_drifting_grating_traces(dg, save_dir):
5959
(blank[str(nc)].std() / len(blank[str(nc)]))
6060
blank_n = blank[str(nc)].mean() - \
6161
(blank[str(nc)].std() / len(blank[str(nc)]))
62-
except:
62+
except Exception:
6363
blank_p = blank.iloc[:, nc].apply(
6464
np.mean) + (blank.iloc[:, nc].apply(np.std) / blank.iloc[:, nc].apply(len))
6565
blank_n = blank.iloc[:, nc].apply(
@@ -76,7 +76,7 @@ def plot_drifting_grating_traces(dg, save_dir):
7676
) + (subset_response[str(nc)][:-1].std() / len(subset_response[str(nc)]))
7777
subset_response_n = subset_response[str(nc)].mean(
7878
) - (subset_response[str(nc)][:-1].std() / len(subset_response[str(nc)]))
79-
except:
79+
except Exception:
8080
subset_response_p = subset_response.iloc[:, nc].apply(
8181
np.mean) + (subset_response.iloc[:, nc].apply(np.std) / subset_response.iloc[:, nc].apply(len))
8282
subset_response_n = subset_response.iloc[:, nc].apply(
@@ -87,17 +87,17 @@ def plot_drifting_grating_traces(dg, save_dir):
8787
try:
8888
ax.fill_between(xtime, subset_response_p,
8989
subset_response_n, color='b', alpha=0.5)
90-
except:
90+
except Exception:
9191
pass
9292
try:
9393
ax.fill_between(xtime, blank_p, blank_n,
9494
color='k', alpha=0.5)
95-
except:
95+
except Exception:
9696
pass
9797
try:
9898
ax.plot(xtime, subset_response[
9999
str(nc)].mean(), color='b', lw=2)
100-
except:
100+
except Exception:
101101
pass
102102
ax.plot(xtime, subset_response[
103103
str(nc)].mean(), color='b', lw=2)
@@ -162,7 +162,7 @@ def plot_ns_traces(nsa, save_dir):
162162
try:
163163
ax.fill_between(xtime, subset_response_p,
164164
subset_response_n, color='b', alpha=0.5)
165-
except:
165+
except Exception:
166166
xtime = xtime[:-1]
167167
ax.fill_between(xtime, subset_response_p,
168168
subset_response_n, color='b', alpha=0.5)
@@ -762,7 +762,7 @@ def _plot_3sb(sg, nm1, ns, save_dir):
762762
) - (subset[str(nc)].std() / np.sqrt(len(subset[str(nc)])))
763763
try:
764764
ax13.fill_between(xtime, subset_p, subset_n, color='b', alpha=0.5)
765-
except:
765+
except Exception:
766766
xtime = xtime[:-1]
767767
ax13.fill_between(xtime, subset_p, subset_n, color='b', alpha=0.5)
768768
blank = sg.sweep_response[(sg.stim_table.orientation == 0) & (
@@ -860,7 +860,7 @@ def _plot_3sb(sg, nm1, ns, save_dir):
860860
try:
861861
ax12.fill_between(xtime, subset_response_p,
862862
subset_response_n, color='b', alpha=0.5)
863-
except:
863+
except Exception:
864864
xtime = xtime[:-1]
865865
ax12.fill_between(xtime, subset_response_p,
866866
subset_response_n, color='b', alpha=0.5)

allensdk/brain_observatory/ecephys/ecephys_project_api/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@
22
from .ecephys_project_lims_api import EcephysProjectLimsApi
33
from .ecephys_project_warehouse_api import EcephysProjectWarehouseApi
44
from .ecephys_project_fixed_api import EcephysProjectFixedApi, MissingDataError
5+
6+
__all__ = [
7+
"EcephysProjectApi",
8+
"EcephysProjectLimsApi",
9+
"EcephysProjectWarehouseApi",
10+
"EcephysProjectFixedApi",
11+
"MissingDataError",
12+
]
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
from .ecephys_session_api import EcephysSessionApi
22
from .ecephys_nwb_session_api import EcephysNwbSessionApi
3-
from .ecephys_nwb1_session_api import EcephysNwb1Api
3+
from .ecephys_nwb1_session_api import EcephysNwb1Api
4+
5+
__all__ = [
6+
"EcephysSessionApi",
7+
"EcephysNwbSessionApi",
8+
"EcephysNwb1Api",
9+
]

allensdk/brain_observatory/ecephys/stimulus_analysis/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@
44
from .flashes import Flashes
55
from .dot_motion import DotMotion
66
from .natural_movies import NaturalMovies
7-
from .receptive_field_mapping import ReceptiveFieldMapping
7+
from .receptive_field_mapping import ReceptiveFieldMapping
8+
9+
__all__ = [
10+
"StaticGratings",
11+
"NaturalScenes",
12+
"DriftingGratings",
13+
"Flashes",
14+
"DotMotion",
15+
"NaturalMovies",
16+
"ReceptiveFieldMapping",
17+
]

allensdk/brain_observatory/observatory_plots.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ def plot_representational_similarity(rs, dims=None, dim_labels=None, colors=None
196196
cbar_size="7%",
197197
cbar_pad=0.05)
198198

199-
for ax in grid: pass
199+
for ax in grid:
200+
pass
200201
else:
201202
ax = plt.gca()
202203

allensdk/brain_observatory/receptive_field_analysis/fitgaussian2D.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
from scipy import optimize
3838

3939

40-
class GaussianFitError(RuntimeError): pass
40+
class GaussianFitError(RuntimeError):
41+
pass
4142

4243

4344
def gaussian2D(height, center_x, center_y, width_x, width_y, rotation):

0 commit comments

Comments
 (0)