Maximum recursion depth exceeded in comparison

Dear All,
I am solving a coupled PDE. The way that I define the initial conditions is given below:

class InitialConditions(Expression):
    
    # Initial conditions for each field
    
    def __init__(self, cell_size, temperature):
        random.seed(2 + rank)
        self.cell_size = cell_size
        self.temperature = temperature
        
    def eval(self, values, x):
        values[0] = random.uniform(-1.0e-4, 1.0e-4)*self.cell_size      
        values[1] = random.uniform(-1.0e-4, 1.0e-4)*self.cell_size      
        values[2] = random.uniform(-1.0e-4, 1.0e-4)                     
        values[3] = 0.0                                                 
        values[4] = self.temperature                                    
        
    def value_shape(self):
        return (5,)

and then

if not restart:

    # Create intial conditions
    U_init = InitialConditions(1.0/case_data["num_cells"], case_data["T_ref"])

    # Interpolate initial conditions in a finite element space
    U.interpolate(U_init)
    U0.interpolate(U_init)

    # Update kinematic fields. This will cause problems if the initial
    # conditions are not compatible with the Dirichlet BCs.
    update(U, U0, v0, a0, float(beta), float(gamma), float(dt))

else:

    prefix = "./restart/" + case_data["tag"] + "/n" + str(step_number) + "_t" + str(t)
    U.interpolate(Function(ME,   prefix + "/U.xml"))
    U0.interpolate(Function(ME,  prefix + "/U0.xml"))
    v0.interpolate(Function(P2v, prefix + "/v0.xml"))
    a0.interpolate(Function(P2v, prefix + "/a0.xml"))

The following error message appeared:

RecursionError Traceback (most recent call last)
in
5
6 # Create intial conditions
----> 7 U_init = InitialConditions(1.0/case_data[“num_cells”], case_data[“T_ref”])
8
9 # Interpolate initial conditions in a finite element space

in init(self, cell_size, temperature)
5 def init(self, cell_size, temperature):
6 random.seed(2 + rank)
----> 7 self.cell_size = cell_size
8 self.temperature = temperature
9

~/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/function/expression.py in setattr(self, name, value)
436 if name.startswith("_"):
437 super().setattr(name, value)
–> 438 elif name in self._parameters:
439 self._parameters[name] = value

~/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/function/expression.py in getattr(self, name)
430 return self._parameters
431 else:
–> 432 return self._parameters[name]
433
434 def setattr(self, name, value):

… last 1 frames repeated, from the frame below …

~/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/function/expression.py in getattr(self, name)
430 return self._parameters
431 else:
–> 432 return self._parameters[name]
433
434 def setattr(self, name, value):

RecursionError: maximum recursion depth exceeded in comparison

Then I tried to increase recursion depth by the following code:

import sys
sys.setrecursionlimit(1500)

and the problem still remains. Actually I did not understand the reason behind this error and the solution for it as well. I appreciate your time, help, and kindness for any help.

Bests,
Ben

See for instance Problem with Expression since 2017.2