From 2d9c7804e7041eb8723b16d6cb0cc6bb84514016 Mon Sep 17 00:00:00 2001 From: Dan Foreman-Mackey Date: Tue, 13 Oct 2020 11:58:58 -0400 Subject: [PATCH 01/14] Update windows-tests.yml --- .github/workflows/windows-tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index 9043398dc..82c4e0543 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -21,17 +21,19 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: goanpeca/setup-miniconda@v1 + - uses: conda-incubator/setup-miniconda@v1 with: auto-update-conda: true python-version: ${{ matrix.python-version }} - name: Install dependencies + shell: bash -l {0} run: | conda install -c conda-forge -q gsl libpython python -m pip install -e .[test] python -m pip install tox - name: Run tests + shell: bash -l {0} run: | tox -e py38-test From bc1f9da4423bb80f46aac0a5205a63d0311f1cb4 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 13 Oct 2020 13:15:26 -0400 Subject: [PATCH 02/14] re-enable tests and pin tox --- .github/workflows/windows-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index 82c4e0543..93ef4e00b 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -3,10 +3,10 @@ name: Windows-tests on: push: branches: - - DISABLED + - main pull_request: branches: - - DISABLED + - main jobs: build: @@ -31,7 +31,7 @@ jobs: run: | conda install -c conda-forge -q gsl libpython python -m pip install -e .[test] - python -m pip install tox + python -m pip install tox==3.20.0 - name: Run tests shell: bash -l {0} From fce39e9a94040e1f6b492bb1dc93b125dcda9270 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 13 Oct 2020 13:23:07 -0400 Subject: [PATCH 03/14] ok fine, try tox 3.19.0 [skip ci] --- .github/workflows/windows-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index 93ef4e00b..1cf2d731c 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -31,7 +31,7 @@ jobs: run: | conda install -c conda-forge -q gsl libpython python -m pip install -e .[test] - python -m pip install tox==3.20.0 + python -m pip install tox==3.19.0 - name: Run tests shell: bash -l {0} From 2388f29e566d8833c589b4cd0debd21de6c937ad Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 13 Oct 2020 13:31:56 -0400 Subject: [PATCH 04/14] flailing about - drop this commit [skip ci] --- .github/workflows/windows-tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index 1cf2d731c..da844321e 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -31,9 +31,15 @@ jobs: run: | conda install -c conda-forge -q gsl libpython python -m pip install -e .[test] - python -m pip install tox==3.19.0 + python -m pip install tox==3.20.0 + + - name: Conda info + shell: bash -l {0} + run: | + conda info + conda list - name: Run tests shell: bash -l {0} run: | - tox -e py38-test + python -m tox -e py38-test From f8ecc006fce6b10ec86c28bdd6941abe146c2e7e Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Tue, 13 Oct 2020 13:47:29 -0400 Subject: [PATCH 05/14] force activate test [ci skip] --- .github/workflows/windows-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index da844321e..c10d57389 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -42,4 +42,5 @@ jobs: - name: Run tests shell: bash -l {0} run: | - python -m tox -e py38-test + conda activate test + tox -e py38-test From 1dc7bda67b25ebae31d35284a95c6e28360f743b Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 13:58:19 -0400 Subject: [PATCH 06/14] pin virtualenv version --- .github/workflows/windows-tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index c10d57389..ee570ffe3 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -31,13 +31,7 @@ jobs: run: | conda install -c conda-forge -q gsl libpython python -m pip install -e .[test] - python -m pip install tox==3.20.0 - - - name: Conda info - shell: bash -l {0} - run: | - conda info - conda list + python -m pip install virtualenv=20.0.33 # 20.0.34 broken! - name: Run tests shell: bash -l {0} From 7c89b8bf40ec6f214bfc0ba4305a0861cc3d0373 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 14:04:11 -0400 Subject: [PATCH 07/14] oops typo --- .github/workflows/windows-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index ee570ffe3..b8c6406f9 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -31,7 +31,7 @@ jobs: run: | conda install -c conda-forge -q gsl libpython python -m pip install -e .[test] - python -m pip install virtualenv=20.0.33 # 20.0.34 broken! + python -m pip install virtualenv==20.0.33 # 20.0.34 broken! - name: Run tests shell: bash -l {0} From 7135514a4d828fc32da8c794e47e69e31064cd5b Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 14:30:46 -0400 Subject: [PATCH 08/14] remove activate --- .github/workflows/windows-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index b8c6406f9..b7842fad5 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -36,5 +36,4 @@ jobs: - name: Run tests shell: bash -l {0} run: | - conda activate test tox -e py38-test From 6223f23ce63c56a5c73a48ffac76eab45a9de1ab Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 14:40:16 -0400 Subject: [PATCH 09/14] oops why did i delete this --- .github/workflows/windows-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index b7842fad5..1b5d3a3f2 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -32,6 +32,7 @@ jobs: conda install -c conda-forge -q gsl libpython python -m pip install -e .[test] python -m pip install virtualenv==20.0.33 # 20.0.34 broken! + python -m pip install tox - name: Run tests shell: bash -l {0} From 87cf30e087ae2bf3473a9e01112c581bc9c8a91d Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 09:01:14 -0400 Subject: [PATCH 10/14] allow static to static frame transformations --- .../frame/builtin/transformations.py | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/gala/potential/frame/builtin/transformations.py b/gala/potential/frame/builtin/transformations.py index af8ceece7..0bd298246 100644 --- a/gala/potential/frame/builtin/transformations.py +++ b/gala/potential/frame/builtin/transformations.py @@ -3,7 +3,8 @@ import numpy as np # Gala -from ....dynamics import Orbit +from gala.dynamics import Orbit +from gala.units import DimensionlessUnitSystem __all__ = ['static_to_constantrotating', 'constantrotating_to_static'] @@ -145,3 +146,31 @@ def constantrotating_to_static(frame_r, frame_i, w, t=None): """ return _constantrotating_static_helper(frame_r=frame_r, frame_i=frame_i, w=w, t=t, sign=-1.) + + +def static_to_static(frame_r, frame_i, w, t=None): + """ + No-op transform + + Parameters + ---------- + frame_i : `~gala.potential.StaticFrame` + frame_r : `~gala.potential.ConstantRotatingFrame` + w : `~gala.dynamics.PhaseSpacePosition`, `~gala.dynamics.Orbit` + t : quantity_like (optional) + Required if input coordinates are just a phase-space position. + + Returns + ------- + pos : `~astropy.units.Quantity` + Position in static, inertial frame. + vel : `~astropy.units.Quantity` + Velocity in static, inertial frame. + """ + tmp = [isinstance(frame_r.units, DimensionlessUnitSystem), + isinstance(frame_i.units, DimensionlessUnitSystem)] + if not all(tmp) and any(tmp): + raise ValueError( + "StaticFrame to StaticFrame transformations are only allowed if " + "both unit systems are physical, or both are dimensionless.") + return w.pos.xyz, w.vel.d_xyz From 5551774a8ff24a2683889cb105d549fc92eae40e Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 09:01:30 -0400 Subject: [PATCH 11/14] fix galpy tests --- gala/dynamics/core.py | 8 ++++---- gala/dynamics/tests/test_core.py | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gala/dynamics/core.py b/gala/dynamics/core.py index 6cdb630b0..bdf6c5249 100644 --- a/gala/dynamics/core.py +++ b/gala/dynamics/core.py @@ -874,8 +874,8 @@ def to_galpy_orbit(self, ro=None, vo=None): galpy_orbit : `galpy.orbit.Orbit` """ - import galpy from galpy.orbit import Orbit + from galpy.util.config import __config__ as galpy_config if self.frame is not None: from ..potential import StaticFrame @@ -884,11 +884,11 @@ def to_galpy_orbit(self, ro=None, vo=None): w = self if ro is None: - ro = galpy.config.__config__.getfloat('normalization', 'ro') + ro = galpy_config.getfloat('normalization', 'ro') ro = ro * u.kpc if vo is None: - vo = galpy.config.__config__.getfloat('normalization', 'vo') + vo = galpy_config.getfloat('normalization', 'vo') vo = vo * u.km/u.s # PhaseSpacePosition or Orbit: @@ -904,7 +904,7 @@ def to_galpy_orbit(self, ro=None, vo=None): o = Orbit(np.array([R, vR, vT, z, vz, phi]).T, ro=ro, vo=vo) - if hasattr(w, 't'): + if hasattr(w, 't') and w.t is not None: o.t = w.t.to_value(ro / vo) return o diff --git a/gala/dynamics/tests/test_core.py b/gala/dynamics/tests/test_core.py index dc30ec753..aa728f5d2 100644 --- a/gala/dynamics/tests/test_core.py +++ b/gala/dynamics/tests/test_core.py @@ -393,9 +393,9 @@ def test_frame_transform(): @pytest.mark.parametrize('obj', [ PhaseSpacePosition([1, 2, 3.]*u.kpc, [1, 2, 3.]*u.km/u.s), PhaseSpacePosition([1, 2, 3.]*u.kpc, [1, 2, 3.]*u.km/u.s, - StaticFrame(galactic)), + StaticFrame(units=galactic)), PhaseSpacePosition([1, 2, 3.]*u.kpc, [1, 2, 3.]*u.km/u.s, - ConstantRotatingFrame([1., 0, 0]*u.rad/u.Myr, + ConstantRotatingFrame(Omega=[1., 0, 0]*u.rad/u.Myr, units=galactic)), ]) def test_io(tmpdir, obj): @@ -412,11 +412,9 @@ def test_io(tmpdir, obj): @pytest.mark.parametrize('obj', [ - PhaseSpacePosition([1,2,3.]*u.kpc, [1,2,3.]*u.km/u.s), - PhaseSpacePosition([1,2,3.]*u.kpc, [1,2,3.]*u.km/u.s, - StaticFrame(galactic)), - PhaseSpacePosition([1,2,3.]*u.kpc, [1,2,3.]*u.km/u.s, - ConstantRotatingFrame([1.,0,0]*u.rad/u.Myr, galactic)), + PhaseSpacePosition([1, 2, 3.]*u.kpc, [1, 2, 3.]*u.km/u.s), + PhaseSpacePosition([1, 2, 3.]*u.kpc, [1, 2, 3.]*u.km/u.s, + StaticFrame(units=galactic)), ]) @pytest.mark.skipif(not HAS_GALPY, reason="requires galpy to run this test") From caa203aba9aae68be6c662db5a9ba8af33d35ed3 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 16:17:00 -0400 Subject: [PATCH 12/14] customize pytest header --- gala/conftest.py | 50 +++++++++++++++++++++++++++++------------------- setup.cfg | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/gala/conftest.py b/gala/conftest.py index 672b2733d..365dd9df9 100644 --- a/gala/conftest.py +++ b/gala/conftest.py @@ -7,33 +7,43 @@ from astropy.version import version as astropy_version -# For Astropy 3.0 and later, we can use the standalone pytest plugin -if astropy_version < '3.0': - from astropy.tests.pytest_plugins import * # noqa - del pytest_report_header - ASTROPY_HEADER = True -else: - try: - from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS - ASTROPY_HEADER = True - except ImportError: - ASTROPY_HEADER = False +from pytest_astropy_header.display import ( + PYTEST_HEADER_MODULES, + TESTED_VERSIONS, + pytest_report_header as astropy_header) def pytest_configure(config): - if ASTROPY_HEADER: + config.option.astropy_header = False - config.option.astropy_header = True + # Customize the following lines to add/remove entries from the list of + # packages for which version numbers are displayed when running the tests. + PYTEST_HEADER_MODULES.pop('Pandas', None) + PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' - # Customize the following lines to add/remove entries from the list of - # packages for which version numbers are displayed when running the tests. - PYTEST_HEADER_MODULES.pop('Pandas', None) - PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' + from . import __version__ + packagename = os.path.basename(os.path.dirname(__file__)) + TESTED_VERSIONS[packagename] = __version__ + + +def pytest_report_header(config): + from gala._cconfig import GSL_ENABLED + + config.option.astropy_header = True + hdr = astropy_header(config) + config.option.astropy_header = False + + hdr += "\n" + + if GSL_ENABLED: + hdr += " +++ Gala compiled with GSL +++" + else: + hdr += " --- Gala compiled without GSL ---" + + hdr += "\n" + return hdr - from . import __version__ - packagename = os.path.basename(os.path.dirname(__file__)) - TESTED_VERSIONS[packagename] = __version__ # Uncomment the last two lines in this block to treat all DeprecationWarnings as # exceptions. For Astropy v2.0 or later, there are 2 additional keywords, diff --git a/setup.cfg b/setup.cfg index c271bf916..4f5983013 100644 --- a/setup.cfg +++ b/setup.cfg @@ -61,7 +61,7 @@ docs = [tool:pytest] testpaths = "gala" "docs" -astropy_header = true +astropy_header = false doctest_plus = enabled text_file_format = rst addopts = --doctest-rst From ff03dea65faccefbbf6a7f32efd3dc094fd4153e Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 16:18:09 -0400 Subject: [PATCH 13/14] verbose pytest --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 81f21d896..afb65965d 100644 --- a/tox.ini +++ b/tox.ini @@ -59,8 +59,8 @@ extras = commands = pip freeze - !cov: pytest --pyargs gala {toxinidir}/docs {posargs} - cov: pytest --pyargs gala {toxinidir}/docs --cov gala --cov-config={toxinidir}/setup.cfg {posargs} + !cov: pytest -v --pyargs gala {toxinidir}/docs {posargs} + cov: pytest -v --pyargs gala {toxinidir}/docs --cov gala --cov-config={toxinidir}/setup.cfg {posargs} # Runs pip install -e . instead of building an sdist and installing usedevelop = True @@ -81,7 +81,7 @@ conda_deps = gsl commands = pip freeze - pytest --pyargs gala {toxinidir}/docs + pytest -v --pyargs gala {toxinidir}/docs [testenv:local_build_docs] changedir = docs From 0d26b79d913ae5c49433830fd636456c7838417c Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan Date: Thu, 15 Oct 2020 16:39:03 -0400 Subject: [PATCH 14/14] simpler way of customizing the pytest header [ci skip] --- gala/conftest.py | 15 ++++----------- setup.cfg | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/gala/conftest.py b/gala/conftest.py index 365dd9df9..ea498c45f 100644 --- a/gala/conftest.py +++ b/gala/conftest.py @@ -15,7 +15,7 @@ def pytest_configure(config): - config.option.astropy_header = False + config.option.astropy_header = True # Customize the following lines to add/remove entries from the list of # packages for which version numbers are displayed when running the tests. @@ -30,19 +30,12 @@ def pytest_configure(config): def pytest_report_header(config): from gala._cconfig import GSL_ENABLED - config.option.astropy_header = True - hdr = astropy_header(config) - config.option.astropy_header = False - - hdr += "\n" - if GSL_ENABLED: - hdr += " +++ Gala compiled with GSL +++" + hdr = " +++ Gala compiled with GSL +++" else: - hdr += " --- Gala compiled without GSL ---" + hdr = " --- Gala compiled without GSL ---" - hdr += "\n" - return hdr + return hdr + "\n" # Uncomment the last two lines in this block to treat all DeprecationWarnings as diff --git a/setup.cfg b/setup.cfg index 4f5983013..c271bf916 100644 --- a/setup.cfg +++ b/setup.cfg @@ -61,7 +61,7 @@ docs = [tool:pytest] testpaths = "gala" "docs" -astropy_header = false +astropy_header = true doctest_plus = enabled text_file_format = rst addopts = --doctest-rst