diff --git a/src/pystencilssfg/composer/basic_composer.py b/src/pystencilssfg/composer/basic_composer.py index 11031f8f5c926e1a7371c85040fc756ccf7686b1..135f6fb85866c486626bf965bbc475c9a3accf18 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 d8bd782090fb625afc95ffc46207f2c2c7a9d8bd..481922e728549e48550e91b562b6099ec9b8c094 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." )