Skip to content
Closed
Changes from all commits
Commits
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
70 changes: 61 additions & 9 deletions .github/workflows/create.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Create missing datasets

on: workflow_dispatch
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
detect:
Expand All @@ -25,7 +28,7 @@ jobs:
bare_versions=""
for version in $(git tag); do
[[ $version != v* ]] && echo "Skipping non-version tag: $version" && continue
[[ $version == v0.* ]] && echo "Skipping: $version" && continue
[[ $version =~ v0.(1|2|3).0 ]] && echo "Skipping $version (too old, no export code)" && continue
echo "Adding: $version"
bare_versions="$bare_versions ${version#v}"
done
Expand All @@ -42,10 +45,10 @@ jobs:
echo "Checking: $version"
pkl_file="data/exported_from_tenpy_$version.pkl"
hdf5_file="data/exported_from_tenpy_$version.hdf5"
if [ ! -f $pkl_file ]; then
if [ ! -f $pkl_file ] && [ -f tenpy_repo/tests/export_import_test/test_pickle.py ]; then
echo " $pkl_file missing"
missing_versions="$missing_versions $version"
elif [ ! -f $hdf5_file ]; then
elif [ ! -f $hdf5_file ] && [ -f tenpy_repo/tests/export_import_test/test_hdf5.py ]; then
echo " $hdf5_file missing"
missing_versions="$missing_versions $version"
fi
Expand All @@ -61,6 +64,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ needs.detect.outputs.matrix != '[""]' }}
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.detect.outputs.matrix) }}
steps:
Expand All @@ -75,20 +79,68 @@ jobs:
repository: tenpy/tenpy
path: tenpy_repo

- name: Set up Python 3.14
- name: Pin versions
run: |
if [[ ${{ matrix.version }} =~ 0.(4|5|6|7).[0-9] ]]; then
echo "numpy_version=1.19" >> $GITHUB_ENV
echo "scipy_version=1.8" >> $GITHUB_ENV
echo "python_version=3.9" >> $GITHUB_ENV
elif [[ ${{ matrix.version }} =~ 0.(8|9|10|11|99).[0-9] ]] || [[ ${{ matrix.version }} =~ 1.0.[0-2] ]]; then
echo "numpy_version=1.26" >> $GITHUB_ENV
echo "scipy_version=1.10" >> $GITHUB_ENV
echo "python_version=3.10" >> $GITHUB_ENV
else
echo "numpy_version=2.3.2" >> $GITHUB_ENV
echo "scipy_version=1.16.1" >> $GITHUB_ENV
echo "python_version=3.13" >> $GITHUB_ENV
fi

- name: Remove unused pylab imports
if: matrix.version == '0.4.0'
# v0.4.0 imports pylab but does not use it.
# rather than figuring out how to install it, we just remove the unused import statement
# also remove bugged lines from the __main__ block of test_pickle.py
run: |
sed -i '/import pylab as pl/d' tenpy_repo/tenpy/algorithms/tdvp.py
sed -i '/import pylab as pl/d' tenpy_repo/tests/tdvp_numpy.py

- name: Fix export_import script
if: matrix.version == '0.4.0' || matrix.version == '0.4.1' || matrix.version == '0.5.0'
# there are two lines in the __main__ block that seem outdated and need to be removed
run: |
sed -i '/for f, fn in test_data_import():/d' tenpy_repo/tests/export_import_test/test_pickle.py
sed -i '/f(fn)/d' tenpy_repo/tests/export_import_test/test_pickle.py

- name: Set up Python ${{ env.python_version }}
uses: actions/setup-python@v6
with:
python-version: 3.14
python-version: ${{ env.python_version }}

- name: Install dependencies
run: |
pip install numpy scipy pytest h5py
pip install numpy==$numpy_version scipy==$scipy_version pytest h5py

- name: Generate datasets
run: |
export PYTHONPATH="$PYTHONPATH:${{ github.workspace }}/tenpy_repo"
python tenpy_repo/tests/export_import_test/test_hdf5.py
python tenpy_repo/tests/export_import_test/test_pickle.py
if [ -f tenpy_repo/tests/export_import_test/test_hdf5.py ]; then
python tenpy_repo/tests/export_import_test/test_hdf5.py
fi
if [ -f tenpy_repo/tests/export_import_test/test_pickle.py ]; then
python tenpy_repo/tests/export_import_test/test_pickle.py
fi

if [ ! -d tenpy_repo/tests/export_import_test/data ]; then
echo "No data was generated." >> $GITHUB_STEP_SUMMARY
exit 1
fi

- name: Rename datasets
if: matrix.version == '0.4.0' || matrix.version == '0.4.1' || matrix.version == '0.5.0'
# the naming convention for the files changed in 0.6.0
run: |
mv tenpy_repo/tests/export_import_test/data/pickled_from_tenpy_v${{ matrix.version }}.pkl \
tenpy_repo/tests/export_import_test/data/exported_from_tenpy_v${{ matrix.version }}.pkl

- name: Move datasets
run: |
Expand Down
Loading