Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
try hacking together configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
  • Loading branch information
nstarman committed Sep 12, 2021
1 parent cda4f22 commit 7665361
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 20 deletions.
6 changes: 4 additions & 2 deletions discO/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
# IMPORTS

# keep this content at the top. (sets the __version__)
from ._astropy_init import * # noqa: F401, F403 # isort:skip
from ._astropy_init import __version__ # noqa: F401 # isort:skip
from ._astropy_init import * # noqa: F401, F403 # isort: skip
from ._astropy_init import __version__ # noqa: F401 # isort: skip

from . import setup_package # noqa: F401 # isort: skip

# LOCAL
from . import core, data, plugin
Expand Down
34 changes: 25 additions & 9 deletions discO/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# IMPORTS

# STDLIB
import configparser
import importlib
import os

# THIRD PARTY
Expand All @@ -22,7 +24,8 @@

try:
# THIRD PARTY
from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
from pytest_astropy_header.display import PYTEST_HEADER_MODULES # noqa: F401
from pytest_astropy_header.display import TESTED_VERSIONS

ASTROPY_HEADER = True
except ImportError:
Expand Down Expand Up @@ -55,9 +58,28 @@
if not HAS_GALPY:
collect_ignore.append("plugin/galpy/")
else:
# THIRD PARTY
import galpy

importlib.reload(galpy)

# THIRD PARTY
from galpy.util import config as galpy_config
galpy_config.__config__["astropy"]["astropy-units"] = "True"
galpy_config.__config__["astropy"]["astropy-coords"] = "True"

# configuration
galpy_config._APY_LOADED = True
galpy_config.__config__.set("astropy", "astropy-units", "True")
galpy_config.__config__.set("astropy", "astropy-coords", "True")

if ".tmp" in os.getcwd():

# write config and read it
cfilename = os.path.join(os.path.expanduser("~"), ".galpyrc")
galpy_config.write_config(cfilename, galpy_config.__config__)

__config__ = configparser.ConfigParser()
__config__.read(cfilename)
galpy_config.__config__ = __config__


# ------------------------------------------------------
Expand All @@ -75,12 +97,6 @@ def pytest_configure(config):

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"

# LOCAL
from . import __version__

Expand Down
6 changes: 1 addition & 5 deletions discO/plugin/galpy/tests/test_residual.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
from discO.plugin.galpy.wrapper import GalpyPotentialWrapper
from discO.utils import vectorfield

##############################################################################
# PYTEST


##############################################################################
# TESTS
##############################################################################
Expand All @@ -42,7 +38,7 @@ def setup_class(cls):

# TODO!! actual potential that properly evaluates
cls.original_potential = gpot.NFWPotential(amp=2e12 * u.solMass)
cls.original_potential.turn_physical_on(ro=8 * u.kpc, vo=220 * u.km / u.s)
gpot.turn_physical_on(cls.original_potential, ro=8 * u.kpc, vo=220 * u.km / u.s)

cls.klass = cls.obj

Expand Down
15 changes: 11 additions & 4 deletions discO/setup_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

from __future__ import absolute_import

# STDLIB
import importlib

__all__ = ["HAS_AGAMA", "HAS_GALA", "HAS_GALPY", "HAS_TQDM"]


Expand Down Expand Up @@ -48,12 +51,16 @@
else:
HAS_GALPY = True

# TODO better way of ensuring unit!
importlib.reload(galpy)

# THIRD PARTY
from galpy.util.config import __config__
from galpy.util import config as galpy_config

__config__.set("astropy", "astropy-units", "True")
__config__.set("astropy", "astropy-coords", "True")
# force configuration
galpy_config._APY_LOADED = True
galpy_config.__config__.set("astropy", "astropy-units", "True")
galpy_config.__config__.set("astropy", "astropy-coords", "True")
galpy_config.default_configuration["astropy"]["astropy-units"] = True

# /try

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ packages = find:
python_requires = >=3.8
setup_requires = setuptools_scm
install_requires =
extension_helpers
astropy >= 4.3
numpy >= 1.17
PyYAML
Expand Down

0 comments on commit 7665361

Please sign in to comment.