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

Fix symbol counters

parent fd37cb09
1 merge request!340Fix symbol counters
...@@ -61,8 +61,11 @@ class AssignmentCollection: ...@@ -61,8 +61,11 @@ class AssignmentCollection:
self.simplification_hints = simplification_hints 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: if subexpression_symbol_generator is None:
self.subexpression_symbol_generator = SymbolGen() self.subexpression_symbol_generator = SymbolGen(ctr=max_ctr)
else: else:
self.subexpression_symbol_generator = subexpression_symbol_generator self.subexpression_symbol_generator = subexpression_symbol_generator
...@@ -453,8 +456,8 @@ class AssignmentCollection: ...@@ -453,8 +456,8 @@ class AssignmentCollection:
class SymbolGen: class SymbolGen:
"""Default symbol generator producing number symbols ζ_0, ζ_1, ...""" """Default symbol generator producing number symbols ζ_0, ζ_1, ..."""
def __init__(self, symbol="xi", dtype=None): def __init__(self, symbol="xi", dtype=None, ctr=0):
self._ctr = 0 self._ctr = ctr
self._symbol = symbol self._symbol = symbol
self._dtype = dtype self._dtype = dtype
......
...@@ -70,7 +70,7 @@ class BasicType(AbstractType): ...@@ -70,7 +70,7 @@ class BasicType(AbstractType):
BasicType is defined with a const qualifier and a np.dtype. 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): if isinstance(dtype, BasicType):
self.numpy_dtype = dtype.numpy_dtype self.numpy_dtype = dtype.numpy_dtype
self.const = dtype.const self.const = dtype.const
...@@ -291,7 +291,7 @@ class StructType(AbstractType): ...@@ -291,7 +291,7 @@ class StructType(AbstractType):
return hash((self.numpy_dtype, self.const)) 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 # 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. """Creates a subclass of Type according to a string or an object of subclass Type.
......
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