From 7fba94accbf9c180a9d5bf55f58333916ff815e9 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sun, 12 Jan 2020 10:11:24 -0600 Subject: [PATCH 1/2] Use pytools.natsorted --- loopy/kernel/__init__.py | 3 +-- loopy/kernel/tools.py | 3 +-- loopy/tools.py | 16 ---------------- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index 80a7ad031..9096edcc0 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -35,14 +35,13 @@ import islpy as isl from islpy import dim_type import re -from pytools import UniqueNameGenerator, generate_unique_names +from pytools import UniqueNameGenerator, generate_unique_names, natsorted from loopy.library.function import ( default_function_mangler, single_arg_function_mangler) from loopy.diagnostic import CannotBranchDomainTree, LoopyError -from loopy.tools import natsorted from loopy.diagnostic import StaticValueFindingError from loopy.kernel.data import filter_iname_tags_by_type from warnings import warn diff --git a/loopy/kernel/tools.py b/loopy/kernel/tools.py index 157099df5..bb6ae44c9 100644 --- a/loopy/kernel/tools.py +++ b/loopy/kernel/tools.py @@ -34,8 +34,7 @@ import numpy as np import islpy as isl from islpy import dim_type from loopy.diagnostic import LoopyError, warn_with_kernel -from pytools import memoize_on_first_arg -from loopy.tools import natsorted +from pytools import memoize_on_first_arg, natsorted import logging logger = logging.getLogger(__name__) diff --git a/loopy/tools.py b/loopy/tools.py index 33b6616f3..e16bac6b2 100644 --- a/loopy/tools.py +++ b/loopy/tools.py @@ -673,20 +673,4 @@ def is_interned(s): def intern_frozenset_of_ids(fs): return frozenset(intern(s) for s in fs) - -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 - return [int(n) if n else s for n, s in re.findall(r'(\d+)|(\D+)', key)] - - -def natsorted(seq, key=lambda x: x): - return sorted(seq, key=lambda y: natorder(key(y))) - # vim: foldmethod=marker -- GitLab From 9d0746d8dfd85840bd0d01a6a32a4312c305be14 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sun, 12 Jan 2020 10:14:40 -0600 Subject: [PATCH 2/2] Bump pytools version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 75d8b340e..92c16a0f5 100644 --- a/setup.py +++ b/setup.py @@ -89,7 +89,7 @@ setup(name="loo.py", ], install_requires=[ - "pytools>=2018.4", + "pytools>=2020.1", "pymbolic>=2019.2", "genpy>=2016.1.2", "cgen>=2016.1", -- GitLab