Skip to content
Snippets Groups Projects
Commit 60e24c40 authored by Philipp Suffa's avatar Philipp Suffa
Browse files

Merge branch 'Fixcounting' into 'master'

Fix symbol counters

See merge request !340
parents fd37cb09 36112534
No related branches found
No related tags found
1 merge request!340Fix symbol counters
Pipeline #54595 passed
...@@ -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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment