Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
827d9fc
fix: resolve ruff linting issues and add CI workflow
binary69 Mar 15, 2026
ebca0d2
style: auto-format with black and isort
invalid-email-address Mar 15, 2026
38ad1aa
ci: pin ruff to v0.15.6 and avoid duplicate CI runs
binary69 Mar 15, 2026
0bd7793
ci: exclude examples folder from ruff check
binary69 Mar 16, 2026
819f870
removed unwanted addition, made the workflow to be consistent with ot…
binary69 Mar 17, 2026
6f17377
style: auto-format with black and isort
invalid-email-address Mar 17, 2026
f03639f
removed blank line
binary69 Mar 17, 2026
73b326f
chore: remove blank line in datasets
binary69 Mar 17, 2026
ae78a7a
style: auto-format with black and isort
invalid-email-address Mar 17, 2026
80225e7
config: add ruff to dev deps, configure pyproject.toml, update ruff.yml
binary69 Mar 18, 2026
da7d491
fix: resolve ruff linting issues in examples
binary69 Mar 18, 2026
804db95
fix: apply ruff auto-fixes to experanto source files
binary69 Mar 18, 2026
0ed7a9d
Merge remote-tracking branch 'upstream/main' into fix/ruff-clean
binary69 Mar 18, 2026
8d362d8
fix: resolve ruff linting issues in dandi example notebook
binary69 Mar 18, 2026
ab631d2
fix: remove omegaconf from autodoc mock imports to fix docs build
binary69 Mar 18, 2026
d0b180c
fix: resolve remaining ruff linting issues in experanto and tests
binary69 Mar 19, 2026
ebe6f1c
style: auto-format with black and isort
invalid-email-address Mar 19, 2026
a03055d
fix: convert dict() calls to literals in tests, remove C408 per-file-…
binary69 Mar 19, 2026
0478a67
remove outdated sensorium example notebooks
binary69 Mar 19, 2026
dc57be5
Update experanto/dataloaders.py
binary69 Mar 19, 2026
4ab079b
Update experanto/dataloaders.py
binary69 Mar 19, 2026
deae36d
Update experanto/datasets.py
binary69 Mar 19, 2026
9e20681
Update experanto/interpolators.py
binary69 Mar 19, 2026
2e07f4e
Update experanto/utils.py
binary69 Mar 19, 2026
1620add
Update experanto/utils.py
binary69 Mar 19, 2026
ad46d7e
Update experanto/utils.py
binary69 Mar 19, 2026
3016ee3
Update experanto/utils.py
binary69 Mar 19, 2026
b942fbe
update experanto/utils.py
binary69 Mar 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Ruff

on: [push, pull_request]

jobs:
ruff:
Comment thread
binary69 marked this conversation as resolved.
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true)
Comment thread
binary69 marked this conversation as resolved.
Outdated
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
with:
version: "0.15.6"
args: "check --exclude examples/"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,4 @@ cython_debug/
*.bak

docs/source/generated/
gsoc_env/
Comment thread
reneburghardt marked this conversation as resolved.
Outdated
4 changes: 1 addition & 3 deletions examples/sensorium/data.ipynb
Comment thread
binary69 marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import torch"
"import matplotlib.pyplot as plt"
]
},
{
Expand Down
5 changes: 1 addition & 4 deletions examples/sensorium/experiment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.animation as animation\n",
"from pathlib import Path\n",
"from IPython.display import HTML"
]
},
Expand All @@ -33,9 +32,7 @@
"if p not in sys.path:\n",
" sys.path.append(p)\n",
"\n",
"from experanto.experiment import Experiment\n",
"from experanto.interpolators import Interpolator\n",
"from experanto.interpolators import ScreenInterpolator"
"from experanto.experiment import Experiment"
]
},
{
Expand Down
4 changes: 0 additions & 4 deletions examples/sensorium/sensorium_min_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"import numpy as np\n",
"from tqdm import tqdm\n",
"import matplotlib.pyplot as plt\n",
"from torch.utils.data import DataLoader\n",
"from collections import OrderedDict"
]
},
Expand Down Expand Up @@ -444,8 +443,6 @@
"\n",
"set_random_seed(seed)\n",
"\n",
"from sensorium.datasets.mouse_video_loaders import mouse_video_loader\n",
"from sensorium.utility.scores import get_correlations\n",
"from nnfabrik.builder import get_trainer\n",
"from sensorium.models.make_model import make_video_model"
]
Expand Down Expand Up @@ -744,7 +741,6 @@
"source": [
"import yaml\n",
"import os\n",
"from tqdm import tqdm\n",
"from collections import Counter"
]
},
Expand Down
3 changes: 1 addition & 2 deletions experanto/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

from pathlib import Path

from hydra import compose, initialize, initialize_config_dir
from omegaconf import OmegaConf, open_dict
from omegaconf import OmegaConf

# get config relative to this file
script_dir = Path(__file__).parent
Expand Down
8 changes: 1 addition & 7 deletions experanto/dataloaders.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import logging
import os
import time
import warnings
from pathlib import Path
from typing import Any, Dict, List, Optional, Type, Union
from typing import Dict, List, Optional, Union

import numpy as np
from omegaconf import DictConfig
from torch.utils.data import DataLoader

from .datasets import ChunkDataset
from .utils import (
Expand Down Expand Up @@ -158,7 +153,6 @@ def get_multisession_concat_dataloader(
datasets = []
session_names = []

start_time = time.time()
for i, (path, cfg) in enumerate(zip(paths, configs)):
# Create dataset with deterministic seed
path_hash = hash(path) % 10000
Expand Down
11 changes: 3 additions & 8 deletions experanto/datasets.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
from __future__ import annotations

import functools
import importlib
import json
import logging
import os
from collections.abc import Iterable
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Optional

import numpy as np
import torch
import torchvision
from hydra.utils import instantiate
from omegaconf import DictConfig, ListConfig, OmegaConf
from omegaconf import DictConfig, ListConfig
from torch.utils.data import Dataset
from torchvision.transforms import v2
from torchvision.transforms.v2 import Compose, Lambda, ToTensor

from .configs import DEFAULT_MODALITY_CONFIG
from .experiment import Experiment
from .interpolators import ImageTrial, VideoTrial
from .intervals import (
TimeInterval,
find_intersection_between_two_interval_arrays,
get_stats_for_valid_interval,
)
from .utils import add_behavior_as_channels, replace_nan_with_batch_mean
from .utils import add_behavior_as_channels

# see .configs.py for the definition of DEFAULT_MODALITY_CONFIG
Comment thread
reneburghardt marked this conversation as resolved.
Outdated
DEFAULT_MODALITY_CONFIG = dict()

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -768,7 +764,6 @@ def __getitem__(self, idx: int) -> dict:
for device_name in self.device_names:
sampling_rate = self.sampling_rates[device_name]
chunk_size = self.chunk_sizes[device_name]
chunk_s = chunk_size / sampling_rate

# convert everything to int to avoid numerical issues
start_time = int(round(s * self.scale_precision))
Expand Down
4 changes: 1 addition & 3 deletions experanto/experiment.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from __future__ import annotations

import logging
import re
import warnings
from collections.abc import Sequence
from pathlib import Path
from typing import Optional, Union
from typing import Union

import numpy as np
from hydra.utils import instantiate
Expand Down
5 changes: 2 additions & 3 deletions experanto/interpolators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import cv2
import numpy as np
import numpy.lib.format as fmt
import yaml
from numba import njit, prange
from scipy.ndimage import gaussian_filter1d
Expand Down Expand Up @@ -326,7 +325,7 @@ def interpolate(

else:
raise NotImplementedError(
f"interpolation_mode should be linear or nearest_neighbor"
"interpolation_mode should be linear or nearest_neighbor"
)

def close(self) -> None:
Expand Down Expand Up @@ -454,7 +453,7 @@ def interpolate(

else:
raise NotImplementedError(
f"interpolation_mode should be linear or nearest_neighbor"
"interpolation_mode should be linear or nearest_neighbor"
)


Expand Down
2 changes: 1 addition & 1 deletion experanto/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def get_stats_for_valid_interval(
"""
total_duration = end_time - start_time
if total_duration <= 0:
return f"Error: Invalid time range (end_time <= start_time). Total duration must be positive."
return "Error: Invalid time range (end_time <= start_time). Total duration must be positive."

# Ensure intervals are unique and sorted, then clamp them to the analysis window
unique_intervals = uniquefy_interval_array(intervals)
Expand Down
19 changes: 3 additions & 16 deletions experanto/utils.py
Comment thread
reneburghardt marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
import bisect
import logging
import math
import multiprocessing

# inbuilt libraries
import os
import queue
import random
import threading
import time
import warnings
from collections import defaultdict
from copy import deepcopy
Comment thread
pollytur marked this conversation as resolved.
from functools import partial
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union

# third-party libraries
import numpy as np
import torch
from omegaconf import DictConfig
from torch.utils.data import ConcatDataset, DataLoader, Dataset, Sampler
from torch.utils.data import DataLoader, Dataset, Sampler

# local libraries
from .intervals import TimeInterval

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -58,7 +45,7 @@ def add_behavior_as_channels(data: dict[str, torch.Tensor]) -> dict:

# Process eye_tracker
if len(eye_tracker.shape) == 2: # (t, c_eye)
c_eye = eye_tracker.shape[1]

# Reshape to (c_eye, t, h, w)
eye_tracker = eye_tracker.transpose(0, 1) # (c_eye, t)
eye_tracker = eye_tracker.unsqueeze(-1).unsqueeze(-1) # (c_eye, t, 1, 1)
Expand All @@ -69,7 +56,7 @@ def add_behavior_as_channels(data: dict[str, torch.Tensor]) -> dict:

# Process treadmill
if len(treadmill.shape) == 2: # (t, c_tread)
c_tread = treadmill.shape[1]

# Reshape to (c_tread, t, h, w)
treadmill = treadmill.transpose(0, 1) # (c_tread, t)
treadmill = treadmill.unsqueeze(-1).unsqueeze(-1) # (c_tread, t, 1, 1)
Expand Down
Loading