Skip to content

LPT broken for new numpy #94

@brandonwkerns

Description

@brandonwkerns

I created a new Conda environment based on the environment.yml provided in the repo. The new version of Numpy (2.4.3) is installed, and LPT breaks. Output with the error message:

. . .
N = 11 nodes left to check.
N = 8 nodes left to check.
N = 7 nodes left to check.
N = 4 nodes left to check.
N = 2 nodes left to check.
Will split groups in to separate, broken up LPTs.
--> LPT group 1 of 13
----> Found 1 LPT system.
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 4429.98it/s]
multiprocessing.pool.RemoteTraceback: 
"""
TypeError: only 0-dimensional arrays can be converted to Python scalars

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/glade/work/bkerns/conda-envs/ai_emulator_model_ar_verification/lib/python3.11/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/glade/work/bkerns/conda-envs/ai_emulator_model_ar_verification/lib/python3.11/multiprocessing/pool.py", line 51, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/glade/u/home/bkerns/projects/ai_emulator_model_ar_verification/code/lpt-python-public/lpt/helpers.py", line 1417, in add_fields_to_a_TC
    TC_this['area'][tt] += OBJ['area']
    ~~~~~~~~~~~~~~~^^^^
ValueError: setting an array element with a sequence.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/glade/u/home/bkerns/projects/ai_emulator_model_ar_verification/code/lpt-python-public/ar/lpt_run.lpt.arlid.py", line 265, in <module>
    lpt_driver(dataset,plotting,output,lpo_options,lpt_options, merge_split_options, mjo_id_options, sys.argv)
  File "/glade/u/home/bkerns/projects/ai_emulator_model_ar_verification/code/lpt-python-public/lpt/lpt_driver.py", line 145, in lpt_driver
    TIMECLUSTERS = lpt.helpers.calc_lpt_properties_break_up_merge_split(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/glade/u/home/bkerns/projects/ai_emulator_model_ar_verification/code/lpt-python-public/lpt/helpers.py", line 1758, in calc_lpt_properties_break_up_merge_split
    fields = p.starmap(
             ^^^^^^^^^^
  File "/glade/work/bkerns/conda-envs/ai_emulator_model_ar_verification/lib/python3.11/multiprocessing/pool.py", line 375, in starmap
    return self._map_async(func, iterable, starmapstar, chunksize).get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/glade/work/bkerns/conda-envs/ai_emulator_model_ar_verification/lib/python3.11/multiprocessing/pool.py", line 774, in get
    raise self._value
ValueError: setting an array element with a sequence.

When I run the same case on another machine, where the Python environment has Numpy 1.24.3, I do not get the error.

Google search suggests that the error occurs in newer versions of Numpy, because "ragged arrays" are deprecated. It seems Numpy is now more strict about array shapes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions