AffineTransformedCoordinateSystem has ndarray fields (_transfThisToWorld, _transfWorldToThis) but inherits the base CoordinateSystem.asDict, which calls attrsAsDict with no eqs. The default-equality check then evaluates default == val on an ndarray and raises:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
This is masked in normal use only because every affine system today is isAutogenerated=True and is swapped for a PlaceholderCoordinateSystem in CoordinateSystems.asList before serialization. Any non-autogenerated affine system — e.g. an addon adding a custom template space, or a future transforms panel — makes Session.saveToUnpackedDir raise, i.e. the session becomes unsaveable.
Repro (headless):
import numpy as np
from NaviNIBS.Navigator.Model.Session import Session
from NaviNIBS.Navigator.Model.CoordinateSystems.Affine import AffineTransformedCoordinateSystem
ses = Session.createNew(filepath='/tmp/x.navinibsdir', unpackedSessionDir='/tmp/x.navinibsdir')
ses.coordinateSystems.addItem(AffineTransformedCoordinateSystem(key='X', transfThisToWorld=np.eye(4)))
ses.saveToUnpackedDir() # ValueError
Suggested fix: override asDict / fromDict on AffineTransformedCoordinateSystem using attrsWithNumpyAsDict / attrsWithNumpyFromDict with npFields=['transfThisToWorld', 'transfWorldToThis'], as other ndarray-bearing model classes do (e.g. Fiducial). NonlinearTransformedCoordinateSystem holds filepaths rather than arrays, so it looks unaffected.
Found while writing tests for the coordinate-system change-handler fix (see linked PR).
AffineTransformedCoordinateSystemhas ndarray fields (_transfThisToWorld,_transfWorldToThis) but inherits the baseCoordinateSystem.asDict, which callsattrsAsDictwith noeqs. The default-equality check then evaluatesdefault == valon an ndarray and raises:This is masked in normal use only because every affine system today is
isAutogenerated=Trueand is swapped for aPlaceholderCoordinateSysteminCoordinateSystems.asListbefore serialization. Any non-autogenerated affine system — e.g. an addon adding a custom template space, or a future transforms panel — makesSession.saveToUnpackedDirraise, i.e. the session becomes unsaveable.Repro (headless):
Suggested fix: override
asDict/fromDictonAffineTransformedCoordinateSystemusingattrsWithNumpyAsDict/attrsWithNumpyFromDictwithnpFields=['transfThisToWorld', 'transfWorldToThis'], as other ndarray-bearing model classes do (e.g.Fiducial).NonlinearTransformedCoordinateSystemholds filepaths rather than arrays, so it looks unaffected.Found while writing tests for the coordinate-system change-handler fix (see linked PR).