From c06b80e8bce5228fe557ae77d51014e6ccd0c4ad Mon Sep 17 00:00:00 2001 From: Jakob Unfried Date: Tue, 27 Jan 2026 03:42:56 +0100 Subject: [PATCH 1/6] Let action also run on v0.* versions --- .github/workflows/create.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create.yml b/.github/workflows/create.yml index 11a5f68..9a2f96f 100644 --- a/.github/workflows/create.yml +++ b/.github/workflows/create.yml @@ -25,7 +25,6 @@ jobs: bare_versions="" for version in $(git tag); do [[ $version != v* ]] && echo "Skipping non-version tag: $version" && continue - [[ $version == v0.* ]] && echo "Skipping: $version" && continue echo "Adding: $version" bare_versions="$bare_versions ${version#v}" done @@ -87,8 +86,12 @@ jobs: - 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 - name: Move datasets run: | From c0d4de23091b8977bc9bdca106df8834ffc14b32 Mon Sep 17 00:00:00 2001 From: Jakob Unfried Date: Tue, 27 Jan 2026 03:56:05 +0100 Subject: [PATCH 2/6] Readable error if no data was generated --- .github/workflows/create.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/create.yml b/.github/workflows/create.yml index 9a2f96f..274ebdd 100644 --- a/.github/workflows/create.yml +++ b/.github/workflows/create.yml @@ -60,6 +60,7 @@ jobs: runs-on: ubuntu-latest if: ${{ needs.detect.outputs.matrix != '[""]' }} strategy: + fail-fast: false matrix: version: ${{ fromJson(needs.detect.outputs.matrix) }} steps: @@ -93,6 +94,11 @@ jobs: 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." + exit 1 + fi + - name: Move datasets run: | mv tenpy_repo/tests/export_import_test/data/* data From f4c746264e65889d25dc2d0f4735d5d2002906ba Mon Sep 17 00:00:00 2001 From: Jakob Unfried Date: Tue, 27 Jan 2026 12:43:26 +0100 Subject: [PATCH 3/6] Only expect hdf5 file if hdf5 test exists already --- .github/workflows/create.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create.yml b/.github/workflows/create.yml index 274ebdd..210122b 100644 --- a/.github/workflows/create.yml +++ b/.github/workflows/create.yml @@ -41,10 +41,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 From 2dcf168dfad853faa7b7ff0045ac8f44b43fb15a Mon Sep 17 00:00:00 2001 From: Jakob Unfried Date: Tue, 27 Jan 2026 14:13:38 +0100 Subject: [PATCH 4/6] Account for naming change on 0.5.1 -> 0.6.0 --- .github/workflows/create.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/create.yml b/.github/workflows/create.yml index 210122b..f3a60f6 100644 --- a/.github/workflows/create.yml +++ b/.github/workflows/create.yml @@ -99,6 +99,13 @@ jobs: 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: | mv tenpy_repo/tests/export_import_test/data/* data From 11ecbd27a9eb82530de53c553c4915584eeb6502 Mon Sep 17 00:00:00 2001 From: Jakob Unfried Date: Tue, 27 Jan 2026 04:04:07 +0100 Subject: [PATCH 5/6] Pin package versions --- .github/workflows/create.yml | 41 ++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create.yml b/.github/workflows/create.yml index f3a60f6..29568f7 100644 --- a/.github/workflows/create.yml +++ b/.github/workflows/create.yml @@ -25,6 +25,7 @@ jobs: bare_versions="" for version in $(git tag); do [[ $version != v* ]] && echo "Skipping non-version tag: $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 @@ -75,14 +76,46 @@ 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.2" >> $GITHUB_ENV + echo "scipy_version=1.5.2" >> $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: | @@ -95,7 +128,7 @@ jobs: fi if [ ! -d tenpy_repo/tests/export_import_test/data ]; then - echo "No data was generated." + echo "No data was generated." >> $GITHUB_STEP_SUMMARY exit 1 fi From 90d8a11d77999eb55060456101745d95b654df03 Mon Sep 17 00:00:00 2001 From: Jakob Unfried Date: Wed, 28 Jan 2026 01:34:07 +0100 Subject: [PATCH 6/6] Use conda for python --- .github/workflows/create.yml | 37 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/.github/workflows/create.yml b/.github/workflows/create.yml index 29568f7..6870cee 100644 --- a/.github/workflows/create.yml +++ b/.github/workflows/create.yml @@ -60,6 +60,9 @@ jobs: needs: [detect] runs-on: ubuntu-latest if: ${{ needs.detect.outputs.matrix != '[""]' }} + defaults: + run: + shell: bash -el {0} strategy: fail-fast: false matrix: @@ -76,22 +79,6 @@ jobs: repository: tenpy/tenpy path: tenpy_repo - - name: Pin versions - run: | - if [[ ${{ matrix.version }} =~ 0.(4|5|6|7).[0-9] ]]; then - echo "numpy_version=1.19.2" >> $GITHUB_ENV - echo "scipy_version=1.5.2" >> $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. @@ -108,14 +95,24 @@ jobs: 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 + - name: Set up conda + uses: conda-incubator/setup-miniconda@v3 with: - python-version: ${{ env.python_version }} + auto-update-conda: true + channels: conda-forge,defaults + channel-priority: true - name: Install dependencies + # note: always pin specific versions, to future proof the environment! run: | - pip install numpy==$numpy_version scipy==$scipy_version pytest h5py + if [[ ${{ matrix.version }} =~ 0.(4|5|6|7).[0-9] ]]; then + conda install -y python==3.9 numpy==1.19.2 scipy==1.5.2 + elif [[ ${{ matrix.version }} =~ 0.(8|9|10|11|99).[0-9] ]] || [[ ${{ matrix.version }} =~ 1.0.[0-2] ]]; then + conda install -y python==3.10 numpy==1.26.4 scipy==1.10.1 + else + conda install -y python==3.13 numpy==2.3.2 scipy==1.16.1 + fi + conda install pytest h5py - name: Generate datasets run: |