Skip to content

Commit e7246e5

Browse files
galenlynchclaude
andcommitted
GH #2744 Fix installation and tests for Python 3.10-3.13
Three pinned dependencies blocked installation on 3.12+: - numpy<1.24: no cp312 wheels; now uncapped (numpy 2.x supported) - pandas==1.5.3: no cp312 wheels; now >=1.5.3 - scipy<1.11: requires_python<3.12; now uncapped - pynwb<3: cap to avoid breaking API changes - xarray<2023.2.0: unpinned (pure Python, no breakage) - pytz: added (was transitive via pandas 1.x, now needed explicitly) - setuptools<81: cap (pkg_resources removed in 81+) Source fixes for removed/changed APIs: - scipy.interpolate.interp2d → RectBivariateSpline (removed in 1.14) - ConfigParser.readfp → read_string (removed in Python 3.12) - DataFrame.iteritems() → items() (removed in pandas 2.0) - np.int() → int() (removed in numpy 1.24) - np.NaN/np.NAN → np.nan (removed in numpy 2.0) - np.Inf → np.inf, np.string_ → np.bytes_ (removed in numpy 2.0) - np.product → np.prod, np.in1d → np.isin (removed in numpy 2.0) - np.ediff1d to_begin dtype must match array dtype in numpy 2.0 - np.VisibleDeprecationWarning → try/except import (removed in 2.0) - nwbfile.modules → .processing (pynwb 2.x deprecation) - IndexSeries unit='None' → 'N/A' (pynwb 2.5+ validation) - np.linalg.norm([array, scalar]) → np.vstack (numpy 1.24+ rejects) - aiohttp.ClientSession → lazy property (aiohttp 3.9+ event loop) - groupby().apply() → select column first (pandas 2.2+ behavior) - demixer: add np.isfinite guard after linalg.solve (some LAPACK implementations return inf instead of raising LinAlgError for singular matrices) Test fixes: - pytest.warns(None) → warnings.catch_warnings (pytest 8) - mock.called_once_with → assert_called_once() (proper assertion) - Add res.x to MagicMock for scipy.optimize result - rng.choice(inhomogeneous) → rng.integers + index (numpy 1.24+) - Widen curve-fit tolerances for platform variance - Cast dtypes for pynwb 2.x roundtrip and pandas 2.x index changes - subprocess 'python' → sys.executable for venv correctness - Replace flaky test_demix_raises_warning_for_singular_matrix with a result-based assertion in test_demix_point - from mock import → from unittest.mock import (69 test files) - Uncap/modernize test dependency bounds, remove dead weight CI: - Update to actions/checkout@v4, actions/setup-python@v5 - Slim matrix to min/max Python (3.10, 3.13) on ubuntu, 3.13 on macOS/windows - Add pip caching, coverage on single matrix element only - Modernize notebook_runner.yml to Python 3.13 - Update nightly.yml to checkout@v4 Fixes #2747, #2744, #2746, #2754 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a9b5c68 commit e7246e5

131 files changed

Lines changed: 277 additions & 272 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.

.github/workflows/github-actions-ci.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
name: Lint
2727
runs-on: "ubuntu-latest"
2828
steps:
29-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v4
3030
- name: flake8 linting
3131
run: |
3232
pip install flake8
@@ -43,28 +43,30 @@ jobs:
4343
runs-on: ${{ matrix.os }}
4444
strategy:
4545
matrix:
46-
os: ["macos-latest", "windows-latest", "ubuntu-latest"]
47-
python-version: ["3.8", "3.9", "3.10", "3.11"]
46+
os: ["ubuntu-latest"]
47+
python-version: ["3.10", "3.13"]
48+
include:
49+
- os: "macos-latest"
50+
python-version: "3.13"
51+
- os: "windows-latest"
52+
python-version: "3.13"
4853
fail-fast: false
49-
defaults:
50-
run:
51-
shell: bash -l {0}
5254
steps:
53-
- uses: actions/checkout@v2
54-
- uses: conda-incubator/setup-miniconda@v2
55+
- uses: actions/checkout@v4
56+
- uses: actions/setup-python@v5
5557
with:
56-
auto-update-conda: true
5758
python-version: ${{ matrix.python-version }}
58-
activate-environment: test-env
59+
cache: pip
60+
cache-dependency-path: |
61+
requirements.txt
62+
test_requirements.txt
5963
- name: Install
6064
run: |
61-
conda activate test-env
62-
pip install codecov
6365
pip install -r test_requirements.txt
6466
pip install .
6567
- name: Test
6668
run: |
67-
py.test --cov=allensdk -n 4
69+
python -m pytest -n 4 ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13') && '--cov=allensdk' || '' }}
6870
6971
onprem:
7072
name: python ${{ matrix.image }} on-prem test
@@ -73,7 +75,7 @@ jobs:
7375
matrix:
7476
image: ["allensdk_local_py38:latest"]
7577
steps:
76-
- uses: actions/checkout@v2
78+
- uses: actions/checkout@v4
7779
- name: run test in docker
7880
run: |
7981
docker run \

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
image: ["allensdk_local_py38:latest"]
1414
branch: ["master", "rc/**"]
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717
with:
1818
ref: ${{ matrix.branch }}
1919
- name: run test in docker

.github/workflows/notebook_runner.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ jobs:
99
strategy:
1010
matrix:
1111
os: ["ubuntu-latest"]
12-
python-version: ["3.8"]
12+
python-version: ["3.13"]
1313
fail-fast: false
1414
runs-on: ${{ matrix.os }}
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- name: Set up Python
18-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: ${{ matrix.python-version }}
21+
cache: pip
22+
cache-dependency-path: |
23+
requirements.txt
24+
dev_requirements.txt
25+
notebook_requirements.txt
2126
- name: Install
2227
run: |
2328
pip install -r requirements.txt

allensdk/brain_observatory/behavior/data_objects/cell_specimens/cell_specimens.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,13 @@ def _validate_traces(
857857
if traces is None:
858858
continue
859859
# validate traces contain expected roi ids
860-
if not np.in1d(traces.value.index, cell_roi_ids).all():
860+
if not np.isin(traces.value.index, cell_roi_ids).all():
861861
raise RuntimeError(
862862
f"{traces.name} contains ROI IDs that "
863863
f"are not in "
864864
f"cell_specimen_table.cell_roi_id"
865865
)
866-
if not np.in1d(cell_roi_ids, traces.value.index).all():
866+
if not np.isin(cell_roi_ids, traces.value.index).all():
867867
raise RuntimeError(
868868
f"cell_specimen_table contains ROI IDs "
869869
f"that are not in {traces.name}"

allensdk/brain_observatory/behavior/data_objects/metadata/behavior_metadata/behavior_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def get_task_parameters(data: Dict) -> Dict:
149149
# displayed stimuli (no flashes).
150150

151151
if stim_duration is None:
152-
stim_duration = np.NaN
152+
stim_duration = np.nan
153153
else:
154154
stim_duration = stim_duration[0]
155155

allensdk/brain_observatory/behavior/data_objects/running_speed/running_acquisition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def from_nwb(
129129
cls,
130130
nwbfile: NWBFile
131131
) -> "RunningAcquisition":
132-
running_module = nwbfile.modules['running']
132+
running_module = nwbfile.processing['running']
133133
dx_interface = running_module.get_data_interface('dx')
134134

135135
dx = dx_interface.data

allensdk/brain_observatory/behavior/data_objects/running_speed/running_speed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def from_nwb(
188188
nwbfile: NWBFile,
189189
filtered=True
190190
) -> "RunningSpeed":
191-
running_module = nwbfile.modules['running']
191+
running_module = nwbfile.processing['running']
192192
interface_name = 'speed' if filtered else 'speed_unfiltered'
193193
running_interface = running_module.get_data_interface(interface_name)
194194

allensdk/brain_observatory/behavior/data_objects/stimuli/templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def _add_image_index_to_nwb(
208208
image_index = IndexSeries(
209209
name=nwb_template.name,
210210
data=stimulus_index['image_index'].values,
211-
unit='None',
211+
unit='N/A',
212212
indexed_timeseries=nwb_template,
213213
timestamps=stimulus_index['start_time'].values)
214214
nwbfile.add_stimulus(image_index)

allensdk/brain_observatory/behavior/data_objects/task_parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def _parse_stimulus_key():
223223
# displayed stimuli (no flashes).
224224

225225
if stim_duration is None:
226-
stim_duration = np.NaN
226+
stim_duration = np.nan
227227
else:
228228
stim_duration = stim_duration[0]
229229
return stim_duration

allensdk/brain_observatory/behavior/data_objects/trials/trial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def add_change_time(self, trial_dict: dict) -> Tuple[dict, float]:
415415
"""
416416
change_frame = trial_dict['change_frame']
417417
if np.isnan(change_frame):
418-
change_time = np.NaN
418+
change_time = np.nan
419419
else:
420420
change_frame = int(change_frame)
421421
change_time = self._stimulus_timestamps.value[change_frame]

0 commit comments

Comments
 (0)