diff --git a/dagrt/language.py b/dagrt/language.py index 60a3709a694ba58924945d0ca7c362c029f33f5a..4603d7bd1d664ebfebeb015d60b7d89dc92d1c88 100644 --- a/dagrt/language.py +++ b/dagrt/language.py @@ -25,13 +25,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from pytools import RecordWithoutPickling, memoize_method +from pytools import RecordWithoutPickling, memoize_method, natsorted from pymbolic.imperative.statement import ( ConditionalStatement as StatementBase, ConditionalAssignment as AssignBase, Nop as NopBase) -from dagrt.utils import get_variables, natsorted +from dagrt.utils import get_variables from contextlib import contextmanager import logging diff --git a/dagrt/utils.py b/dagrt/utils.py index 69f4640936b1abeba6e66851e1c2eb5d8ab6c0b6..bd8df2e9fbec232b721e49eb4d59d66a4c0b2500 100644 --- a/dagrt/utils.py +++ b/dagrt/utils.py @@ -224,33 +224,4 @@ def run_fortran(sources, fortran_options=None, fortran_libraries=None): # }}} - -# {{{ sorting in natural order - -def natorder(key): - # Return natural ordering for strings, as opposed to dictionary order. - # E.g. will result in - # 'abc1' < 'abc9' < 'abc10' - # rather than - # 'abc1' < 'abc10' < 'abc9' - # Based on - # http://code.activestate.com/recipes/285264-natural-string-sorting/#c7 - import re - result = [] - for (int_val, string_val) in re.findall(r"(\d+)|(\D+)", key): - if int_val: - result.append(int(int_val)) - # Tie-breaker in case leading zeros in *int_val* cause distinct - # values to compare equally. - result.append(len(int_val)) - else: - result.append(string_val) - return result - - -def natsorted(seq, key=lambda x: x): - return sorted(seq, key=lambda y: natorder(key(y))) - -# }}} - # vim: foldmethod=marker diff --git a/setup.py b/setup.py index 053a8b7b9f99b04a09f626b2132399d75e3ebd5f..706c6ed13389d9f2e1997a4035a542bffaf955d8 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ def main(): packages=find_packages(), install_requires=[ "numpy>=1.5", - "pytools>=2014.1", + "pytools>=2020.1", "pymbolic>=2016.2", "pytest>=2.3", "mako",