Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhassell committed Feb 20, 2024
1 parent 5d991a5 commit 36f5786
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cfdm/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2178,18 +2178,20 @@ 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)

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(
Expand Down

0 comments on commit 36f5786

Please sign in to comment.