Skip to content

Commit 17f752e

Browse files
committed
merge: sync with upstream main and resolve experiment.py conflict
2 parents 863e52c + 2a45423 commit 17f752e

21 files changed

Lines changed: 1671 additions & 858 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: 1278 additions & 0 deletions
Large diffs are not rendered by default.

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)"

examples/sensorium/sensorium_min_example.ipynb

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"import numpy as np\n",
3333
"from tqdm import tqdm\n",
3434
"import matplotlib.pyplot as plt\n",
35-
"from torch.utils.data import DataLoader\n",
3635
"from collections import OrderedDict"
3736
]
3837
},
@@ -429,80 +428,78 @@
429428
},
430429
{
431430
"cell_type": "code",
432-
"execution_count": 25,
431+
"execution_count": null,
433432
"id": "70c2c2fa",
434433
"metadata": {},
435434
"outputs": [],
436435
"source": [
437436
"seed = 42\n",
438-
"import sys\n",
437+
"import sys # noqa: E402\n",
439438
"\n",
440439
"sys.path.append(\"/srv/user/turishcheva/sensorium_replicate/sensorium_2023/\")\n",
441440
"sys.path.append(\"/srv/user/turishcheva/sensorium_replicate/neuralpredictors/\")\n",
442-
"import torch\n",
443-
"from nnfabrik.utility.nn_helpers import set_random_seed\n",
441+
"import torch # noqa: E402\n",
442+
"from nnfabrik.utility.nn_helpers import set_random_seed # noqa: E402\n",
444443
"\n",
445444
"set_random_seed(seed)\n",
446445
"\n",
447-
"from sensorium.datasets.mouse_video_loaders import mouse_video_loader\n",
448-
"from sensorium.utility.scores import get_correlations\n",
449-
"from nnfabrik.builder import get_trainer\n",
450-
"from sensorium.models.make_model import make_video_model"
446+
"from nnfabrik.builder import get_trainer # noqa: E402\n",
447+
"from sensorium.models.make_model import make_video_model # noqa: E402"
451448
]
452449
},
453450
{
454451
"cell_type": "code",
455-
"execution_count": 26,
452+
"execution_count": null,
456453
"id": "78705901",
457454
"metadata": {},
458455
"outputs": [],
459456
"source": [
460-
"factorised_3D_core_dict = dict(\n",
461-
" input_channels=1, # increase if behaviour is used\n",
462-
" hidden_channels=[32, 64, 128],\n",
463-
" spatial_input_kernel=(11, 11),\n",
464-
" temporal_input_kernel=11,\n",
465-
" spatial_hidden_kernel=(5, 5),\n",
466-
" temporal_hidden_kernel=5,\n",
467-
" stride=1,\n",
468-
" layers=3,\n",
469-
" gamma_input_spatial=10,\n",
470-
" gamma_input_temporal=0.01,\n",
471-
" bias=True,\n",
472-
" hidden_nonlinearities=\"elu\",\n",
473-
" x_shift=0,\n",
474-
" y_shift=0,\n",
475-
" batch_norm=True,\n",
476-
" laplace_padding=None,\n",
477-
" input_regularizer=\"LaplaceL2norm\",\n",
478-
" padding=False,\n",
479-
" final_nonlin=True,\n",
480-
" momentum=0.7,\n",
481-
")\n",
457+
"factorised_3D_core_dict = {\n",
458+
" \"input_channels\": 1, # increase if behaviour is used\n",
459+
" \"hidden_channels\": [32, 64, 128],\n",
460+
" \"spatial_input_kernel\": (11, 11),\n",
461+
" \"temporal_input_kernel\": 11,\n",
462+
" \"spatial_hidden_kernel\": (5, 5),\n",
463+
" \"temporal_hidden_kernel\": 5,\n",
464+
" \"stride\": 1,\n",
465+
" \"layers\": 3,\n",
466+
" \"gamma_input_spatial\": 10,\n",
467+
" \"gamma_input_temporal\": 0.01,\n",
468+
" \"bias\": True,\n",
469+
" \"hidden_nonlinearities\": \"elu\",\n",
470+
" \"x_shift\": 0,\n",
471+
" \"y_shift\": 0,\n",
472+
" \"batch_norm\": True,\n",
473+
" \"laplace_padding\": None,\n",
474+
" \"input_regularizer\": \"LaplaceL2norm\",\n",
475+
" \"padding\": False,\n",
476+
" \"final_nonlin\": True,\n",
477+
" \"momentum\": 0.7,\n",
478+
"}\n",
482479
"\n",
483480
"\n",
484481
"shifter_dict = None\n",
485482
"\n",
486483
"\n",
487-
"readout_dict = dict(\n",
488-
" bias=True,\n",
489-
" init_mu_range=0.2,\n",
490-
" init_sigma=1.0,\n",
491-
" gamma_readout=0.0,\n",
492-
" gauss_type=\"full\",\n",
493-
" # grid_mean_predictor=None,\n",
494-
" grid_mean_predictor={\n",
484+
"readout_dict = {\n",
485+
" \"bias\": True,\n",
486+
" \"init_mu_range\": 0.2,\n",
487+
" \"init_sigma\": 1.0,\n",
488+
" \"gamma_readout\": 0.0,\n",
489+
" \"gauss_type\": \"full\",\n",
490+
" # grid_mean_predictor=None,\n",
491+
" \"grid_mean_predictor\": {\n",
495492
" \"type\": \"cortex\",\n",
496493
" \"input_dimensions\": 2,\n",
497494
" \"hidden_layers\": 1,\n",
498495
" \"hidden_features\": 30,\n",
499496
" \"final_tanh\": True,\n",
500497
" },\n",
501-
" share_features=False,\n",
502-
" share_grid=False,\n",
503-
" shared_match_ids=None,\n",
504-
" gamma_grid_dispersion=0.0,\n",
505-
")"
498+
" \"share_features\": False,\n",
499+
" \"share_grid\": False,\n",
500+
" \"shared_match_ids\": None,\n",
501+
" \"gamma_grid_dispersion\": 0.0,\n",
502+
"}"
506503
]
507504
},
508505
{
@@ -744,7 +741,6 @@
744741
"source": [
745742
"import yaml\n",
746743
"import os\n",
747-
"from tqdm import tqdm\n",
748744
"from collections import Counter"
749745
]
750746
},
@@ -763,6 +759,8 @@
763759
"metadata": {},
764760
"outputs": [],
765761
"source": [
762+
"import pickle\n",
763+
"\n",
766764
"path_to_old = ...\n",
767765
"path_to_new = ...\n",
768766
"path_to_save_matching = ...\n",
@@ -782,7 +780,7 @@
782780
" )\n",
783781
"\n",
784782
" for file in tqdm(os.listdir(yaml_pre_path)):\n",
785-
" with open(f\"{yaml_pre_path}{file}\", \"r\") as f:\n",
783+
" with open(f\"{yaml_pre_path}{file}\") as f:\n",
786784
" data = yaml.safe_load(f)\n",
787785
" if data[\"modality\"] != \"blank\":\n",
788786
" if len(np.where(trial_idx_prev == data[\"trial_idx\"])[0]) == 0:\n",
@@ -817,6 +815,8 @@
817815
"metadata": {},
818816
"outputs": [],
819817
"source": [
818+
"import pickle\n",
819+
"\n",
820820
"for m in [\n",
821821
" \"dynamic29623-4-9-Video-full\",\n",
822822
" \"dynamic29647-19-8-Video-full\",\n",
@@ -845,7 +845,7 @@
845845
" trial_idx_prev = np.asarray(trial_idx_prev)\n",
846846
"\n",
847847
" for file in tqdm(os.listdir(yaml_pre_path)):\n",
848-
" with open(f\"{yaml_pre_path}{file}\", \"r\") as f:\n",
848+
" with open(f\"{yaml_pre_path}{file}\") as f:\n",
849849
" data = yaml.safe_load(f)\n",
850850
" if data[\"modality\"] != \"blank\":\n",
851851
" if len(np.where(trial_idx_prev == data[\"trial_idx\"])[0]) == 0:\n",

0 commit comments

Comments
 (0)