From 7a4ff7464eb3d8d25749b42171c3a3ccf6b2b22f Mon Sep 17 00:00:00 2001
From: Frederik Hennig <frederik.hennig@fau.de>
Date: Thu, 17 Oct 2024 16:00:51 +0200
Subject: [PATCH] Add CustomGenerator to docs. Fix bug in postprocessing.

---
 docs/source/api/composer.rst           |  9 +++++++
 src/pystencilssfg/composer/custom.py   |  2 +-
 src/pystencilssfg/ir/postprocessing.py | 35 +++++++++++++-------------
 3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/docs/source/api/composer.rst b/docs/source/api/composer.rst
index 75acd8a..fb63d68 100644
--- a/docs/source/api/composer.rst
+++ b/docs/source/api/composer.rst
@@ -14,4 +14,13 @@ Composer API (`pystencilssfg.composer`)
 .. autoclass:: pystencilssfg.composer.SfgClassComposer
     :members:
 
+Helper Methods
+==============
+
 .. autofunction:: pystencilssfg.composer.make_sequence
+
+Custom Generators
+=================
+
+.. autoclass:: pystencilssfg.composer.custom.CustomGenerator
+    :members:
diff --git a/src/pystencilssfg/composer/custom.py b/src/pystencilssfg/composer/custom.py
index 26e9b93..fa53d6a 100644
--- a/src/pystencilssfg/composer/custom.py
+++ b/src/pystencilssfg/composer/custom.py
@@ -4,7 +4,7 @@ from ..context import SfgContext
 
 class CustomGenerator(ABC):
     """Abstract base class for custom code generators that may be passed to
-    [SfgComposer.generate][pystencilssfg.SfgComposer.generate]."""
+    `SfgComposer.generate`."""
 
     @abstractmethod
     def generate(self, ctx: SfgContext) -> None: ...
diff --git a/src/pystencilssfg/ir/postprocessing.py b/src/pystencilssfg/ir/postprocessing.py
index e796a69..c037c52 100644
--- a/src/pystencilssfg/ir/postprocessing.py
+++ b/src/pystencilssfg/ir/postprocessing.py
@@ -106,23 +106,24 @@ class PostProcessingContext:
             if var.name in self._live_variables:
                 live_var = self._live_variables[var.name]
 
-                if var.dtype == live_var.dtype:
-                    #   This can only happen if the variables are SymbolLike,
-                    #   i.e. wrap a field-associated kernel parameter
-                    #   TODO: Once symbol properties are a thing, check and combine them here
-                    warnings.warn(
-                        "Encountered two non-identical variables with same name and data type:\n"
-                        f"    {var.name_and_type()}\n"
-                        "and\n"
-                        f"    {live_var.name_and_type()}\n"
-                    )
-                else:
-                    raise SfgException(
-                        "Encountered two variables with same name but different data types:\n"
-                        f"    {var.name_and_type()}\n"
-                        "and\n"
-                        f"    {live_var.name_and_type()}"
-                    )
+                if var != live_var:
+                    if var.dtype == live_var.dtype:
+                        #   This can only happen if the variables are SymbolLike,
+                        #   i.e. wrap a field-associated kernel parameter
+                        #   TODO: Once symbol properties are a thing, check and combine them here
+                        warnings.warn(
+                            "Encountered two non-identical variables with same name and data type:\n"
+                            f"    {var.name_and_type()}\n"
+                            "and\n"
+                            f"    {live_var.name_and_type()}\n"
+                        )
+                    else:
+                        raise SfgException(
+                            "Encountered two variables with same name but different data types:\n"
+                            f"    {var.name_and_type()}\n"
+                            "and\n"
+                            f"    {live_var.name_and_type()}"
+                        )
             else:
                 self._live_variables[var.name] = var
 
-- 
GitLab