From 36f5786ebcc1c26bc403c5ad34ab9a2b05b99190 Mon Sep 17 00:00:00 2001 From: David Hassell Date: Tue, 20 Feb 2024 17:54:19 +0000 Subject: [PATCH] dev --- cfdm/field.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cfdm/field.py b/cfdm/field.py index 92ec2eb30..e16e02d90 100644 --- a/cfdm/field.py +++ b/cfdm/field.py @@ -2178,6 +2178,8 @@ def insert_dimension( (19, 73, 1, 96) >>> f.data.shape (19, 73, 1, 96) + >>> f.insert_dimension(None, 1).data.shape + (19, 1, 73, 1, 96) """ f = _inplace_enabled_define_and_cleanup(self) @@ -2185,11 +2187,11 @@ def insert_dimension( if axis is None: axis = f.set_construct(self._DomainAxis(1)) else: - domain_axis = f.domain_axes(todict=True).get(axis) - if domain_axis is None: - raise ValueError( - f"Can't insert non-existent domain axis: {axis}" - ) + axis, domain_axis = f.domain_axis( + axis, + item=True, + default=ValueError("Can't identify a unique axis to insert"), + ) if domain_axis.get_size() != 1: raise ValueError(