-
Notifications
You must be signed in to change notification settings - Fork 301
Use of tuples for dimensions in coord to dim mapping #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,39 @@ def test_remove_coord(self): | |
| self.cube.remove_coord('y') | ||
| self.assertEqual(self.cube.coords(), []) | ||
|
|
||
| def test_immutable_dimcoord_dims(self): | ||
| # Add DimCoord to dimension 1 | ||
| dims = [1] | ||
| self.cube.add_dim_coord(self.x, dims) | ||
| self.assertEqual(self.cube.coord_dims(self.x), (1,)) | ||
|
|
||
| # Change dims object | ||
| dims[0] = 0 | ||
| # Check the cube is unchanged | ||
| self.assertEqual(self.cube.coord_dims(self.x), (1,)) | ||
|
|
||
| # Check coord_dims cannot be changed | ||
| dims = self.cube.coord_dims(self.x) | ||
| with self.assertRaises(TypeError): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would have been fine to simply do some type checking here (i.e. assert it is a tuple).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Arguably the current check is better - it's testing the desired behaviour, and could conceivably survive a switch to an alternative immutable type. |
||
| dims[0] = 0 | ||
|
|
||
| def test_immutable_auxcoord_dims(self): | ||
| # Add AuxCoord to dimensions (0, 1) | ||
| dims = [0, 1] | ||
| self.cube.add_aux_coord(self.xy, dims) | ||
| self.assertEqual(self.cube.coord_dims(self.xy), (0, 1)) | ||
|
|
||
| # Change dims object | ||
| dims[0] = 1 | ||
| dims[1] = 0 | ||
| # Check the cube is unchanged | ||
| self.assertEqual(self.cube.coord_dims(self.xy), (0, 1)) | ||
|
|
||
| # Check coord_dims cannot be changed | ||
| dims = self.cube.coord_dims(self.xy) | ||
| with self.assertRaises(TypeError): | ||
| dims[0] = 1 | ||
|
|
||
|
|
||
| class TestStockCubeStringRepresentations(tests.IrisTest): | ||
| def setUp(self): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stuff is already handled in the load API PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry already merged. Would you mind re-basing the load api PR and handling this conflict (and I will then merge).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rolls eyes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pelson Done.