Skip to content

Commit

Permalink
Merge pull request #190 from dfm/windows-ci
Browse files Browse the repository at this point in the history
[WIP]: Trying to fix Windows CI
  • Loading branch information
adrn authored Oct 15, 2020
2 parents 4608bd2 + 0d26b79 commit 9c0c98a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 38 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/windows-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Windows-tests
on:
push:
branches:
- DISABLED
- main
pull_request:
branches:
- DISABLED
- main

jobs:
build:
Expand All @@ -21,17 +21,20 @@ 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 virtualenv==20.0.33 # 20.0.34 broken!
python -m pip install tox
- name: Run tests
shell: bash -l {0}
run: |
tox -e py38-test
43 changes: 23 additions & 20 deletions gala/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,36 @@

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 = True

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

if GSL_ENABLED:
hdr = " +++ Gala compiled with GSL +++"
else:
hdr = " --- Gala compiled without GSL ---"

return hdr + "\n"

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,
Expand Down
8 changes: 4 additions & 4 deletions gala/dynamics/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
12 changes: 5 additions & 7 deletions gala/dynamics/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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")
Expand Down
31 changes: 30 additions & 1 deletion gala/potential/frame/builtin/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9c0c98a

Please sign in to comment.