Skip to content

Commit

Permalink
add vald shortlist parsing as well as handling for wavelength in vacu…
Browse files Browse the repository at this point in the history
…um/air and nm/aa (#386)

* add shortlist parsing and handling for wavelength in vacuum/air and nm/AA

* fix broken tests

* add support for stellar linelists

* add tests

* cleanup

* add example notebook with documentation

* improve documentation

* see if pathlib breaks tests

* change os to pathlib

* change paths to strings like os output

* fix vald test bug, change regex pattern to constant naming convention

* fix tests

* remove VALD_URL

* remove os import

* put vald wavelength column handling in external function

* make DATA_DIR_PATH constant in conftest.py

* continue propagating data_dir
  • Loading branch information
jvshields authored Dec 11, 2023
1 parent de795f6 commit d5853ba
Show file tree
Hide file tree
Showing 6 changed files with 1,211 additions and 214 deletions.
34 changes: 18 additions & 16 deletions carsus/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

import os
from pathlib import Path

from astropy.version import version as astropy_version

Expand Down Expand Up @@ -44,7 +44,7 @@ def pytest_configure(config):

from . import __version__

packagename = os.path.basename(os.path.dirname(__file__))
packagename = Path(__file__).parent.name
TESTED_VERSIONS[packagename] = __version__


Expand All @@ -67,6 +67,8 @@ def pytest_configure(config):
from sqlalchemy.orm import Session
from carsus import init_db

DATA_DIR_PATH = Path(__file__).parent / "tests" / "data"


def pytest_addoption(parser):
parser.addoption(
Expand Down Expand Up @@ -101,18 +103,13 @@ def memory_session():
return session


@pytest.fixture(scope="session")
def data_dir():
return os.path.join(os.path.dirname(__file__), "tests", "data")


@pytest.fixture(scope="session")
def test_db_fname(request):
test_db_fname = request.config.getoption("--test-db")
if test_db_fname is None:
pytest.skip("--testing database was not specified")
else:
return os.path.expandvars(os.path.expanduser(test_db_fname))
return str(Path(test_db_fname).expanduser().resolve())


@pytest.fixture(scope="session")
Expand All @@ -121,25 +118,30 @@ def test_db_url(test_db_fname):


@pytest.fixture(scope="session")
def gfall_fname(data_dir):
return os.path.join(data_dir, "gftest.all") # Be III, B IV, N VI
def gfall_fname():
return str(DATA_DIR_PATH / "gftest.all") # Be III, B IV, N VI


@pytest.fixture(scope="session")
def gfall_http(data_dir):
def gfall_http():
url = "https://github.com/tardis-sn/carsus/"
url += "master/carsus/tests/data/gftest.all"
return url


@pytest.fixture(scope="session")
def vald_fname(data_dir):
return os.path.join(data_dir, "valdtest.dat")
def vald_fname():
return str(DATA_DIR_PATH / "valdtest.dat")


@pytest.fixture(scope="session")
def vald_short_form_stellar_fname():
return str(DATA_DIR_PATH / "vald_shortlist_test.dat")


@pytest.fixture(scope="session")
def nndc_dirname(data_dir):
return os.path.join(data_dir, "nndc") # Mn-52, Ni-56
def nndc_dirname():
return str(DATA_DIR_PATH / "nndc") # Mn-52, Ni-56


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -179,4 +181,4 @@ def refdata_path(request):
if refdata_path is None:
pytest.skip("--refdata folder path was not specified")
else:
return os.path.expandvars(os.path.expanduser(refdata_path))
return str(Path(refdata_path).expanduser().resolve())
Loading

0 comments on commit d5853ba

Please sign in to comment.