From ea11954d0d4255862e50be88c2b1e5e58395e31f Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni <kaushikcfd@gmail.com> Date: Mon, 27 Sep 2021 18:48:17 -0500 Subject: [PATCH] Deprecate with_container_arithmetic's bcast_numpy_array arg Passing both 'bcast_numpy_array' and '_bcast_actx_array_types' was ill-defined. For example, in the case of an ArrayContext whose thawed array type is np.ndarray the specification would contradict between broadcasting the argument numpy_array to return an object array *OR* peforming the operation with every leaf array. Consider the example below, ( - 'Foo: ArrayContainer' whose arithmetic routines are generated by `with_container_arithmetic(bcast_numpy=True, _bcast_actx_array_types=True)` - 'actx: ArrayContextT' for whom `np.ndarray` is a valid thawed array type. ) Foo(DOFArray(actx, [38*actx.ones(3, np.float64)])) + np.array([3, 4, 5]) could be either of: - array([Foo(DOFArray([array([41, 41, 41])])), Foo(DOFArray([array([42, 42, 42])])), Foo(DOFArray([array([43, 43, 43])]))]), OR, - Foo(DOFArray(actx, array([41, 42, 43]))) --- arraycontext/container/arithmetic.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arraycontext/container/arithmetic.py b/arraycontext/container/arithmetic.py index 2ef5ddc..4c8a09a 100644 --- a/arraycontext/container/arithmetic.py +++ b/arraycontext/container/arithmetic.py @@ -214,6 +214,15 @@ def with_container_arithmetic( if rel_comparison is None: raise TypeError("rel_comparison must be specified") + if bcast_numpy_array: + from warnings import warn + warn("'bcast_numpy_array=True' is deprecated and will be unsupported" + " from December 2021", DeprecationWarning, stacklevel=2) + + if _bcast_actx_array_type: + raise ValueError("'bcast_numpy_array' and '_bcast_actx_array_type'" + " cannot be both set.") + if rel_comparison and eq_comparison is None: eq_comparison = True -- GitLab