-
Notifications
You must be signed in to change notification settings - Fork 300
Closed
Labels
Good First IssueA good issue to take on if you're just getting started with Iris developmentA good issue to take on if you're just getting started with Iris developmentType: Bug
Description
🐛 Bug Report
If the scalar coord passed to iris.util.new_axis is already a dimension coordinate, an anonymous new dimension is created.
How To Reproduce
import iris
import iris.cube
print(iris.__version__)
cube = iris.cube.Cube(1)
coord = iris.coords.DimCoord(1, long_name="spam")
cube.add_aux_coord(coord)
new_cube = iris.util.new_axis(cube, coord)
new_new_cube = iris.util.new_axis(new_cube, coord)
for c in [cube, new_cube, new_new_cube]:
print(c)output:
3.2.dev0
unknown / (unknown) (scalar cube)
Scalar coordinates:
spam 1
unknown / (unknown) (spam: 1)
Dimension coordinates:
spam x
unknown / (unknown) (-- : 1; spam: 1)
Dimension coordinates:
spam - x
Expected behaviour
I think we should probably get an exception if our "spam" coord is already a dim coord. It might be as simple as adding dim_coords=False in the call to src_cube.coord here:
Lines 1116 to 1117 in ab1e699
| if scalar_coord is not None: | |
| scalar_coord = src_cube.coord(scalar_coord) |
Environment
- OS & Version: RHEL 7.9
- Iris Version: 3.2.dev0
Metadata
Metadata
Assignees
Labels
Good First IssueA good issue to take on if you're just getting started with Iris developmentA good issue to take on if you're just getting started with Iris developmentType: Bug