Skip to content
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

test_non_comoving fails #49

Closed
kyleaoman opened this issue Feb 19, 2024 · 1 comment
Closed

test_non_comoving fails #49

kyleaoman opened this issue Feb 19, 2024 · 1 comment

Comments

@kyleaoman
Copy link

I attempted to run the test suite locally and got the following failure:

_____________________________________________________________ test_non_comoving _____________________________________________________________

show = False

    def test_non_comoving(show=False):
        import paicos as pa
        import numpy as np
>       snap = pa.Snapshot(pa.data_dir, 7,
                           basename='small_non_comoving')

tests/non-comoving/test_non_comoving.py:5: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
paicos/readers/arepo_snap.py:85: in __init__
    super().__init__(basedir=basedir, snapnum=snapnum, basename=basename,
paicos/readers/paicos_readers.py:121: in __init__
    self.get_units_and_other_parameters()
paicos/readers/paicos_readers.py:190: in get_units_and_other_parameters
    arepo_time = u.def_unit(
../../.miniconda3/envs/paicos_review/lib/python3.11/site-packages/astropy/units/core.py:2618: in def_unit
    result = Unit(s, represents, namespace=namespace, doc=doc, format=format)
../../.miniconda3/envs/paicos_review/lib/python3.11/site-packages/astropy/units/core.py:2077: in __call__
    return super().__call__(
../../.miniconda3/envs/paicos_review/lib/python3.11/site-packages/astropy/units/core.py:2235: in __init__
    NamedUnit.__init__(self, st, namespace=namespace, doc=doc, format=format)
../../.miniconda3/envs/paicos_review/lib/python3.11/site-packages/astropy/units/core.py:1799: in __init__
    self._inject(namespace)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = Unit("arepo_time")
namespace = {'Histogram2DReader': <class 'paicos.readers.paicos_readers.Histogram2DReader'>, 'ImageCreator': <class 'paicos.image_...s 'paicos.readers.paicos_readers.ImageReader'>, 'LambdaCDM': <class 'astropy.cosmology.flrw.lambdacdm.LambdaCDM'>, ...}

    def _inject(self, namespace=None):
        """
        Injects the unit, and all of its aliases, in the given
        namespace dictionary.
        """
        if namespace is None:
            return
    
        # Loop through all of the names first, to ensure all of them
        # are new, then add them all as a single "transaction" below.
        for name in self._names:
            if name in namespace and self != namespace[name]:
>               raise ValueError(
                    f"Object with name {name!r} already exists in "
                    f"given namespace ({namespace[name]!r})."
                )
E               ValueError: Object with name 'arepo_time' already exists in given namespace (Unit("arepo_time")).

../../.miniconda3/envs/paicos_review/lib/python3.11/site-packages/astropy/units/core.py:1880: ValueError
@tberlok
Copy link
Owner

tberlok commented Mar 8, 2024

I have explained in some details why it fails here: #59

The problem here is that pytest uses one single Python session to run all the tests
when you do pytest at the base directory (this is why I introduced the make checks command).
I have updated the error message that you get when loading several snapshots with different unit systems,
so that the difficult to understand and expected astropy error message is explained.

You can check that all the tests work like this (one python session for each set of tests):

pytest tests/comoving
pytest tests/non-comoving
pytest tests/general
pytest tests/cuda-gpu

This should hopefully work.

@tberlok tberlok closed this as completed Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants