Skip to content

Commit

Permalink
Ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cgokmen committed Dec 27, 2024
1 parent 41b945f commit 6c3f232
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,9 @@ def __init__(
self.robot.controllers["base"], (JointController, DifferentialDriveController)
), "StarterSemanticActionPrimitives only works with a JointController or DifferentialDriveController at the robot base."
if self._base_controller_is_joint:
assert not self.robot.controllers[
"base"
].use_delta_commands, (
"StarterSemanticActionPrimitives only works with a base JointController with absolute mode."
)
assert (
not self.robot.controllers["base"].use_delta_commands
), "StarterSemanticActionPrimitives only works with a base JointController with absolute mode."

self.robot_model = self.robot.model_name
self.add_context = add_context
Expand Down
4 changes: 3 additions & 1 deletion omnigibson/controllers/controller_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ def nums2array(nums, dim):
return (
nums
if isinstance(nums, cb.arr_type)
else cb.array(nums) if isinstance(nums, Iterable) else cb.ones(dim) * nums
else cb.array(nums)
if isinstance(nums, Iterable)
else cb.ones(dim) * nums
)

@property
Expand Down
8 changes: 2 additions & 6 deletions omnigibson/examples/robots/import_custom_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,7 @@ def add_sensor(stage, root_prim, sensor_type, link_name, parent_link_name=None,
link_prim_path = f"{root_prim_path}/{link_name}"
link_prim_exists = lazy.omni.isaac.core.utils.prims.is_prim_path_valid(link_prim_path)
if parent_link_prim is not None:
assert (
not link_prim_exists
), f"Since parent link is defined, link_name {link_name} must be a link that is NOT pre-existing within the robot's set of links!"
assert not link_prim_exists, f"Since parent link is defined, link_name {link_name} must be a link that is NOT pre-existing within the robot's set of links!"
# Manually create a new prim (specified offset)
create_rigid_prim(
stage=stage,
Expand Down Expand Up @@ -443,9 +441,7 @@ def add_sensor(stage, root_prim, sensor_type, link_name, parent_link_name=None,

else:
# Otherwise, link prim MUST exist
assert (
link_prim_exists
), f"Since no parent link is defined, link_name {link_name} must be a link that IS pre-existing within the robot's set of links!"
assert link_prim_exists, f"Since no parent link is defined, link_name {link_name} must be a link that IS pre-existing within the robot's set of links!"

# Define functions to generate the desired sensor prim
if sensor_type == "Camera":
Expand Down
4 changes: 3 additions & 1 deletion omnigibson/objects/object_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def __init__(
load_config["scale"] = (
scale
if isinstance(scale, th.Tensor)
else th.tensor(scale, dtype=th.float32) if isinstance(scale, Iterable) else scale
else th.tensor(scale, dtype=th.float32)
if isinstance(scale, Iterable)
else scale
)
load_config["visible"] = visible
load_config["visual_only"] = visual_only
Expand Down
4 changes: 3 additions & 1 deletion omnigibson/robots/robot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def __init__(
self._obs_modalities = (
obs_modalities
if obs_modalities == "all"
else {obs_modalities} if isinstance(obs_modalities, str) else set(obs_modalities)
else {obs_modalities}
if isinstance(obs_modalities, str)
else set(obs_modalities)
) # this will get updated later when we fill in our sensors
self._proprio_obs = self.default_proprio_obs if proprio_obs == "default" else list(proprio_obs)
self._sensor_config = sensor_config
Expand Down
6 changes: 3 additions & 3 deletions omnigibson/robots/two_wheel_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def _default_controller_config(self):
cfg = super()._default_controller_config

# Add differential drive option to base
cfg["base"][
self._default_base_differential_drive_controller_config["name"]
] = self._default_base_differential_drive_controller_config
cfg["base"][self._default_base_differential_drive_controller_config["name"]] = (
self._default_base_differential_drive_controller_config
)

return cfg

Expand Down
4 changes: 2 additions & 2 deletions omnigibson/systems/micro_particle_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def set_carb_settings_for_fluid_isosurface():
min_frame_rate = 60
# Make sure we have at least 60 FPS before setting "persistent/simulation/minFrameRate" to 60
assert (
1 / og.sim.get_rendering_dt()
) >= min_frame_rate, f"isosurface HQ rendering requires at least {min_frame_rate} FPS; consider increasing rendering_frequency of env_config to {min_frame_rate}."
(1 / og.sim.get_rendering_dt()) >= min_frame_rate
), f"isosurface HQ rendering requires at least {min_frame_rate} FPS; consider increasing rendering_frequency of env_config to {min_frame_rate}."

# Settings for Isosurface
isregistry = lazy.carb.settings.acquire_settings_interface()
Expand Down
3 changes: 2 additions & 1 deletion omnigibson/utils/profiling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def gpu_in_use_by_this_process(gpu_handle, pid: int) -> bool:

compute_pids = {process.pid for process in pynvml.nvmlDeviceGetComputeRunningProcesses(gpu_handle)} # type: ignore
graphics_pids = {
process.pid for process in pynvml.nvmlDeviceGetGraphicsRunningProcesses(gpu_handle) # type: ignore
process.pid
for process in pynvml.nvmlDeviceGetGraphicsRunningProcesses(gpu_handle) # type: ignore
}

pids_using_device = compute_pids | graphics_pids
Expand Down
5 changes: 3 additions & 2 deletions omnigibson/utils/urdfpy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ def _parse_simple_elements(cls, node, path):
vs = node.findall(t._TAG)
if len(vs) == 0 and r:
raise ValueError(
"Missing required subelement(s) of type {} when "
"parsing an object of type {}".format(t.__name__, cls.__name__)
"Missing required subelement(s) of type {} when " "parsing an object of type {}".format(
t.__name__, cls.__name__
)
)
v = [t._from_xml(n, path) for n in vs]
kwargs[a] = v
Expand Down

0 comments on commit 6c3f232

Please sign in to comment.