From 3cb194c5575f3e74d8b011208399ea09a025d3f7 Mon Sep 17 00:00:00 2001
From: Frederik Hennig <frederik.hennig@fau.de>
Date: Fri, 18 Oct 2024 11:01:11 +0200
Subject: [PATCH] Deprecate map_param. Fix test suite

---
 src/pystencilssfg/composer/basic_composer.py | 58 +++++++++++---------
 src/pystencilssfg/lang/expressions.py        |  7 ++-
 2 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/src/pystencilssfg/composer/basic_composer.py b/src/pystencilssfg/composer/basic_composer.py
index 11031f8..135f6fb 100644
--- a/src/pystencilssfg/composer/basic_composer.py
+++ b/src/pystencilssfg/composer/basic_composer.py
@@ -468,8 +468,14 @@ class SfgBasicComposer(SfgIComposer):
         depends: VarLike | Sequence[VarLike],
         mapping: str,
     ):
-        """Arbitrary parameter mapping: Add a single line of code to define a left-hand
-        side object from one or multiple right-hand side dependencies."""
+        from warnings import warn
+
+        warn(
+            "The `map_param` method of `SfgBasicComposer` is deprecated and will be removed "
+            "in a future version. Use `sfg.set_param` instead.",
+            FutureWarning,
+        )
+
         if isinstance(depends, _VarLike):
             depends = [depends]
         lhs_var: SfgVar | sp.Symbol = (
@@ -508,37 +514,37 @@ def make_sequence(*args: SequencerArg) -> SfgSequence:
     - Sub-ASTs and AST builders, which are often produced by the syntactic sugar and
       factory methods of `SfgComposer`.
 
-    Its usage is best shown by example:
+    :Example:
 
-    .. code-block:: Python
+        .. code-block:: Python
 
-        tree = make_sequence(
-            "int a = 0;",
-            "int b = 1;",
-            (
-                "int tmp = b;",
-                "b = a;",
-                "a = tmp;"
-            ),
-            SfgKernelCall(kernel_handle)
-        )
+            tree = make_sequence(
+                "int a = 0;",
+                "int b = 1;",
+                (
+                    "int tmp = b;",
+                    "b = a;",
+                    "a = tmp;"
+                ),
+                SfgKernelCall(kernel_handle)
+            )
 
-        sfg.context.add_function("myFunction", tree)
+            sfg.context.add_function("myFunction", tree)
 
-    will translate to
+        will translate to
 
-    .. code-block:: C++
+        .. code-block:: C++
 
-        void myFunction() {
-            int a = 0;
-            int b = 0;
-            {
-                int tmp = b;
-                b = a;
-                a = tmp;
+            void myFunction() {
+                int a = 0;
+                int b = 0;
+                {
+                    int tmp = b;
+                    b = a;
+                    a = tmp;
+                }
+                kernels::kernel( ... );
             }
-            kernels::kernel( ... );
-        }
     """
     children = []
     for i, arg in enumerate(args):
diff --git a/src/pystencilssfg/lang/expressions.py b/src/pystencilssfg/lang/expressions.py
index d8bd782..481922e 100644
--- a/src/pystencilssfg/lang/expressions.py
+++ b/src/pystencilssfg/lang/expressions.py
@@ -288,8 +288,9 @@ def asvar(var: VarLike) -> SfgVar:
         SfgVar: Variable cast as `SfgVar`.
 
     Raises:
-        SfgException: If given a non-variable `AugExpr`, or a `TypedSymbol` with a `DynamicType`
-        ValueError: If given any non-variable-like object.
+        ValueError: If given a non-variable `AugExpr`,
+            a `TypedSymbol` with a `DynamicType`,
+            or any non-variable-like object.
     """
     match var:
         case SfgVar():
@@ -300,7 +301,7 @@ def asvar(var: VarLike) -> SfgVar:
             from pystencils import DynamicType
 
             if isinstance(var.dtype, DynamicType):
-                raise SfgException(
+                raise ValueError(
                     f"Unable to cast dynamically typed symbol {var} to a variable.\n"
                     f"{var} has dynamic type {var.dtype}, which cannot be resolved to a type outside of a kernel."
                 )
-- 
GitLab