Skip to content

Commit 37da8d5

Browse files
Fix Codestyle of Jaxfluids merge (#249)
* Format files. * Resort imports. * Fix spelling errors. * Fix linting error. * Fix linting error. * Fix formatting. * Fix linting errors. * Fix formatting.
1 parent 6bcfa3a commit 37da8d5

5 files changed

Lines changed: 259 additions & 330 deletions

File tree

examples/jaxfluids/test_jaxfluids_env.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
which serves as the common base class.
99
1010
JAXFluidsFlowEnv has the following arguments:
11-
- environment_name: Required. Name of the enviroment.
11+
- environment_name: Required. Name of the environment.
1212
- hf_repo_id: Hugging Face repository (default: 'dynamicslab/HydroGym-environments')
1313
1414
- use_clean_cache: Use clean cache directory (default: True)
@@ -46,7 +46,7 @@
4646
are part of the observation
4747
- is_scale_observations: Optional. Boolean indicating whether observations are scaled to [0, 1].
4848
- target_fn: Optional. Target thrust vector function. Choose either 'sine' or 'step'.
49-
49+
5050
The Nozzle3D environment has the following additional arguments:
5151
- num_actuators: Required. Integer number of actuators. Must be between 4 and 12.
5252
- secondary_pressure_ratio: Optional. Float, must be between 0.7 and 0.9.
@@ -57,7 +57,7 @@
5757
are part of the observation
5858
- is_scale_observations: Optional. Boolean indicating whether observations are scaled to [0, 1].
5959
- target_fn: Optional. Target thrust vector function. Choose either 'sine' or 'step'.
60-
60+
6161
"""
6262

6363
import os
@@ -68,7 +68,7 @@
6868
def main():
6969
env_config = {
7070
"environment_name": "Nozzle2D_coarse",
71-
"configuration_file": os.path.abspath("environment_config.yaml")
71+
"configuration_file": os.path.abspath("environment_config.yaml"),
7272
}
7373

7474
env = Nozzle2D(env_config=env_config)
@@ -77,12 +77,11 @@ def main():
7777
env.render()
7878

7979
for i in range(1000):
80-
8180
# Random action
82-
# action = env.action_space.sample()
81+
# action = env.action_space.sample()
8382

8483
# Fixed action
85-
action = [0.0, 0.5]
84+
action = [0.0, 0.5]
8685

8786
observation, reward, terminated, truncated, info = env.step(action)
8887

@@ -96,4 +95,4 @@ def main():
9695

9796

9897
if __name__ == "__main__":
99-
main()
98+
main()

hydrogym/jaxfluids/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .envs.nozzle import Nozzle2D, Nozzle3D
1+
from .envs.nozzle import Nozzle2D, Nozzle3D

hydrogym/jaxfluids/env_core.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
from pathlib import Path
44
from typing import Dict, Optional, Tuple, Union
55

6+
from jaxfluids_rl.jxf_env import JAXFluidsEnv, RenderMode
67
from omegaconf import OmegaConf
78

89
from hydrogym.data_manager import HFDataManager
910

10-
from jaxfluids_rl.jxf_env import JAXFluidsEnv, RenderMode
11-
1211

1312
class ConfigError(Exception):
1413
"""Exception raised for configuration-related errors."""
@@ -21,7 +20,7 @@ class JAXFluidsFlowEnv(JAXFluidsEnv):
2120
Base JAXFluidsFlowEnv with Hugging Face Hub integration for configuration management.
2221
2322
Arguments:
24-
- environment_name: Required. Name of the enviroment.
23+
- environment_name: Required. Name of the environment.
2524
- hf_repo_id: Hugging Face repository (default: 'dynamicslab/HydroGym-environments')
2625
2726
- use_clean_cache: Use clean cache directory (default: True)
@@ -35,7 +34,6 @@ class JAXFluidsFlowEnv(JAXFluidsEnv):
3534
"""
3635

3736
def _init_from_hf(self, env_config: dict) -> None:
38-
3937
# Initialize HF data manager
4038
self.hf_repo_id = env_config.get("hf_repo_id", "dynamicslab/HydroGym-environments")
4139
self.local_fallback_dir = env_config.get("local_fallback_dir", None)
@@ -45,15 +43,15 @@ def _init_from_hf(self, env_config: dict) -> None:
4543
repo_id=self.hf_repo_id,
4644
local_fallback_dir=self.local_fallback_dir,
4745
use_clean_cache=self.use_clean_cache,
48-
fallback_profile="JAXFLUIDS"
46+
fallback_profile="JAXFLUIDS",
4947
)
5048

5149
# Environment identification
5250
self.environment_name = env_config.get("environment_name")
5351

5452
if not self.environment_name:
5553
raise ConfigError("'environment_name' must be specified in env_config")
56-
54+
5755
# Download/get environment configuration
5856
self.env_data_path = self._setup_environment_data()
5957

@@ -65,11 +63,10 @@ def _init_from_hf(self, env_config: dict) -> None:
6563
f"No configuration file found for environment '{self.environment_name}'. "
6664
f"Expected config.yaml in: {self.env_data_path}"
6765
)
68-
66+
6967
# Load configuration from HF
7068
self.conf = OmegaConf.load(self.configuration_file)
7169

72-
7370
def _setup_environment_data(self) -> str:
7471
"""
7572
Download and setup environment data from HF Hub.
@@ -95,7 +92,6 @@ def _setup_environment_data(self) -> str:
9592
return env_path
9693
except Exception as e:
9794
raise ConfigError(f"Failed to setup environment data for {self.environment_name}: {e}")
98-
9995

10096
def _resolve_configuration_file(self, config_file_input: Optional[str]) -> Optional[str]:
10197
"""
@@ -154,7 +150,7 @@ def _resolve_configuration_file(self, config_file_input: Optional[str]) -> Optio
154150
f" - Current directory: {os.getcwd()}\n"
155151
f" - Environment directory: {self.env_data_path}"
156152
)
157-
153+
158154
def _find_configuration_file(self) -> Optional[str]:
159155
"""
160156
Auto-detect configuration file in the environment data directory.
@@ -192,4 +188,4 @@ def _find_configuration_file(self) -> Optional[str]:
192188
if os.path.exists(self.env_data_path):
193189
print(f"Available files: {os.listdir(self.env_data_path)}")
194190

195-
return None
191+
return None

0 commit comments

Comments
 (0)