rose icon indicating copy to clipboard operation
rose copied to clipboard

Replacement for python2 `cmp` functions

Open wxtim opened this issue 6 years ago • 1 comments

During the conversion from python2 to 3 @wxtim has used:

-cmp(a, b)
+(a>b) - (a<b)

in

  • lib/python/rose/config.py
  • lib/python/rose/macro.py
  • lib/python/rose/namelist_dump.py
  • lib/python/rose/suite_clean.py

This is subtracting booleans, which is ugly and non-intuitive.

Additionally this logic is used in functions called thus:

-list_.sort(sort_function)
+from functools import cmp_to_key
+list_sort(key=cmp_to_key(sort_func)

This logic should be tidied up, preferably deprecating the use of cmp_to_key. Proposed work:

  • Use Pytest to create functional tests at the level of calling list_.sort(key=cmp_to_key(sort_func))
  • Change the sort functions to key functions, if possible.

wxtim avatar Mar 13 '19 10:03 wxtim

During the conversion from python2 to 3 @wxtim has used...

Oh that @wxtim! :smile:

sadielbartholomew avatar May 08 '19 13:05 sadielbartholomew