def __lock_density_if_defined(self, stack: dict):
if self.stack == {}:<EOL><INDENT>density_lock = {}<EOL><DEDENT>else:<EOL><INDENT>density_lock = self.density_lock<EOL><DEDENT>for _compound in stack.keys():<EOL><INDENT>_density = stack[_compound]['<STR_LIT>']['<STR_LIT:value>']<EOL>if np.isnan(_density):<EOL><INDENT>density_lock[_compound] = False<EOL><DEDENT>else:<EOL><INDENT>density_lock[_compound] = True<EOL><DEDENT><DEDENT>self.density_lock = density_lock<EOL>
lock (True) the density lock if the density has been been defined during initialization
        Store the resulting dictionary into density_lock

        Parameters:
        ===========
        stack: dictionary (optional)
          if not provided, the entire stack will be used