Skip to content
Snippets Groups Projects
Commit 36112534 authored by Markus Holzer's avatar Markus Holzer
Browse files

Fix symbol counters

parent fd37cb09
No related branches found
No related tags found
No related merge requests found
Pipeline #54502 passed
......@@ -61,8 +61,11 @@ class AssignmentCollection:
self.simplification_hints = simplification_hints
ctrs = [int(n.name[3:])for n in self.rhs_symbols if "xi_" in n.name]
max_ctr = max(ctrs) + 1 if len(ctrs) > 0 else 0
if subexpression_symbol_generator is None:
self.subexpression_symbol_generator = SymbolGen()
self.subexpression_symbol_generator = SymbolGen(ctr=max_ctr)
else:
self.subexpression_symbol_generator = subexpression_symbol_generator
......@@ -453,8 +456,8 @@ class AssignmentCollection:
class SymbolGen:
"""Default symbol generator producing number symbols ζ_0, ζ_1, ..."""
def __init__(self, symbol="xi", dtype=None):
self._ctr = 0
def __init__(self, symbol="xi", dtype=None, ctr=0):
self._ctr = ctr
self._symbol = symbol
self._dtype = dtype
......
......@@ -70,7 +70,7 @@ class BasicType(AbstractType):
BasicType is defined with a const qualifier and a np.dtype.
"""
def __init__(self, dtype: Union[np.dtype, 'BasicType', str], const: bool = False):
def __init__(self, dtype: Union[type, 'BasicType', str], const: bool = False):
if isinstance(dtype, BasicType):
self.numpy_dtype = dtype.numpy_dtype
self.const = dtype.const
......@@ -291,7 +291,7 @@ class StructType(AbstractType):
return hash((self.numpy_dtype, self.const))
def create_type(specification: Union[np.dtype, AbstractType, str]) -> AbstractType:
def create_type(specification: Union[type, AbstractType, str]) -> AbstractType:
# TODO: Deprecated Use the constructor of BasicType or StructType instead
"""Creates a subclass of Type according to a string or an object of subclass Type.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment