(self, *flags)
Context manager for temporarily disabling MuJoCo flags.

    Args:
      *flags: Positional arguments specifying flags to disable. Can be either
        lowercase strings (e.g. 'gravity', 'contact') or `mjtDisableBit` enum
        values.

    Yields:
      None

    Raises:
      ValueError: If any item in `flags` is neither a valid name nor a value
        from `enums.mjtDisableBit`.
Context manager for temporarily disabling MuJoCo flags.
Context manager for temporarily disabling MuJoCo flags .
def disable(self, *flags):
    """Context manager for temporarily disabling MuJoCo flags.

    Args:
      *flags: Positional arguments specifying flags to disable. Can be either
        lowercase strings (e.g. 'gravity', 'contact') or `mjtDisableBit` enum
        values.

    Yields:
      None

    Raises:
      ValueError: If any item in `flags` is neither a valid name nor a value
        from `enums.mjtDisableBit`.
    """
    old_bitmask = self.opt.disableflags
    new_bitmask = old_bitmask
    for flag in flags:
      if isinstance(flag, str):
        try:
          field_name = "mjDSBL_" + flag.upper()
          bitmask = getattr(enums.mjtDisableBit, field_name)
        except AttributeError:
          valid_names = [field_name.split("_")[1].lower()
                         for field_name in enums.mjtDisableBit._fields[:-1]]
          raise ValueError("'{}' is not a valid flag name. Valid names: {}"
                           .format(flag, ", ".join(valid_names)))
      else:
        if flag not in enums.mjtDisableBit[:-1]:
          raise ValueError("'{}' is not a value in `enums.mjtDisableBit`. "
                           "Valid values: {}"
                           .format(flag, tuple(enums.mjtDisableBit[:-1])))
        bitmask = flag
      new_bitmask |= bitmask
    self.opt.disableflags = new_bitmask
    try:
      yield
    finally:
      self.opt.disableflags = old_bitmask
def disable ( self , * flags ) : old_bitmask = self . opt . disableflags new_bitmask = old_bitmask for flag in flags : if isinstance ( flag , str ) : try : field_name = "mjDSBL_" + flag . upper ( ) bitmask = getattr ( enums . mjtDisableBit , field_name ) except AttributeError : valid_names = [ field_name . split ( "_" ) [ 1 ] . lower ( ) for field_name in enums . mjtDisableBit . _fields [ : - 1 ] ] raise ValueError ( "'{}' is not a valid flag name. Valid names: {}" . format ( flag , ", " . join ( valid_names ) ) ) else : if flag not in enums . mjtDisableBit [ : - 1 ] : raise ValueError ( "'{}' is not a value in `enums.mjtDisableBit`. " "Valid values: {}" . format ( flag , tuple ( enums . mjtDisableBit [ : - 1 ] ) ) ) bitmask = flag new_bitmask |= bitmask self . opt . disableflags = new_bitmask try : yield finally : self . opt . disableflags = old_bitmask