You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Geometry.export fails with AttributeError for a geometry without spline mappings #631
Geometry.export can only write spline (or NURBS) mappings, because it reads their space and control_points. It is meant to reject other geometries with ValueError('No mappings were found'), but this check only tests whether the dictionary of mappings is empty:
ifnot( self.mappings ):
raiseValueError('No mappings were found')
Geometry.from_topological_domain creates a dictionary with one None value per patch, so the check passes, and export fails later with an AttributeError. By then the HDF5 file has already been created, and it is left behind with partial content.
{'Omega': None}
Traceback (most recent call last):
...
File ".../psydac/cad/geometry.py", line 471, in export
space = mapping.space
^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'space'
The file geo.h5 exists after the error.
Proposed solution
Before creating the file, check that every patch has a spline mapping, and raise a ValueError listing the patches that do not:
missing= [nameforname, mappinginself.mappings.items()
ifnotisinstance(mapping, SplineMapping)]
ifmissing:
raiseValueError(f'Cannot export patches without a spline mapping: {missing}')
Since NurbsMapping is a subclass of SplineMapping, NURBS mappings are accepted.
Activity
Raise a ValueError when exporting a Geometry without spline mappings (f…