From 62679ecd4644ba42ab79648b6393e072a29391b2 Mon Sep 17 00:00:00 2001 From: IainHammond Date: Thu, 26 Mar 2026 14:39:51 +0100 Subject: [PATCH 01/11] replaced double array operation, switch mgrid for broadcast_to --- src/vip_hci/preproc/derotation.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vip_hci/preproc/derotation.py b/src/vip_hci/preproc/derotation.py index 83749f86..610c8ad6 100644 --- a/src/vip_hci/preproc/derotation.py +++ b/src/vip_hci/preproc/derotation.py @@ -219,7 +219,7 @@ def frame_rotate(array, angle, imlib='vip-fft', interpolation='lanczos4', array_prep = array.copy() # residual (non-interp) nans should be set to 0 to avoid bug in rotation - array_prep[np.where(np.isnan(array_prep))] = 0 + array_prep[np.isnan(array_prep)] = 0 y, x = array_prep.shape @@ -604,9 +604,8 @@ def rotate_fft(array, angle): ori_y, ori_x = array_in.shape cy, cx = frame_center(array) - arr_xy = np.mgrid[0:ori_y, 0:ori_x] - arr_y = arr_xy[0]-cy - arr_x = arr_xy[1]-cx + arr_y = np.broadcast_to((np.arange(ori_y) - cy)[:, np.newaxis], (ori_y, ori_x)) + arr_x = np.broadcast_to((np.arange(ori_x) - cx)[np.newaxis, :], (ori_y, ori_x)) # TODO: make FFT padding work for other option than '0'. s_x = _fft_shear(array_in, arr_x, a, ax=1, pad=0) From 83b95dc0da93b810e7085428e835dfb4f7891001 Mon Sep 17 00:00:00 2001 From: IainHammond Date: Thu, 26 Mar 2026 14:46:57 +0100 Subject: [PATCH 02/11] fix for no reference cube case in _adimsdi_doublepca --- src/vip_hci/psfsub/pca_fullfr.py | 48 +++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/vip_hci/psfsub/pca_fullfr.py b/src/vip_hci/psfsub/pca_fullfr.py index 877520e4..10dda4ae 100644 --- a/src/vip_hci/psfsub/pca_fullfr.py +++ b/src/vip_hci/psfsub/pca_fullfr.py @@ -1428,22 +1428,38 @@ def _adimsdi_doublepca( for frame in range(n): ind = _find_indices_adi(angle_list, frame, pa_thr, truncate=truncate, max_frames=max_fr) - - res_result = _project_subtract( - res_cube_channels[:n], - res_cube_channels[n:], - ncomp_adi, - scaling[1], - mask_center_px, - svd_mode, - verbose, - False, - ind, - frame, - cube_sig=cube_sig, - left_eigv=left_eigv, - min_frames_pca=min_frames_pca, - ) + if 'A' in ref_strategy or cube_ref is None: + res_result = _project_subtract( + res_cube_channels[:n], + None, + ncomp_adi, + scaling[1], + mask_center_px, + svd_mode, + verbose, + False, + ind, + frame, + cube_sig=cube_sig, + left_eigv=left_eigv, + min_frames_pca=min_frames_pca, + ) + else: + res_result = _project_subtract( + res_cube_channels[:n], + res_cube_channels[n:], # ref cube + ncomp_adi, + scaling[1], + mask_center_px, + svd_mode, + verbose, + False, + ind, + frame, + cube_sig=cube_sig, + left_eigv=left_eigv, + min_frames_pca=min_frames_pca, + ) res_ifs_adi[frame] = res_result[-1].reshape((y_in, x_in)) if verbose: From d0914b99c355f44e64cba33a03ca1aeaf7f75bbd Mon Sep 17 00:00:00 2001 From: IainHammond Date: Thu, 26 Mar 2026 15:08:48 +0100 Subject: [PATCH 03/11] bumping test versions before they get removed --- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/draft-pdf.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8892d946..63314428 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,9 @@ jobs: group: [1, 2, 3] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -56,7 +56,7 @@ jobs: coverage run --source src -m pytest tests/pre_3_10 --splits 3 --group ${{ matrix.group }} coverage xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 objects_check: @@ -67,9 +67,9 @@ jobs: python-version: ["3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -93,4 +93,4 @@ jobs: coverage run --source=src/vip_hci/objects/ -m pytest tests/post_3_10 coverage xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 diff --git a/.github/workflows/draft-pdf.yml b/.github/workflows/draft-pdf.yml index cce545f2..47ec13e3 100644 --- a/.github/workflows/draft-pdf.yml +++ b/.github/workflows/draft-pdf.yml @@ -6,7 +6,7 @@ jobs: name: Paper Draft steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build draft PDF uses: openjournals/openjournals-draft-action@master with: From bbc593e9c09d747addfdd4f102c337afe7de5074 Mon Sep 17 00:00:00 2001 From: IainHammond Date: Thu, 26 Mar 2026 15:52:47 +0100 Subject: [PATCH 04/11] bumping actions to latest major version --- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/draft-pdf.yml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63314428..20ba7ead 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,9 @@ jobs: group: [1, 2, 3] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -56,7 +56,7 @@ jobs: coverage run --source src -m pytest tests/pre_3_10 --splits 3 --group ${{ matrix.group }} coverage xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 + uses: codecov/codecov-action@v6 objects_check: @@ -67,9 +67,9 @@ jobs: python-version: ["3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -93,4 +93,4 @@ jobs: coverage run --source=src/vip_hci/objects/ -m pytest tests/post_3_10 coverage xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 + uses: codecov/codecov-action@v6 diff --git a/.github/workflows/draft-pdf.yml b/.github/workflows/draft-pdf.yml index 47ec13e3..6f6d14ea 100644 --- a/.github/workflows/draft-pdf.yml +++ b/.github/workflows/draft-pdf.yml @@ -6,7 +6,7 @@ jobs: name: Paper Draft steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Build draft PDF uses: openjournals/openjournals-draft-action@master with: @@ -14,7 +14,7 @@ jobs: # This should be the path to the paper within your repo. paper-path: paper.md - name: Upload - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: paper # This is the output path where Pandoc will write the compiled From 7f22dcb20c179d897eff026b04933f24c59c2e1b Mon Sep 17 00:00:00 2001 From: IainHammond Date: Fri, 27 Mar 2026 13:57:07 +0100 Subject: [PATCH 05/11] updating pre-commit hooks to v6 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 91a09a0e..3ba88f61 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer From 7e74a5c367db3745ce2219de369e70ffc7c2ead5 Mon Sep 17 00:00:00 2001 From: IainHammond Date: Fri, 27 Mar 2026 14:03:01 +0100 Subject: [PATCH 06/11] pre-commit runs once, drop unused code, cache pip --- .github/workflows/ci.yml | 45 +++++++++++++++------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20ba7ead..40e1309e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# This workflow will install Python depe:ndencies, run tests and lint with a variety of Python versions +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: ci @@ -15,8 +15,20 @@ env: COVERAGE_CORE: sysmon jobs: - no_object_checks: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 + with: + python-version: "3.14" + - name: Run pre-commit + run: | + pip install pre-commit + pre-commit run --all-files + no_object_checks: + needs: pre-commit runs-on: ubuntu-latest strategy: fail-fast: false @@ -34,23 +46,11 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + cache: pip - name: Install dependencies run: | python -m pip install --upgrade pip pip install --editable . --group dev - # Uncomment below when ready to deal with a lot of PEP8 formatting changes - - name: Verify files with pre-commit - run: | - # Setup pre-commit hooks - pre-commit clean - pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks - pre-commit install --hook-type pre-merge-commit - pre-commit install --hook-type pre-push - pre-commit install --hook-type post-rewrite - pre-commit install-hooks - pre-commit install - # Run pre-commit hooks - pre-commit run --files src/**/*.py - name: Test with pytest run: | coverage run --source src -m pytest tests/pre_3_10 --splits 3 --group ${{ matrix.group }} @@ -59,7 +59,7 @@ jobs: uses: codecov/codecov-action@v6 objects_check: - + needs: pre-commit runs-on: ubuntu-latest strategy: fail-fast: false @@ -72,22 +72,11 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + cache: pip - name: Install dependencies run: | python -m pip install --upgrade pip pip install --editable . --group dev - - name: Verify files with pre-commit - run: | - # Setup pre-commit hooks - pre-commit clean - pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks - pre-commit install --hook-type pre-merge-commit - pre-commit install --hook-type pre-push - pre-commit install --hook-type post-rewrite - pre-commit install-hooks - pre-commit install - # Run pre-commit hooks - pre-commit run --files src/vip_hci/objects/*.py - name: Test with pytest run: | coverage run --source=src/vip_hci/objects/ -m pytest tests/post_3_10 From f28620bcb30731fc5ca915f35a4dcc18eb343bf6 Mon Sep 17 00:00:00 2001 From: IainHammond Date: Fri, 27 Mar 2026 14:18:04 +0100 Subject: [PATCH 07/11] pre-commit runs once, drop unused code, cache pip --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40e1309e..ed31d85f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Run pre-commit run: | pip install pre-commit - pre-commit run --all-files + pre-commit run --files src/**/*.py no_object_checks: needs: pre-commit From 2518f6f14d6fa9e58020676f7101c91a964f20aa Mon Sep 17 00:00:00 2001 From: IainHammond Date: Mon, 30 Mar 2026 12:11:33 +0200 Subject: [PATCH 08/11] bkg_proba can be imported --- src/vip_hci/stats/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vip_hci/stats/__init__.py b/src/vip_hci/stats/__init__.py index 4b6e7bd2..6ac11bc6 100644 --- a/src/vip_hci/stats/__init__.py +++ b/src/vip_hci/stats/__init__.py @@ -9,6 +9,7 @@ - distance (correlation) between a cube and a reference frame. """ +from .bkg_proba import * from .clip_sigma import * from .distances import * from .im_stats import * From 7897589a590c0f98ec1a2b75f985c367071faeea Mon Sep 17 00:00:00 2001 From: IainHammond Date: Mon, 30 Mar 2026 13:35:22 +0200 Subject: [PATCH 09/11] deleting unused files --- .travis.yml | 20 ------------------- ...thedocs_full_compilation_timeout_error.yml | 15 -------------- 2 files changed, 35 deletions(-) delete mode 100644 .travis.yml delete mode 100644 readthedocs_full_compilation_timeout_error.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 089dbffb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: python - -sudo: required -dist: xenial # no 3.7 on 14.04 Trusty - -python: - - 3.7 - - 3.8 - - 3.9 - -# command to install dependencies -install: - - pip install -e . - -# command to run tests + coverage -script: - - pytest -v - -after_success: - - codecov diff --git a/readthedocs_full_compilation_timeout_error.yml b/readthedocs_full_compilation_timeout_error.yml deleted file mode 100644 index 0ca52ca0..00000000 --- a/readthedocs_full_compilation_timeout_error.yml +++ /dev/null @@ -1,15 +0,0 @@ -# .readthedocs_timeout_error.yml - -version: 2 - -build: - os: ubuntu-22.04 - tools: - python: "3.10" - -python: - install: - - requirements: docs/requirements.txt - -sphinx: - configuration: docs/source/conf.py From b983edcdab32f8f2417a53f784ea83043c7e86f8 Mon Sep 17 00:00:00 2001 From: IainHammond Date: Mon, 30 Mar 2026 14:03:32 +0200 Subject: [PATCH 10/11] major fix to bkg_star_proba --- src/vip_hci/stats/bkg_proba.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/vip_hci/stats/bkg_proba.py b/src/vip_hci/stats/bkg_proba.py index e4611d58..67970e36 100644 --- a/src/vip_hci/stats/bkg_proba.py +++ b/src/vip_hci/stats/bkg_proba.py @@ -11,9 +11,10 @@ import numpy as np -def bkg_star_proba(n_dens, sep, n_bkg=1, verbose=True, full_output=False): +def bkg_star_proba(n_dens, sep, n_bkg=1, unit="deg", verbose=True, + full_output=False): """ Given an input density of background star brighter than a certain - magnitude (obtained e.g. from the Besancon model or TRILEGAL), and the + magnitude (obtained e.g. from the Besançon model or TRILEGAL), and the separation of n_bkg point source, estimate the probability of having n_bkg or more background stars in a disk with radius equal to the largest separation. @@ -23,12 +24,15 @@ def bkg_star_proba(n_dens, sep, n_bkg=1, verbose=True, full_output=False): ---------- n_dens : float Number density of background stars in the direction of the object of - interest, in arcsec^-2. + interest. Units are set by the ``unit`` parameter. sep : float or numpy 1d array Separation of the point sources with respect to central star, in arcsec. n_bkg : int, opt Number of point sources in the field, and for which the separation is provided. + unit : str, opt + Unit of ``n_dens``. Either ``"deg"`` for deg^-2 (default, e.g. from + the Besançon model) or ``"arcsec"`` for arcsec^-2. verbose: bool, opt Whether to print the probabilities for 0 to n_bkg point sources. full_output: bool, opt @@ -46,6 +50,11 @@ def bkg_star_proba(n_dens, sep, n_bkg=1, verbose=True, full_output=False): if n_bkg < 1 or not isinstance(n_bkg, int): raise TypeError("n_bkg should be a strictly positive integer.") + if unit == "deg": + n_dens = n_dens / 3600**2 + elif unit != "arcsec": + raise ValueError("unit must be 'deg' or 'arcsec'.") + if not isinstance(sep, float): if isinstance(sep, np.ndarray): if sep.ndim != 1 or sep.shape[0] != n_bkg: @@ -61,14 +70,14 @@ def bkg_star_proba(n_dens, sep, n_bkg=1, verbose=True, full_output=False): probas[i] = np.exp(-n_dens*B)*(n_dens*B)**i/float(factorial(i)) if verbose: msg = "Proba of having {:.0f} bkg star in a disk of " - msg += "{:.1}'' radius: {:.1f}%" - print(msg.format(i, sep, probas[i])) + msg += "{:.1}'' radius: {:.4g}%" + print(msg.format(i, sep, probas[i]*100)) proba = 1-np.sum(probas) if verbose: msg = "Proba of having {:.0f} bkg star or more in a disk of " - msg += "{:.1}'' radius: {:.1f}%" - print(msg.format(n_bkg, sep, proba)) + msg += "{:.1}'' radius: {:.4g}%" + print(msg.format(n_bkg, sep, proba*100)) if full_output: return proba, probas From f598105dfecdabc69127d46b782afacc222a2fbb Mon Sep 17 00:00:00 2001 From: IainHammond Date: Mon, 30 Mar 2026 14:13:34 +0200 Subject: [PATCH 11/11] major fix to bkg_star_proba --- src/vip_hci/stats/bkg_proba.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vip_hci/stats/bkg_proba.py b/src/vip_hci/stats/bkg_proba.py index 67970e36..968a9e6b 100644 --- a/src/vip_hci/stats/bkg_proba.py +++ b/src/vip_hci/stats/bkg_proba.py @@ -51,8 +51,13 @@ def bkg_star_proba(n_dens, sep, n_bkg=1, unit="deg", verbose=True, raise TypeError("n_bkg should be a strictly positive integer.") if unit == "deg": + if verbose: + print("Input n_dens unit: deg^-2") n_dens = n_dens / 3600**2 - elif unit != "arcsec": + elif unit == "arcsec": + if verbose: + print("Input n_dens unit: arcsec^-2") + else: raise ValueError("unit must be 'deg' or 'arcsec'.") if not isinstance(sep, float): @@ -70,13 +75,13 @@ def bkg_star_proba(n_dens, sep, n_bkg=1, unit="deg", verbose=True, probas[i] = np.exp(-n_dens*B)*(n_dens*B)**i/float(factorial(i)) if verbose: msg = "Proba of having {:.0f} bkg star in a disk of " - msg += "{:.1}'' radius: {:.4g}%" + msg += "{:.2g}'' radius: {:.4g}%" print(msg.format(i, sep, probas[i]*100)) proba = 1-np.sum(probas) if verbose: msg = "Proba of having {:.0f} bkg star or more in a disk of " - msg += "{:.1}'' radius: {:.4g}%" + msg += "{:.2g}'' radius: {:.4g}%" print(msg.format(n_bkg, sep, proba*100)) if full_output: