Skip to content

Set DATAPATH for tests #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zonca opened this issue Nov 1, 2018 · 3 comments
Open

Set DATAPATH for tests #504

zonca opened this issue Nov 1, 2018 · 3 comments
Labels
Good first issue Relatively small patch that doesn't require an in-depth understanding of healpy

Comments

@zonca
Copy link
Member

zonca commented Nov 1, 2018

Set DATAPATH for tests as an easily accessible variable somewhere, so it doesn't have to be re-defined in all the tests.

Originally posted by @DanielLenz in #489

@DanielLenz DanielLenz added the Good first issue Relatively small patch that doesn't require an in-depth understanding of healpy label Nov 2, 2018
@DanielLenz
Copy link
Contributor

DanielLenz commented Nov 2, 2018

We could do something like:

E.g. in healpy/test/helpers.py

from pathlib import PATH

DATAPATH = PATH(__file__).parent.joinpath("data/")

and later

from .helpers import DATAPATH
d = fits.open(DATAPATH.joinpath('file.fits'))

@DanielLenz
Copy link
Contributor

I've implemented this on https://github.com/DanielLenz/healpy/tree/datapath, but decided to go with the future-oriented (Python >= 3.4)pathlib module. Unfortunately, this won't work with Python 2.

We could simply stick to os.path.join(BASEPATH, filename) instead of BASEPATH.joinpath(filename) for now, of course, and re-visit this once we decide to drop Python 2 support.

@zonca
Copy link
Member Author

zonca commented Feb 9, 2019

we can also consider http://docs.astropy.org/en/stable/api/astropy.utils.data.get_pkg_data_filename.html

we already use it to download pixel weights on the fly

pixel_weights_filename = data.get_pkg_data_filename(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Relatively small patch that doesn't require an in-depth understanding of healpy
Projects
None yet
Development

No branches or pull requests

2 participants