File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -519,7 +519,6 @@ def __init__(self,
519519 objects are identified automatically. Doesn't work with
520520 funcs_in with a property decorator
521521 """
522- self .hash = None
523522 self ._dofs = DOFs (x0 ,
524523 names ,
525524 np .logical_not (fixed ) if fixed is not None else None ,
@@ -531,6 +530,8 @@ def __init__(self,
531530 # instances of same class
532531 self ._id = ImmutableId (next (self .__class__ ._ids ))
533532 self .name = self .__class__ .__name__ + str (self ._id .id )
533+ hash_str = hashlib .sha256 (self .name .encode ('utf-8' )).hexdigest ()
534+ self .hash = int (hash_str , 16 ) % 10 ** 32 # 32 digit int as hash
534535 self ._children = set () # This gets populated when the object is passed
535536 # as argument to another Optimizable object
536537 self .return_fns = WeakKeyDefaultDict (list ) # Store return fn's required by each child
@@ -583,9 +584,6 @@ def __str__(self):
583584 return self .name
584585
585586 def __hash__ (self ) -> int :
586- if self .hash is None :
587- hash_str = hashlib .sha256 (self .name .encode ('utf-8' )).hexdigest ()
588- self .hash = int (hash_str , 16 ) % 10 ** 32 # 32 digit int as hash
589587 return self .hash
590588
591589 def __eq__ (self , other : Optimizable ) -> bool :
You can’t perform that action at this time.
0 commit comments