Skip to content

Commit 2a45423

Browse files
binary69github-actionspollytur
authored
fix: resolve ruff linting issues and add CI workflow (sensorium-competition#133)
* fix: resolve ruff (v0.15.6 ) linting issues and add CI workflow * ci: exclude examples folder from ruff check * removed unwanted addition, made the workflow to be consistent with other ,removed orphaned comment,change on class * fix: apply ruff auto-fixes to experanto source files * fix: convert dict() calls to literals in tests, remove C408 per-file-ignore * remove outdated sensorium example notebooks --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Polina Turishcheva <49938348+pollytur@users.noreply.github.com>
1 parent 1b5de8c commit 2a45423

21 files changed

Lines changed: 400 additions & 865 deletions

.github/workflows/ruff.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI - Ruff Linting
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
ruff:
13+
name: Ruff Linting
14+
runs-on: ubuntu-latest
15+
if: |
16+
github.event_name == 'push' ||
17+
(
18+
github.event_name == 'pull_request' &&
19+
github.repository != github.event.pull_request.head.repo.full_name
20+
)
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Run Ruff
26+
uses: astral-sh/ruff-action@v3
27+
with:
28+
version: "0.15.6"
29+
args: "check"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ venv/
129129
ENV/
130130
env.bak/
131131
venv.bak/
132+
*env/
132133

133134
# Spyder project settings
134135
.spyderproject
@@ -164,4 +165,4 @@ cython_debug/
164165
*.sif
165166
*.bak
166167

167-
docs/source/generated/
168+
docs/source/generated/

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"cv2",
7979
"pandas",
8080
"hydra",
81-
"omegaconf",
8281
"jaxtyping",
8382
"plotly",
8483
"optree",

examples/dandi_experanto_example.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
},
138138
{
139139
"cell_type": "code",
140-
"execution_count": 3,
140+
"execution_count": null,
141141
"metadata": {
142142
"id": "QYrgfZC2J573"
143143
},
@@ -158,7 +158,7 @@
158158
},
159159
{
160160
"cell_type": "code",
161-
"execution_count": 4,
161+
"execution_count": null,
162162
"metadata": {
163163
"id": "t8hE0WuTO10X"
164164
},
@@ -189,7 +189,7 @@
189189
" elif \"ImageSeries\" in t or \"TwoPhotonSeries\" in t:\n",
190190
" modalities[name.lower()] = \"ScreenInterpolator\"\n",
191191
"\n",
192-
" for mod_name, module in nwb.processing.items():\n",
192+
" for _mod_name, module in nwb.processing.items():\n",
193193
" for dname, dobj in module.data_interfaces.items():\n",
194194
" t = type(dobj).__name__\n",
195195
" if \"LFP\" in t:\n",
@@ -1149,7 +1149,7 @@
11491149
},
11501150
{
11511151
"cell_type": "code",
1152-
"execution_count": 27,
1152+
"execution_count": null,
11531153
"metadata": {
11541154
"colab": {
11551155
"base_uri": "https://localhost:8080/",
@@ -1180,7 +1180,7 @@
11801180
" \"50 ms — balanced (default-like)\",\n",
11811181
" \"200 ms — smooth firing rate estimate, low resolution\"]\n",
11821182
"\n",
1183-
"for ax, w, label in zip(axes, windows, labels):\n",
1183+
"for ax, w, label in zip(axes, windows, labels, strict=False):\n",
11841184
" si = SpikeInterpolator(\n",
11851185
" \"experanto_000623/spikes\",\n",
11861186
" cache_data=True,\n",
@@ -1214,7 +1214,7 @@
12141214
},
12151215
{
12161216
"cell_type": "code",
1217-
"execution_count": 28,
1217+
"execution_count": null,
12181218
"metadata": {
12191219
"colab": {
12201220
"base_uri": "https://localhost:8080/",
@@ -1247,7 +1247,7 @@
12471247
"seq_lfp = SequenceInterpolator(\"experanto_000623/lfp_macro\")\n",
12481248
"t_window = np.linspace(t_623[0], t_623[0] + 10, max(n_points)) # 10s window\n",
12491249
"\n",
1250-
"for ax, n, label in zip(axes, n_points, labels):\n",
1250+
"for ax, n, label in zip(axes, n_points, labels, strict=False):\n",
12511251
" t_query = np.linspace(t_623[0], t_623[0] + 10, n)\n",
12521252
" result = seq_lfp.interpolate(t_query)\n",
12531253
" ax.plot(t_query, result[:, 0], lw=0.8)\n",

examples/demo.ipynb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"\n",
2323
"# Standard imports\n",
2424
"import sys\n",
25-
"import os\n",
2625
"from pathlib import Path\n",
2726
"\n",
2827
"# Add project root to path if needed\n",
@@ -45,13 +44,9 @@
4544
"outputs": [],
4645
"source": [
4746
"import matplotlib.pyplot as plt\n",
48-
"from os import path\n",
4947
"\n",
50-
"from tqdm import tqdm\n",
51-
"import torch\n",
52-
"from omegaconf import OmegaConf, open_dict\n",
48+
"from omegaconf import OmegaConf\n",
5349
"\n",
54-
"from experanto.datasets import ChunkDataset\n",
5550
"from experanto.dataloaders import get_multisession_dataloader"
5651
]
5752
},
@@ -198,7 +193,7 @@
198193
},
199194
{
200195
"cell_type": "code",
201-
"execution_count": 5,
196+
"execution_count": null,
202197
"id": "3eb3e584-077f-4124-abb2-4fb8d43070c0",
203198
"metadata": {},
204199
"outputs": [
@@ -211,7 +206,7 @@
211206
}
212207
],
213208
"source": [
214-
"ls /data/test_upsampling_without_hamming_30.0Hz/dynamic29515-10-12-Video-021a75e56847d574b9acbcc06c675055_30hz"
209+
"!ls /data/test_upsampling_without_hamming_30.0Hz/dynamic29515-10-12-Video-021a75e56847d574b9acbcc06c675055_30hz"
215210
]
216211
},
217212
{
@@ -238,7 +233,6 @@
238233
}
239234
],
240235
"source": [
241-
"from experanto.dataloaders import get_multisession_dataloader\n",
242236
"\n",
243237
"paths = [\"/data/test_upsampling_without_hamming_30.0Hz/dynamic29515-10-12-Video-021a75e56847d574b9acbcc06c675055_30hz\"]\n",
244238
"train_dl = get_multisession_dataloader(paths, cfg)"
@@ -321,7 +315,7 @@
321315
"fig, axs = plt.subplots(1, 4, figsize=(10, 2))\n",
322316
"for i, ax in enumerate(axs.ravel()):\n",
323317
" ax.imshow(batch[\"screen\"][i, 0, 0]) # video frames that the mouse sees\n",
324-
" ax.axis(\"off\");"
318+
" ax.axis(\"off\")"
325319
]
326320
},
327321
{

examples/sensorium/data.ipynb

Lines changed: 0 additions & 396 deletions
This file was deleted.

examples/sensorium/experiment.ipynb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"import numpy as np\n",
1515
"import matplotlib.pyplot as plt\n",
1616
"import matplotlib.animation as animation\n",
17-
"from pathlib import Path\n",
1817
"from IPython.display import HTML"
1918
]
2019
},
@@ -33,9 +32,7 @@
3332
"if p not in sys.path:\n",
3433
" sys.path.append(p)\n",
3534
"\n",
36-
"from experanto.experiment import Experiment\n",
37-
"from experanto.interpolators import Interpolator\n",
38-
"from experanto.interpolators import ScreenInterpolator"
35+
"from experanto.experiment import Experiment # noqa: E402"
3936
]
4037
},
4138
{
@@ -93,7 +90,7 @@
9390
"metadata": {},
9491
"outputs": [],
9592
"source": [
96-
"plt.plot(data[\"running_speed\"], \"o-k\")"
93+
"plt.plot(data[\"running_speed\"], \"o-k\") # noqa: F821 - `data` is defined in prior cell"
9794
]
9895
},
9996
{
@@ -103,8 +100,8 @@
103100
"metadata": {},
104101
"outputs": [],
105102
"source": [
106-
"vid1 = e[b : b + time_steps][\"screen\"]\n",
107-
"vid2 = e[b : b + time_steps, \"screen\"]\n",
103+
"vid1 = e[b : b + time_steps][\"screen\"] # noqa: F821 - `b` is defined in prior cell\n",
104+
"vid2 = e[b : b + time_steps, \"screen\"] # noqa: F821\n",
108105
"np.sum(vid1 - vid2)"
109106
]
110107
},

examples/sensorium/images.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
" sys.path.append(p)\n",
3131
"\n",
3232
"# from experanto.experiment import ImageInterpolator\n",
33-
"from experanto.interpolators import ImageInterpolator"
33+
"from experanto.interpolators import ImageInterpolator # noqa: E402"
3434
]
3535
},
3636
{

examples/sensorium/interpolator_demo.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
"source": [
4949
"import yaml\n",
5050
"\n",
51-
"meta = dict(\n",
52-
" modality=\"time_series\",\n",
53-
" start_time=float(si.timestamps[0]),\n",
54-
" end_time=float(si.timestamps[-1]),\n",
55-
" time_delta=float((si.timestamps[-1] - si.timestamps[0]) / (len(si.timestamps) - 1)),\n",
56-
" phase_shift_per_signal=False,\n",
57-
")\n",
51+
"meta = {\n",
52+
" \"modality\": \"time_series\",\n",
53+
" \"start_time\": float(si.timestamps[0]),\n",
54+
" \"end_time\": float(si.timestamps[-1]),\n",
55+
" \"time_delta\": float((si.timestamps[-1] - si.timestamps[0]) / (len(si.timestamps) - 1)),\n",
56+
" \"phase_shift_per_signal\": False,\n",
57+
"}\n",
5858
"\n",
5959
"with open(\"/Users/fabee/Data/sinzlab-data/dataset0/eye_tracker/meta.yml\", \"w\") as f:\n",
6060
" yaml.safe_dump(meta, f)"

0 commit comments

Comments
 (0)