astropy / specutils

An Astropy coordinated package for astronomical spectroscopy. Maintainers: @rosteen @keflavich @eteq
http://specutils.readthedocs.io/en/latest/
166 stars 127 forks source link

Improve/Update Developer docs #1098

Closed kelle closed 10 months ago

kelle commented 10 months ago

I recently struggled a lot with getting the testing environoment setup. Basically, @cshanahan1 had to tell me exactly what to do and it was not described in the docs: https://specutils.readthedocs.io/en/latest/contributing.html#get-started

Something about pip install .'[test]' ?

Also, I think running tox runs all the whole test matrix. I decided to run tox -e py310-test since I'm using a Python 3.10 environment.

sbailey commented 10 months ago

Related: https://specutils.readthedocs.io/en/stable/contributing.html step 5 says to run

$ python setup.py test or py.test
$ tox

When running python setup.py test, it says

Note: running tests is no longer done using 'python setup.py test'. Instead
you will need to run:

    tox -e test
...

Running py.test says

ERROR: usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --doctest-rst
  inifile: /Users/sbailey/git/specutils/setup.cfg
  rootdir: /Users/sbailey/git/specutils

I succeeded in running tox -e test, and plain tox by itself also seems to work. Since I'm not entirely sure what the "right" instructions are, I'm commenting here in the ticket rather than contributing a PR with a specific documentation update.

kelle commented 10 months ago

I would also appreciate instructions on the best way to run one test module and not the whole suite. e.g., tox -e py310-test -- tests/test_loaders.py still runs all the tests.

kelle commented 10 months ago

Most of this was addressed in #1110.

I found one more thing and opened #1112 to address.

Regarding pytest vs tox: I followed the current dev instructions regarding conda and ended up with a python 12 environment. When I ran pytest, I got this error:

ImportError while loading conftest '/Users/kelle/Dropbox (Hunter College)/Science/Code/Python/specutils/specutils/conftest.py'.
specutils/__init__.py:23: in <module>
    from .spectra import *  # noqa
specutils/spectra/__init__.py:5: in <module>
    from .spectrum1d import *  # noqa
specutils/spectra/spectrum1d.py:15: in <module>
    from ndcube import NDCube
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/ndcube/__init__.py:13: in <module>
    from .ndcube import NDCube, NDCubeBase
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/ndcube/ndcube.py:779: in <module>
    class NDCube(NDCubeBase):
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/ndcube/visualization/descriptor.py:27: in __set_name__
    plotter = self._resolve_default_type(raise_error=False)
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/ndcube/visualization/descriptor.py:38: in _resolve_default_type
    from ndcube.visualization.mpl_plotter import MatplotlibPlotter
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/ndcube/visualization/mpl_plotter.py:4: in <module>
    import matplotlib.pyplot as plt
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/matplotlib/pyplot.py:66: in <module>
    from matplotlib.figure import Figure, FigureBase, figaspect
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/matplotlib/figure.py:43: in <module>
    from matplotlib import _blocking_input, backend_bases, _docstring, projections
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/matplotlib/projections/__init__.py:55: in <module>
    from .. import axes, _docstring
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/matplotlib/axes/__init__.py:2: in <module>
    from ._axes import *
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/matplotlib/axes/_axes.py:11: in <module>
    import matplotlib.category  # Register category unit converter as side effect.
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/matplotlib/category.py:14: in <module>
    import dateutil.parser
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/dateutil/parser/__init__.py:2: in <module>
    from ._parser import parse, parser, parserinfo, ParserError
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/dateutil/parser/_parser.py:50: in <module>
    from .. import tz
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/dateutil/tz/__init__.py:2: in <module>
    from .tz import *
/Users/kelle/miniforge3/envs/specutils-dev/lib/python3.12/site-packages/dateutil/tz/tz.py:37: in <module>
    EPOCH = datetime.datetime.utcfromtimestamp(0)
E   DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
E   Error calling __set_name__ on 'PlotterDescriptor' instance 'plotter' in 'NDCube'

But tox -e py312-test got the tests to run.

kelle commented 10 months ago

specifying python 3.11 fixed it. Updating my PR.

kelle commented 10 months ago

Closed via #1112 .