Skip to content

Commit ab5f573

Browse files
committed
Rename function to fn
1 parent 3951852 commit ab5f573

17 files changed

Lines changed: 44 additions & 44 deletions

File tree

‎SKILL.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Grepping the name of an existing model or drone finds every registration site, e
4747
against all models in the simulation's `build_control_fns`.
4848

4949
Define the function in `dynamics.py` and never in the package `__init__.py`, because
50-
`load_function_params` derives the model name from `fn.__module__.split(".")[-2]`. `parametrize`
50+
`load_fn_params` derives the model name from `fn.__module__.split(".")[-2]`. `parametrize`
5151
binds exactly the keyword-only parameters after the bare `*`, so anything before it is never bound.
5252
Every drone in `available_drones` needs a complete section in every model's
5353
`crazyflow/dynamics/*/params.toml`; the commented example at the top of each file lists the keys.
@@ -63,7 +63,7 @@ Pure, batched, array-API functions with no dependency on `Sim`.
6363
immediately, and scipy cannot be reconfigured once loaded. Transitive imports through acados or
6464
sklearn trigger this too.
6565
- `dynamics` and `control` each have `load_params(name, drone)`, returning everything defined for
66-
the drone, and `load_function_params(fn, drone)`, which filters to the signature of `fn` and
66+
the drone, and `load_fn_params(fn, drone)`, which filters to the signature of `fn` and
6767
silently drops the rest. Platform data that nothing uses sits as a comment in the drone MJCF.
6868
- `parametrize` returns a `functools.partial` whose `keywords` dict is shared by every reference to
6969
it. Call `parametrize` again for an independent copy.

‎crazyflow/control/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
__all__ = []
1616

17-
from crazyflow.control.core import Control, load_function_params, load_params, parametrize
17+
from crazyflow.control.core import Control, load_fn_params, load_params, parametrize
1818
from crazyflow.control.mellinger import attitude2force_torque as mellinger_attitude2force_torque
1919
from crazyflow.control.mellinger import body_rate2force_torque as mellinger_body_rate2force_torque
2020
from crazyflow.control.mellinger import state2attitude as mellinger_state2attitude
@@ -25,4 +25,4 @@
2525
"mellinger_body_rate2force_torque": mellinger_body_rate2force_torque,
2626
}
2727

28-
__all__ = ["Control", "load_params", "load_function_params", "parametrize"]
28+
__all__ = ["Control", "load_params", "load_fn_params", "parametrize"]

‎crazyflow/control/core.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def parametrize(
9090
Returns:
9191
The parametrized controller function with all keyword argument only parameters filled in.
9292
"""
93-
return _parametrize(fn, drone, load_function_params, xp=xp, device=device)
93+
return _parametrize(fn, drone, load_fn_params, xp=xp, device=device)
9494

9595

9696
def load_params(
@@ -120,7 +120,7 @@ def load_params(
120120
return to_xp(params[drone], xp=xp, device=device)
121121

122122

123-
def load_function_params(
123+
def load_fn_params(
124124
fn: Callable, drone: str, xp: ModuleType | None = None, device: str | None = None
125125
) -> dict[str, Array]:
126126
"""Load the parameters a controller function accepts.

‎crazyflow/control/mellinger/control.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from flax.struct import dataclass, field
2121
from scipy.spatial.transform import Rotation as R
2222

23-
from crazyflow.control.core import controllable, load_function_params
23+
from crazyflow.control.core import controllable, load_fn_params
2424
from crazyflow.control.transform import force2pwm, motor_force2rotor_vel, pwm2force
2525
from crazyflow.utils import CORE_NDIM_KEY, leaf_replace
2626

@@ -513,7 +513,7 @@ def create(
513513
zeros_3d = jnp.zeros((n_worlds, n_drones, 3), device=device)
514514
cmd = jnp.zeros((n_worlds, n_drones, 16), device=device).at[..., 12].set(1.0)
515515
steps = -jnp.ones((n_worlds, 1), dtype=jnp.int32, device=device)
516-
params = load_function_params(state2attitude, drone, xp=jnp, device=device)
516+
params = load_fn_params(state2attitude, drone, xp=jnp, device=device)
517517
return MellingerStateData(
518518
cmd=cmd,
519519
staged_cmd=cmd.copy(),
@@ -553,7 +553,7 @@ def create(
553553
zeros_3d = jnp.zeros((n_worlds, n_drones, 3), device=device)
554554
zeros_4d = jnp.zeros((n_worlds, n_drones, 4), device=device)
555555
steps = -jnp.ones((n_worlds, 1), dtype=jnp.int32, device=device)
556-
params = load_function_params(attitude2force_torque, drone, xp=jnp, device=device)
556+
params = load_fn_params(attitude2force_torque, drone, xp=jnp, device=device)
557557
return MellingerAttitudeData(
558558
cmd=zeros_4d.copy(),
559559
staged_cmd=zeros_4d.copy(),
@@ -595,7 +595,7 @@ def create(
595595
zeros_3d = jnp.zeros((n_worlds, n_drones, 3), device=device)
596596
zeros_4d = jnp.zeros((n_worlds, n_drones, 4), device=device)
597597
steps = -jnp.ones((n_worlds, 1), dtype=jnp.int32, device=device)
598-
params = load_function_params(body_rate2force_torque, drone, xp=jnp, device=device)
598+
params = load_fn_params(body_rate2force_torque, drone, xp=jnp, device=device)
599599
return MellingerBodyRateData(
600600
cmd=zeros_4d.copy(),
601601
staged_cmd=zeros_4d.copy(),
@@ -629,7 +629,7 @@ def create(
629629
) -> MellingerForceTorqueData:
630630
zeros_4d = jnp.zeros((n_worlds, n_drones, 4), device=device)
631631
steps = -jnp.ones((n_worlds, 1), dtype=jnp.int32, device=device)
632-
params = load_function_params(force_torque2rotor_vel, drone, xp=jnp, device=device)
632+
params = load_fn_params(force_torque2rotor_vel, drone, xp=jnp, device=device)
633633
return MellingerForceTorqueData(
634634
cmd=zeros_4d.copy(), staged_cmd=zeros_4d.copy(), steps=steps, freq=freq, params=params
635635
)

‎crazyflow/dynamics/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from typing import Callable
1616

17-
from crazyflow.dynamics.core import Dynamics, load_function_params, load_params, parametrize
17+
from crazyflow.dynamics.core import Dynamics, load_fn_params, load_params, parametrize
1818
from crazyflow.dynamics.first_principles import dynamics as _first_principles_dynamics
1919
from crazyflow.dynamics.so_rpy import dynamics as _so_rpy_dynamics
2020
from crazyflow.dynamics.so_rpy_rotor import dynamics as _so_rpy_rotor_dynamics
@@ -23,7 +23,7 @@
2323
__all__ = [
2424
"parametrize",
2525
"load_params",
26-
"load_function_params",
26+
"load_fn_params",
2727
"available_dynamics",
2828
"dynamics_features",
2929
"Dynamics",

‎crazyflow/dynamics/core.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def parametrize(
8181
Returns:
8282
The parametrized dynamics function with all keyword argument only parameters filled in.
8383
"""
84-
return _parametrize(fn, drone, load_function_params, xp=xp, device=device)
84+
return _parametrize(fn, drone, load_fn_params, xp=xp, device=device)
8585

8686

8787
def load_params(
@@ -120,7 +120,7 @@ def load_params(
120120
return to_xp(params, xp=xp, device=device)
121121

122122

123-
def load_function_params(
123+
def load_fn_params(
124124
fn: Callable, drone: str, xp: ModuleType | None = None, device: str | None = None
125125
) -> dict:
126126
"""Load the parameters a dynamics function accepts.

‎crazyflow/dynamics/first_principles/dynamics.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from scipy.spatial.transform import Rotation as R
2626

2727
import crazyflow.dynamics.symbols as symbols
28-
from crazyflow.dynamics.core import load_function_params, supports
28+
from crazyflow.dynamics.core import load_fn_params, supports
2929
from crazyflow.dynamics.utils import rotation
3030
from crazyflow.utils import CORE_NDIM_KEY, to_xp
3131

@@ -342,7 +342,7 @@ class Params:
342342
@staticmethod
343343
def create(drone: str, device: Device) -> Params:
344344
"""Create the default parameters for the simulation."""
345-
p = load_function_params(dynamics, drone)
345+
p = load_fn_params(dynamics, drone)
346346
J = jnp.asarray(p["J"], device=device)
347347
return Params(
348348
mass=jnp.asarray([p["mass"]], device=device),

‎crazyflow/dynamics/so_rpy/dynamics.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from scipy.spatial.transform import Rotation as R
2525

2626
import crazyflow.dynamics.symbols as symbols
27-
from crazyflow.dynamics.core import load_function_params, supports
27+
from crazyflow.dynamics.core import load_fn_params, supports
2828
from crazyflow.dynamics.utils import rotation
2929
from crazyflow.utils import CORE_NDIM_KEY, to_xp
3030

@@ -345,7 +345,7 @@ class Params:
345345
@staticmethod
346346
def create(drone: str, device: Device) -> Params:
347347
"""Create the default parameters for the simulation."""
348-
p = load_function_params(dynamics, drone)
348+
p = load_fn_params(dynamics, drone)
349349
J = jnp.asarray(p["J"], device=device)
350350
return Params(
351351
mass=jnp.asarray([p["mass"]], device=device),

‎crazyflow/dynamics/so_rpy_rotor/dynamics.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from scipy.spatial.transform import Rotation as R
2727

2828
import crazyflow.dynamics.symbols as symbols
29-
from crazyflow.dynamics.core import load_function_params, supports
29+
from crazyflow.dynamics.core import load_fn_params, supports
3030
from crazyflow.dynamics.utils import rotation
3131
from crazyflow.utils import CORE_NDIM_KEY, to_xp
3232

@@ -398,7 +398,7 @@ class Params:
398398
@staticmethod
399399
def create(drone: str, device: Device) -> Params:
400400
"""Create the default parameters for the simulation."""
401-
p = load_function_params(dynamics, drone)
401+
p = load_fn_params(dynamics, drone)
402402
J = jnp.asarray(p["J"], device=device)
403403
return Params(
404404
mass=jnp.asarray([p["mass"]], device=device),

‎crazyflow/dynamics/so_rpy_rotor_drag/dynamics.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from scipy.spatial.transform import Rotation as R
2929

3030
import crazyflow.dynamics.symbols as symbols
31-
from crazyflow.dynamics.core import load_function_params, supports
31+
from crazyflow.dynamics.core import load_fn_params, supports
3232
from crazyflow.dynamics.utils import rotation
3333
from crazyflow.utils import CORE_NDIM_KEY, to_xp
3434

@@ -434,7 +434,7 @@ class Params:
434434
@staticmethod
435435
def create(drone: str, device: Device) -> Params:
436436
"""Create the default parameters for the simulation."""
437-
p = load_function_params(dynamics, drone)
437+
p = load_fn_params(dynamics, drone)
438438
J = jnp.asarray(p["J"], device=device)
439439
return Params(
440440
mass=jnp.asarray([p["mass"]], device=device),

0 commit comments

Comments
 (0)