def setup_class(self): self.datadir = 'data' test_vos_path = get_pkg_data_path(self.datadir) + os.sep # Convert to a proper file:// URL--on *NIXen this is not necessary but # Windows paths will blow up if we don't do this. test_vos_path = '/'.join(test_vos_path.split(os.sep)) if not test_vos_path.startswith('/'): test_vos_path = '/' + test_vos_path cs_conf.vos_baseurl = 'file://' + test_vos_path self.r = inspect.ConeSearchResults()
def test_skip_hidden(): path = data.get_pkg_data_path('data') for root, dirs, files in os.walk(path): assert '.hidden_file.txt' in files assert 'local.dat' in files # break after the first level since the data dir contains some other # subdirectories that don't have these files break for root, dirs, files in misc.walk_skip_hidden(path): assert '.hidden_file.txt' not in files assert 'local.dat' in files break
def _iraf_decode(irafdir): """Decode IRAF dir shortcut.""" from .config import conf # Put here to avoid circular import error global _irafconvdata irafdir = irafdir.lower() if irafdir == 'synphot': # Local data path = get_pkg_data_path('data') elif irafdir == 'crrefer': # Root dir path = conf.rootdir else: # Read from file # Avoid repeated I/O but do not load if not used if _irafconvdata is None: _irafconvdata = ascii.read(irafconvert(conf.irafshortcutfile)) mask = _irafconvdata['IRAFNAME'] == irafdir if not np.any(mask): raise KeyError(f'IRAF shortcut {irafdir} not found in ' f'{conf.irafshortcutfile}.') relpath = os.path.normpath(_irafconvdata['RELPATH'][mask][0]) path = os.path.join(conf.rootdir, relpath) return path
def test_reader_casa(): from dask import array as dask_array data = read_spectral_cube(get_pkg_data_path('data/cube_3d.image')) assert isinstance(data['STOKES I'], dask_array.Array) assert data.shape == (2, 3, 4)
def test_identifier_casa(): assert is_spectral_cube(get_pkg_data_path('data/cube_3d.image'))
# Licensed under a 3-clause BSD style license - see LICENSE.rst # STDLIB import pathlib import sys from typing import Optional, Union # LOCAL from astropy.utils.data import get_pkg_data_path from astropy.utils.decorators import deprecated from astropy.utils.state import ScienceState from .core import Cosmology _COSMOLOGY_DATA_DIR = pathlib.Path( get_pkg_data_path("cosmology", "data", package="astropy")) available = tuple(sorted(p.stem for p in _COSMOLOGY_DATA_DIR.glob("*.ecsv"))) __all__ = ["available", "default_cosmology"] + list(available) __doctest_requires__ = {"*": ["scipy"]} def __getattr__(name): """Make specific realizations from data files with lazy import from `PEP 562 <https://www.python.org/dev/peps/pep-0562/>`_. Raises ------ AttributeError If "name" is not in :mod:`astropy.cosmology.realizations`
def setup_class(self): self.datadir = get_pkg_data_path('data')