-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
IMAS-Python version: 2.1.0
System: Mac M1
Python: 3.10.17
I am getting the following error when reading an IMAS database (DD version 3.24.0 via the netcdf backend) and converting the wall IDS to DD version 4.1.0:
Traceback (most recent call last):
File "/Users/timothynunn/eqdsk/imas_test.py", line 39, in <module>
wall_ids = convert_ids(db.get("wall"), NEW_DD_VERSION)
File "/Users/timothynunn/eqdsk/.venv/lib/python3.10/site-packages/imas/ids_convert.py", line 513, in convert_ids
_copy_structure(toplevel, target, deepcopy, rename_map)
File "/Users/timothynunn/eqdsk/.venv/lib/python3.10/site-packages/imas/ids_convert.py", line 634, in _copy_structure
_copy_structure(item[i], target_item[i], deepcopy, rename_map, callback)
File "/Users/timothynunn/eqdsk/.venv/lib/python3.10/site-packages/imas/ids_convert.py", line 636, in _copy_structure
_copy_structure(item, target_item, deepcopy, rename_map, callback)
File "/Users/timothynunn/eqdsk/.venv/lib/python3.10/site-packages/imas/ids_convert.py", line 634, in _copy_structure
_copy_structure(item[i], target_item[i], deepcopy, rename_map, callback)
File "/Users/timothynunn/eqdsk/.venv/lib/python3.10/site-packages/imas/ids_convert.py", line 624, in _copy_structure
new_items = rename_map.type_change[path](item, target_item)
File "/Users/timothynunn/eqdsk/.venv/lib/python3.10/site-packages/imas/ids_convert.py", line 843, in _repeat_first_point_conditional
closed = bool(closed_node)
TypeError: __bool__ should return bool, returned numpy.bool
I have created the following small script to showcase how to replicate the error:
import numpy as np
from imas import DBEntry, IDSFactory, convert_ids
ORIGINAL_DD_VERSION = "3.42.0"
NEW_DD_VERSION = "4.1.0"
with DBEntry("test.nc", "w", dd_version=ORIGINAL_DD_VERSION) as db:
# Create the IDS factor with a fixed version of the DD (4.1.0)
# because the following code uses that API
ids_factory = IDSFactory(version=NEW_DD_VERSION)
limiter_ids = ids_factory.wall()
description_2d = limiter_ids.description_2d
description_2d.resize(1)
description_2d = description_2d[0]
unit = description_2d.limiter.unit
unit.resize(1)
unit = unit[0]
outline = unit.outline
limiter_ids.ids_properties.homogeneous_time = 1
outline.r = np.array([0.0, 0.0, 1.0, 1.0])
outline.z = np.array([0.0, 1.0, 1.0, 0.0])
# Convert the IDS back to 3.42.0 before writing because this is the version
# of the DBEntry.
db.put(convert_ids(limiter_ids, ORIGINAL_DD_VERSION))
with DBEntry("test.nc", "r", dd_version=ORIGINAL_DD_VERSION) as db:
print(f"=== Opening database with DD version {ORIGINAL_DD_VERSION} ===")
wall_ids = db.get("wall")
limiter = wall_ids.description_2d[0].limiter.unit[0].outline
print(f"Limiter r = {limiter.r.value}")
print(f"Limiter z = {limiter.z.value}")
with DBEntry("test.nc", "r", dd_version=ORIGINAL_DD_VERSION) as db:
print(
f"=== Opening database with DD version {ORIGINAL_DD_VERSION}, converting to {NEW_DD_VERSION} ==="
)
# the error occurs at this line, when trying to convert the 3.42.0 wall IDS to 4.1.0
wall_ids = convert_ids(db.get("wall"), NEW_DD_VERSION)
limiter = wall_ids.description_2d[0].limiter.unit[0].outline
print(f"Limiter r = {limiter.r.value}")
print(f"Limiter z = {limiter.z.value}")Metadata
Metadata
Assignees
Labels
No labels