Skip to content
Snippets Groups Projects
Commit 7a4ff746 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

Add CustomGenerator to docs. Fix bug in postprocessing.

parent 2edd363e
No related merge requests found
...@@ -14,4 +14,13 @@ Composer API (`pystencilssfg.composer`) ...@@ -14,4 +14,13 @@ Composer API (`pystencilssfg.composer`)
.. autoclass:: pystencilssfg.composer.SfgClassComposer .. autoclass:: pystencilssfg.composer.SfgClassComposer
:members: :members:
Helper Methods
==============
.. autofunction:: pystencilssfg.composer.make_sequence .. autofunction:: pystencilssfg.composer.make_sequence
Custom Generators
=================
.. autoclass:: pystencilssfg.composer.custom.CustomGenerator
:members:
...@@ -4,7 +4,7 @@ from ..context import SfgContext ...@@ -4,7 +4,7 @@ from ..context import SfgContext
class CustomGenerator(ABC): class CustomGenerator(ABC):
"""Abstract base class for custom code generators that may be passed to """Abstract base class for custom code generators that may be passed to
[SfgComposer.generate][pystencilssfg.SfgComposer.generate].""" `SfgComposer.generate`."""
@abstractmethod @abstractmethod
def generate(self, ctx: SfgContext) -> None: ... def generate(self, ctx: SfgContext) -> None: ...
...@@ -106,23 +106,24 @@ class PostProcessingContext: ...@@ -106,23 +106,24 @@ class PostProcessingContext:
if var.name in self._live_variables: if var.name in self._live_variables:
live_var = self._live_variables[var.name] live_var = self._live_variables[var.name]
if var.dtype == live_var.dtype: if var != live_var:
# This can only happen if the variables are SymbolLike, if var.dtype == live_var.dtype:
# i.e. wrap a field-associated kernel parameter # This can only happen if the variables are SymbolLike,
# TODO: Once symbol properties are a thing, check and combine them here # i.e. wrap a field-associated kernel parameter
warnings.warn( # TODO: Once symbol properties are a thing, check and combine them here
"Encountered two non-identical variables with same name and data type:\n" warnings.warn(
f" {var.name_and_type()}\n" "Encountered two non-identical variables with same name and data type:\n"
"and\n" f" {var.name_and_type()}\n"
f" {live_var.name_and_type()}\n" "and\n"
) f" {live_var.name_and_type()}\n"
else: )
raise SfgException( else:
"Encountered two variables with same name but different data types:\n" raise SfgException(
f" {var.name_and_type()}\n" "Encountered two variables with same name but different data types:\n"
"and\n" f" {var.name_and_type()}\n"
f" {live_var.name_and_type()}" "and\n"
) f" {live_var.name_and_type()}"
)
else: else:
self._live_variables[var.name] = var self._live_variables[var.name] = var
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment