From b21a64902b41e5c9675b5fcf840d875ca558749e Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 28 Aug 2019 10:37:33 -0500 Subject: [PATCH 1/2] Deprecate across_dim_types in align_spaces (Closes #18 on Gitlab) --- islpy/__init__.py | 42 +++++++++++++++++++----------------------- test/test_isl.py | 8 ++++++++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/islpy/__init__.py b/islpy/__init__.py index cd6ef6d..9c398f7 100644 --- a/islpy/__init__.py +++ b/islpy/__init__.py @@ -1173,7 +1173,7 @@ def _align_dim_type(tgt_dt, obj, tgt, obj_bigger_ok, obj_names, tgt_names): return obj -def align_spaces(obj, tgt, obj_bigger_ok=False, across_dim_types=False): +def align_spaces(obj, tgt, obj_bigger_ok=False, across_dim_types=None): """ Try to make the space in which *obj* lives the same as that of *tgt* by adding/matching named dimensions. @@ -1182,6 +1182,11 @@ def align_spaces(obj, tgt, obj_bigger_ok=False, across_dim_types=False): has more dimensions than *tgt*. """ + if across_dim_types is not None: + warn("across_dim_types is deprecated and should no longer be used. " + "It never had any effect anyway.", stacklevel=2, + DeprecationWarning) + have_any_param_domains = ( isinstance(obj, (Set, BasicSet)) and isinstance(tgt, (Set, BasicSet)) @@ -1198,28 +1203,19 @@ def align_spaces(obj, tgt, obj_bigger_ok=False, across_dim_types=False): else: dim_types = _CHECK_DIM_TYPES - if across_dim_types: - obj_names = [ - obj.get_dim_name(dt, i) - for dt in dim_types - for i in range(obj.dim(dt)) - ] - tgt_names = [ - tgt.get_dim_name(dt, i) - for dt in dim_types - for i in range(tgt.dim(dt)) - ] - - for dt in dim_types: - obj = _align_dim_type(dt, obj, tgt, obj_bigger_ok, obj_names, tgt_names) - else: - obj_names = [obj.get_dim_name(dt, i) - for dt in dim_types for i in range(obj.dim(dt))] - tgt_names = [tgt.get_dim_name(dt, i) - for dt in dim_types for i in range(tgt.dim(dt))] - - for dt in dim_types: - obj = _align_dim_type(dt, obj, tgt, obj_bigger_ok, obj_names, tgt_names) + obj_names = [ + obj.get_dim_name(dt, i) + for dt in dim_types + for i in range(obj.dim(dt)) + ] + tgt_names = [ + tgt.get_dim_name(dt, i) + for dt in dim_types + for i in range(tgt.dim(dt)) + ] + + for dt in dim_types: + obj = _align_dim_type(dt, obj, tgt, obj_bigger_ok, obj_names, tgt_names) return obj diff --git a/test/test_isl.py b/test/test_isl.py index 46855df..39a7f0f 100644 --- a/test/test_isl.py +++ b/test/test_isl.py @@ -308,6 +308,14 @@ def test_lexmin(): """).lexmin()) +def test_align_spaces(): + m1 = isl.BasicMap("[m,n] -> {[i,j,k]->[l,o]:}") + m2 = isl.BasicMap("[m,n] -> {[j,k,l,i]->[o]:}") + + result = isl.align_spaces(m1, m2) + assert result.get_var_dict() == m2.get_var_dict() + + if __name__ == "__main__": import sys if len(sys.argv) > 1: -- GitLab From f59c3ca8e87912580edbb8af9c899b7d490db4b8 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 28 Aug 2019 10:44:29 -0500 Subject: [PATCH 2/2] Fix syntax blooper in DeprecationWarning --- islpy/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/islpy/__init__.py b/islpy/__init__.py index 9c398f7..45af750 100644 --- a/islpy/__init__.py +++ b/islpy/__init__.py @@ -1184,8 +1184,8 @@ def align_spaces(obj, tgt, obj_bigger_ok=False, across_dim_types=None): if across_dim_types is not None: warn("across_dim_types is deprecated and should no longer be used. " - "It never had any effect anyway.", stacklevel=2, - DeprecationWarning) + "It never had any effect anyway.", + DeprecationWarning, stacklevel=2) have_any_param_domains = ( isinstance(obj, (Set, BasicSet)) -- GitLab