From 34787898e2d74a20ed8920432834b9628f7f4b30 Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 25 Nov 2025 16:20:16 +0000 Subject: [PATCH 1/7] try two strategies for removing flex from coveralls --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c92b15b..ddc08d5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,11 +22,11 @@ jobs: run: | python -m pip install --upgrade pip pip install -r test_requirements.txt - git clone https://github.com/ObservationalExpansions/flex.git - pip install -e ./flex + git clone https://github.com/ObservationalExpansions/flex.git .. + pip install -e ../flex - name: Test with pytest run: | - coverage run -m pytest -v -s + coverage run -m pytest --ignore=flex/ -v -s - name: Upload coverage to Coveralls run: coveralls --service=github env: From 06df7d5d52bc31a66eabf7bb7372b7f31f90da8c Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 25 Nov 2025 16:21:58 +0000 Subject: [PATCH 2/7] try one strategy for removing flex from coveralls --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ddc08d5..77a4e2b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,8 +22,8 @@ jobs: run: | python -m pip install --upgrade pip pip install -r test_requirements.txt - git clone https://github.com/ObservationalExpansions/flex.git .. - pip install -e ../flex + git clone https://github.com/ObservationalExpansions/flex.git + pip install -e ./flex - name: Test with pytest run: | coverage run -m pytest --ignore=flex/ -v -s From b262bed3433af5e8f3b0b7ca927df3f22e1d44bf Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 25 Nov 2025 16:33:38 +0000 Subject: [PATCH 3/7] add more coverage --- .github/workflows/test.yaml | 2 +- pytest.ini | 2 ++ src/discmodel/discmodel.py | 32 +++++++++++++++---------------- src/discmodel/optional_imports.py | 2 +- tests/test_discmodel.py | 9 ++++++++- 5 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 pytest.ini diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 77a4e2b..4337d0f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,7 +26,7 @@ jobs: pip install -e ./flex - name: Test with pytest run: | - coverage run -m pytest --ignore=flex/ -v -s + coverage run -m pytest -v -s - name: Upload coverage to Coveralls run: coveralls --service=github env: diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..08ba66f --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --ignore=flex diff --git a/src/discmodel/discmodel.py b/src/discmodel/discmodel.py index ea4c34c..7179097 100644 --- a/src/discmodel/discmodel.py +++ b/src/discmodel/discmodel.py @@ -139,26 +139,26 @@ def rotate_disc(self,xrotation=0.,yrotation=0.,zrotation=0.,euler=False): # do the transformation in position tmp = np.dot(np.array([x,y,z]).T,Rmatrix) - try: - xout = tmp[:,0] - yout = tmp[:,1] - zout = tmp[:,2] - except: - xout = tmp[0] - yout = tmp[1] - zout = tmp[2] + #try: + xout = tmp[:,0] + yout = tmp[:,1] + zout = tmp[:,2] + #except: + # xout = tmp[0] + # yout = tmp[1] + # zout = tmp[2] # and in velocity tmpv = np.dot(np.array([u,v,w]).T,Rmatrix) - try: - uout = tmpv[:,0] - vout = tmpv[:,1] - wout = tmpv[:,2] - except: - uout = tmpv[0] - vout = tmpv[1] - wout = tmpv[2] + #try: + uout = tmpv[:,0] + vout = tmpv[:,1] + wout = tmpv[:,2] + #except: + # uout = tmpv[0] + # vout = tmpv[1] + # wout = tmpv[2] self.x = xout self.y = yout diff --git a/src/discmodel/optional_imports.py b/src/discmodel/optional_imports.py index a043b9f..2c5078e 100644 --- a/src/discmodel/optional_imports.py +++ b/src/discmodel/optional_imports.py @@ -10,7 +10,7 @@ def _check_lintsampler(): def _check_flex(): try: import importlib - importlib.import_module("lintsampler") + importlib.import_module("flex") return True except ImportError: return False diff --git a/tests/test_discmodel.py b/tests/test_discmodel.py index 57e12a9..97b08ef 100644 --- a/tests/test_discmodel.py +++ b/tests/test_discmodel.py @@ -122,6 +122,10 @@ def test_discmodel_expansion(): nbins = 50 disc = discmodel.DiscGalaxy(N=N, a=a, M=M, vcirc=vcirc, rmax=rmax) + + # try to compute expansion before image - should raise error + E1 = disc.make_expansion(mmax=4,nmax=4,rscl=1.0,xmax=rmax,noisy=False) + disc.generate_image(rmax,nbins,noiselevel=noiselevel) # add some noise @@ -132,8 +136,11 @@ def test_discmodel_expansion(): # compute the expansion E1 = disc.make_expansion(mmax=4,nmax=4,rscl=1.0,xmax=rmax,noisy=False) + # compute a nosiy expansion + E2 = disc.make_expansion(mmax=4,nmax=4,rscl=1.0,xmax=rmax,noisy=True) + # compute the expansion from the particles - E2 = disc.make_particle_expansion(mmax=4,nmax=4,rscl=1.0) + E3 = disc.make_particle_expansion(mmax=4,nmax=4,rscl=1.0) # compute A1 a1 = disc.compute_a1(E1) From 4a5a3dbb67b7e3ebb334010a516825851acb28f5 Mon Sep 17 00:00:00 2001 From: Michael Petersen Date: Tue, 25 Nov 2025 17:27:38 +0000 Subject: [PATCH 4/7] Update tests/test_discmodel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/test_discmodel.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_discmodel.py b/tests/test_discmodel.py index 97b08ef..17cd87b 100644 --- a/tests/test_discmodel.py +++ b/tests/test_discmodel.py @@ -124,7 +124,6 @@ def test_discmodel_expansion(): disc = discmodel.DiscGalaxy(N=N, a=a, M=M, vcirc=vcirc, rmax=rmax) # try to compute expansion before image - should raise error - E1 = disc.make_expansion(mmax=4,nmax=4,rscl=1.0,xmax=rmax,noisy=False) disc.generate_image(rmax,nbins,noiselevel=noiselevel) From 442311f8ddabac9c993557a0d9aca363fe9de408 Mon Sep 17 00:00:00 2001 From: Michael Petersen Date: Tue, 25 Nov 2025 17:27:46 +0000 Subject: [PATCH 5/7] Update tests/test_discmodel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/test_discmodel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_discmodel.py b/tests/test_discmodel.py index 17cd87b..0892eca 100644 --- a/tests/test_discmodel.py +++ b/tests/test_discmodel.py @@ -137,7 +137,7 @@ def test_discmodel_expansion(): # compute a nosiy expansion E2 = disc.make_expansion(mmax=4,nmax=4,rscl=1.0,xmax=rmax,noisy=True) - + assert E2 is not None # compute the expansion from the particles E3 = disc.make_particle_expansion(mmax=4,nmax=4,rscl=1.0) From 6922967a21d07593c051aff402bfe25c686363b8 Mon Sep 17 00:00:00 2001 From: Michael Petersen Date: Tue, 25 Nov 2025 17:27:55 +0000 Subject: [PATCH 6/7] Update tests/test_discmodel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/test_discmodel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_discmodel.py b/tests/test_discmodel.py index 0892eca..0a94c5e 100644 --- a/tests/test_discmodel.py +++ b/tests/test_discmodel.py @@ -140,7 +140,7 @@ def test_discmodel_expansion(): assert E2 is not None # compute the expansion from the particles E3 = disc.make_particle_expansion(mmax=4,nmax=4,rscl=1.0) - + assert E3 is not None # compute A1 a1 = disc.compute_a1(E1) From 4085b5e85c9c517b0ffc78fbdf6473fb444f239b Mon Sep 17 00:00:00 2001 From: Michael Petersen Date: Tue, 25 Nov 2025 17:28:03 +0000 Subject: [PATCH 7/7] Update tests/test_discmodel.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/test_discmodel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_discmodel.py b/tests/test_discmodel.py index 0a94c5e..e5899e3 100644 --- a/tests/test_discmodel.py +++ b/tests/test_discmodel.py @@ -135,7 +135,7 @@ def test_discmodel_expansion(): # compute the expansion E1 = disc.make_expansion(mmax=4,nmax=4,rscl=1.0,xmax=rmax,noisy=False) - # compute a nosiy expansion + # compute a noisy expansion E2 = disc.make_expansion(mmax=4,nmax=4,rscl=1.0,xmax=rmax,noisy=True) assert E2 is not None # compute the expansion from the particles