diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c92b15b..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 -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..e5899e3 100644 --- a/tests/test_discmodel.py +++ b/tests/test_discmodel.py @@ -122,6 +122,9 @@ 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 + disc.generate_image(rmax,nbins,noiselevel=noiselevel) # add some noise @@ -132,9 +135,12 @@ def test_discmodel_expansion(): # compute the expansion E1 = disc.make_expansion(mmax=4,nmax=4,rscl=1.0,xmax=rmax,noisy=False) + # 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 - E2 = disc.make_particle_expansion(mmax=4,nmax=4,rscl=1.0) - + E3 = disc.make_particle_expansion(mmax=4,nmax=4,rscl=1.0) + assert E3 is not None # compute A1 a1 = disc.compute_a1(E1)