Skip to content

Commit

Permalink
Merge pull request #129 from luigibonati/fix_macOS_CI
Browse files Browse the repository at this point in the history
Fix issues in CI
  • Loading branch information
EnricoTrizio authored May 6, 2024
2 parents 8c2ede9 + 703f7fa commit 0d40dc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
# os: [macOS-latest, ubuntu-latest, windows-latest] # TODO use this when macOS-latest becomes stable again
os: [macOS-13, ubuntu-latest, windows-latest]
python-version: [3.8, 3.9, "3.10"]

steps:
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: test
channels:

- conda-forge
- pytorch
- conda-forge

- defaults
dependencies:
Expand Down
15 changes: 14 additions & 1 deletion mlcolvar/data/datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import lightning
from torch.utils.data import random_split, Subset
from torch import default_generator, randperm
from torch._utils import _accumulate

from mlcolvar.data import DictLoader, DictDataset

Expand Down Expand Up @@ -324,6 +323,20 @@ def sequential_split(dataset, lengths: Sequence) -> list:

return split_dataset(dataset=dataset, lengths=lengths, random_split=False)

# Taken from python 3.5 docs, removed from PyTorch 2.3 onward
def _accumulate(iterable, fn=lambda x, y: x + y):
"Return running totals"
# _accumulate([1,2,3,4,5]) --> 1 3 6 10 15
# _accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120
it = iter(iterable)
try:
total = next(it)
except StopIteration:
return
yield total
for element in it:
total = fn(total, element)
yield total

if __name__ == "__main__":
import doctest
Expand Down

0 comments on commit 0d40dc1

Please sign in to comment.