MetOffice / CATNIP

Climate Analysis Tool: Now In Python
Other
5 stars 2 forks source link

Feature test compare i107 #108

Closed gredmond-mo closed 4 years ago

gredmond-mo commented 4 years ago

Unit tests added. Note the comment on https://github.com/MetOffice/CATNIP/issues/107 regarding future development for this function. Tests run successfully.

`test_common_timeperiod (main.TestUtils) ... ok test_compare_coords (main.TestUtils) ... ok test_compare_cubes (main.TestUtils) ... ok test_convert_from_um_stamp (main.TestUtils) ... ok test_convert_to_um_stamp (main.TestUtils) ... ok test_date_chunks (main.TestUtils) ... ok test_get_date_range (main.TestUtils) Tests for get_date_range function ... ok test_sort_cube (main.TestUtils) ... ok test_um_file_list (main.TestUtils) ... ok test_umstash_2_pystash (main.TestUtils) ... ok


Ran 10 tests in 0.937s

OK`

Only thing to note is a very irritating failure in the compare_cubes doctest, it seems that the order the coords are read in varies, therefore the doctest sometimes passes and it sometimes fails (as it is expecting the output printed to screen in a certain order). For the future consider forcing the coords that are loop through to be alphabetised?

zmaalick commented 4 years ago

Unit tests added. Note the comment on #107 regarding future development for this function. Tests run successfully.

`test_common_timeperiod (main.TestUtils) ... ok test_compare_coords (main.TestUtils) ... ok test_compare_cubes (main.TestUtils) ... ok test_convert_from_um_stamp (main.TestUtils) ... ok test_convert_to_um_stamp (main.TestUtils) ... ok test_date_chunks (main.TestUtils) ... ok test_get_date_range (main.TestUtils) Tests for get_date_range function ... ok test_sort_cube (main.TestUtils) ... ok test_um_file_list (main.TestUtils) ... ok test_umstash_2_pystash (main.TestUtils) ... ok

Ran 10 tests in 0.937s

OK`

Only thing to note is a very irritating failure in the compare_cubes doctest, it seems that the order the coords are read in varies, therefore the doctest sometimes passes and it sometimes fails (as it is expecting the output printed to screen in a certain order). For the future consider forcing the coords that are loop through to be alphabetised?

I have put in discussion point about this doctest failure ..

gredmond-mo commented 4 years ago
  1. delete the "pass" at the end of the function Complete
  2. We need to change these both function in a way that they could return something .. and change the unittests accordingly.. Discussed offline, will keep as it is for now but will discuss again in CATNIP meeting
  3. In the beginning of the functions we need to add exception of cube type .. (please check other functions) Added for compare_cubes but not compare_coords, this is because compare_coords is rarely/never used directly and is generally called from within compare_cubes. Also, the input to compare_coords can be a number of different classes of iris.coords so is less easy to have a strict check for. Also add exception else where it is needed See above
zmaalick commented 4 years ago
  1. delete the "pass" at the end of the function Complete
  2. We need to change these both function in a way that they could return something .. and change the unittests accordingly.. Discussed offline, will keep as it is for now but will discuss again in CATNIP meeting
  3. In the beginning of the functions we need to add exception of cube type .. (please check other functions) Added for compare_cubes but not compare_coords, this is because compare_coords is rarely/never used directly and is generally called from within compare_cubes. Also, the input to compare_coords can be a number of different classes of iris.coords so is less easy to have a strict check for. Also add exception else where it is needed See above

Getting three flake8 error:

./catnip/analysis.py:777:1: W293 blank line contains whitespace ./catnip/tests/test_utils.py:95:1: W293 blank line contains whitespace ./catnip/tests/test_utils.py:128:1: W293 blank line contains whitespace 3 W293 blank line contains whitespace 3

gredmond-mo commented 4 years ago

Flake8 whitespace corrected