SWIFTSIM / SOAP

Spherical Overdensity Aperture Processor: MPI parallel Python code to compute properties of halos in SWIFT n-body simulations
3 stars 3 forks source link

Running SOAP not compatible with unyt 3.0.1 #52

Closed JegerBroxterman closed 9 months ago

JegerBroxterman commented 9 months ago

I have unyt 3.0.1 (the newest version)

When I git clone the master branch and run python3 -W error -m pytest aperture_properties.py

I get

[dc-brox1@login8a SOAP]$ python3 -W error -m pytest aperture_properties.py 
============================= test session starts ==============================
platform linux -- Python 3.9.1, pytest-7.4.0, pluggy-1.2.0
rootdir: /snap8/scratch/dp004/dc-brox1/SOAP_nov2023/SOAP
collected 1 item                                                               

aperture_properties.py F                                                 [100%]

=================================== FAILURES ===================================
___________________________ test_aperture_properties ___________________________

    def test_aperture_properties():
        """
        Unit test for the aperture property calculations.

        We generate 100 random "dummy" halos and feed them to
        ExclusiveSphereProperties::calculate() and
        InclusiveSphereProperties::calculate(). We check that the returned values
        are present, and have the right units, size and dtype
        """

        from dummy_halo_generator import DummyHaloGenerator

        # initialise the DummyHaloGenerator with a random seed
        dummy_halos = DummyHaloGenerator(3256)
        filter = RecentlyHeatedGasFilter(dummy_halos.get_cell_grid())
        stellar_age_calculator = StellarAgeCalculator(dummy_halos.get_cell_grid())
        cat_filter = CategoryFilter()

        pc_exclusive = ExclusiveSphereProperties(
            dummy_halos.get_cell_grid(), 50.0, filter, stellar_age_calculator, cat_filter
        )
        pc_inclusive = InclusiveSphereProperties(
            dummy_halos.get_cell_grid(), 50.0, filter, stellar_age_calculator, cat_filter
        )

        # generate 100 random halos
        for i in range(100):
            input_halo, data, _, _, _, particle_numbers = dummy_halos.get_random_halo(
                [1, 10, 100, 1000, 10000]
            )
            halo_result_template = {
                f"FOFSubhaloProperties/{PropertyTable.full_property_list['Ngas'][0]}": (
                    unyt.unyt_array(
                        particle_numbers["PartType0"],
                        dtype=PropertyTable.full_property_list["Ngas"][2],
                        units="dimensionless",
                    ),
                    "Dummy Ngas for filter",
                ),
                f"FOFSubhaloProperties/{PropertyTable.full_property_list['Ndm'][0]}": (
                    unyt.unyt_array(
                        particle_numbers["PartType1"],
                        dtype=PropertyTable.full_property_list["Ndm"][2],
                        units="dimensionless",
                    ),
                    "Dummy Ndm for filter",
                ),
                f"FOFSubhaloProperties/{PropertyTable.full_property_list['Nstar'][0]}": (
                    unyt.unyt_array(
                        particle_numbers["PartType4"],
                        dtype=PropertyTable.full_property_list["Nstar"][2],
                        units="dimensionless",
                    ),
                    "Dummy Nstar for filter",
                ),
                f"FOFSubhaloProperties/{PropertyTable.full_property_list['Nbh'][0]}": (
                    unyt.unyt_array(
                        particle_numbers["PartType5"],
                        dtype=PropertyTable.full_property_list["Nbh"][2],
                        units="dimensionless",
                    ),
                    "Dummy Nbh for filter",
                ),
            }

            for pc_type, pc_calc in [
                ("ExclusiveSphere", pc_exclusive),
                ("InclusiveSphere", pc_inclusive),
            ]:
                input_data = {}
                for ptype in pc_calc.particle_properties:
                    if ptype in data:
                        input_data[ptype] = {}
                        for dset in pc_calc.particle_properties[ptype]:
                            input_data[ptype][dset] = data[ptype][dset]
                input_halo_copy = input_halo.copy()
                input_data_copy = input_data.copy()
                halo_result = dict(halo_result_template)
>               pc_calc.calculate(input_halo, 0.0 * unyt.kpc, input_data, halo_result)

aperture_properties.py:1143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
aperture_properties.py:956: in calculate
    part_props = ApertureParticleData(
aperture_properties.py:47: in __init__
    self.compute_basics()
aperture_properties.py:73: in compute_basics
    self.mass = unyt.array.uconcatenate(mass)
/cosma/home/dp004/dc-brox1/.local/lib/python3.9/site-packages/unyt/array.py:2291: in uconcatenate
    warn_deprecated(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'unyt.uconcatenate'

    def warn_deprecated(
        name,
        /,
        *,
        stacklevel: int = 3,
        replacement: Optional[str] = None,
        since_version: str,
    ) -> None:
        msg = (
            f"{name} is deprecated and will be removed in a future version\n"
            f"Instead, {replacement}\n"
            f"(deprecated since unyt v{since_version})"
        )
>       warnings.warn(
            msg,
            category=DeprecationWarning,
            stacklevel=stacklevel,
        )
E       DeprecationWarning: unyt.uconcatenate is deprecated and will be removed in a future version
E       Instead, use numpy.concatenate
E       (deprecated since unyt v3.0)

/cosma/home/dp004/dc-brox1/.local/lib/python3.9/site-packages/unyt/_deprecation.py:18: DeprecationWarning
=========================== short test summary info ============================
FAILED aperture_properties.py::test_aperture_properties - DeprecationWarning: unyt.uconcatenate is deprecated and will be removed in ...
============================== 1 failed in 2.42s ==========
MatthieuSchaller commented 9 months ago

@VictorForouhar is that similar to what you saw with the pipeline?

VictorForouhar commented 9 months ago

The problem I had involved the calculation of inertia tensors, so I have not seen this before.