|
23 | 23 | # importing anything else. |
24 | 24 | import iris.tests as tests |
25 | 25 |
|
| 26 | +from itertools import permutations |
| 27 | + |
26 | 28 | import biggus |
27 | 29 | import numpy as np |
28 | 30 | import numpy.ma as ma |
@@ -418,16 +420,16 @@ def setUp(self): |
418 | 420 | ''' |
419 | 421 | setup a 4D iris cube, each dimension is length 1. |
420 | 422 | The dimensions are; |
421 | | - dim1: height |
422 | | - dim2: time |
423 | | - dim3: longitude |
424 | | - dim4: latitude |
| 423 | + dim1: time |
| 424 | + dim2: height |
| 425 | + dim3: latitude |
| 426 | + dim4: longitude |
425 | 427 | ''' |
426 | 428 | self.cube = iris.cube.Cube(np.array([[[[8.]]]])) |
427 | | - self.cube.add_dim_coord(iris.coords.DimCoord([0], "height"), [0]) |
428 | | - self.cube.add_dim_coord(iris.coords.DimCoord([0], "time"), [1]) |
429 | | - self.cube.add_dim_coord(iris.coords.DimCoord([0], "longitude"), [2]) |
430 | | - self.cube.add_dim_coord(iris.coords.DimCoord([0], "latitude"), [3]) |
| 429 | + self.cube.add_dim_coord(iris.coords.DimCoord([0], "time"), [0]) |
| 430 | + self.cube.add_dim_coord(iris.coords.DimCoord([0], "height"), [1]) |
| 431 | + self.cube.add_dim_coord(iris.coords.DimCoord([0], "latitude"), [2]) |
| 432 | + self.cube.add_dim_coord(iris.coords.DimCoord([0], "longitude"), [3]) |
431 | 433 |
|
432 | 434 | @staticmethod |
433 | 435 | def expected_cube_setup(dim1name, dim2name, dim3name): |
@@ -478,71 +480,11 @@ def check_order(self, dim1, dim2, dim3, dim_to_remove): |
478 | 480 | sliced_cube = next(self.cube.slices([dim1, dim2, dim3])) |
479 | 481 | sliced_cube.remove_coord(dim_to_remove) |
480 | 482 | expected_cube = self.expected_cube_setup(dim1, dim2, dim3) |
481 | | - return self.assertEqual(sliced_cube, expected_cube) |
482 | | - |
483 | | - |
484 | | - def test_height_long_lat(self): |
485 | | - ''' |
486 | | - tests the slicing in this order: |
487 | | - height |
488 | | - longitude |
489 | | - latitude |
490 | | - ''' |
491 | | - self.check_order("height", "longitude", "latitude", "time") |
492 | | - |
493 | | - def test_long_height_lat(self): |
494 | | - ''' |
495 | | - tests the slicing in this order: |
496 | | - longitude |
497 | | - height |
498 | | - latitude |
499 | | - ''' |
500 | | - self.check_order("longitude", "height", "latitude", "time") |
501 | | - |
502 | | - def test_time_height_lat(self): |
503 | | - ''' |
504 | | - tests the slicing in this order: |
505 | | - time |
506 | | - height |
507 | | - latitude |
508 | | - ''' |
509 | | - self.check_order("time", "height", "latitude", "longitude") |
| 483 | + self.assertEqual(sliced_cube, expected_cube) |
510 | 484 |
|
511 | | - def test_time_height_long(self): |
512 | | - ''' |
513 | | - tests the slicing in this order: |
514 | | - time |
515 | | - height |
516 | | - longitude |
517 | | - ''' |
518 | | - self.check_order("time", "height", "longitude", "latitude") |
519 | | - |
520 | | - def test_long_lat_height(self): |
521 | | - ''' |
522 | | - tests the slicing in this order: |
523 | | - longitude |
524 | | - latitude |
525 | | - height |
526 | | - ''' |
527 | | - self.check_order("longitude", "latitude", "height", "time") |
528 | | - |
529 | | - def test_lat_height_time(self): |
530 | | - ''' |
531 | | - tests the slicing in this order: |
532 | | - latitude |
533 | | - height |
534 | | - time |
535 | | - ''' |
536 | | - self.check_order("latitude", "height", "time", "longitude") |
537 | | - |
538 | | - def test_long_height_time(self): |
539 | | - ''' |
540 | | - tests the slicing in this order: |
541 | | - longitude |
542 | | - height |
543 | | - time |
544 | | - ''' |
545 | | - self.check_order("longitude", "height", "time", "latitude") |
| 485 | + def test_all_permutations(self): |
| 486 | + for perm in permutations(["time", "height", "latitude", "longitude"]): |
| 487 | + self.check_order(*perm) |
546 | 488 |
|
547 | 489 |
|
548 | 490 | @tests.skip_data |
|
0 commit comments