Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .codex-worktrees/friction-factors-3659
Submodule friction-factors-3659 added at 9c6731
1 change: 1 addition & 0 deletions .codex-worktrees/pr-3602-fix
Submodule pr-3602-fix added at e37b32
1 change: 1 addition & 0 deletions .codex-worktrees/pr-3752-movement
Submodule pr-3752-movement added at e5e013
1 change: 1 addition & 0 deletions .codex-worktrees/pr-3766-modern-robotics-dbc
Submodule pr-3766-modern-robotics-dbc added at 34ee67
1 change: 1 addition & 0 deletions .codex-worktrees/pr-3780-pressure-flow
Submodule pr-3780-pressure-flow added at b28657
1 change: 1 addition & 0 deletions .codex-worktrees/pr-3784-deterministic-te
Submodule pr-3784-deterministic-te added at 1e87cc
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@
## 2025-05-18 - Avoid array methods for small static arrays in frequently called initializers
**Learning:** Using `.reduce()` or `.map()` on static arrays like tabs definitions inside frequently called functions (e.g. state initializers or local storage hydration) incurs unnecessary closure and function call overhead.
**Action:** Replace `.reduce()` and `.map()` with single-pass `for` loops in simple data transformation functions (like `defaultTabVisibility`) to eliminate closure allocations.
## 2026-08-09 - Pre-allocate Arrays instead of Array.from in hot paths
**Learning:** In JavaScript/TypeScript data-intensive hot paths (e.g., CSV parsing), using `Array.from({ length: X }, ...)` for initialization incurs significant overhead from iterability checks, iterator creation, and closure execution per element.
**Action:** Always replace `Array.from({ length: X }, ...)` with pre-allocated arrays using `new Array(X)` and populate them with standard `for` loops in performance-critical code to eliminate GC pressure.
6 changes: 6 additions & 0 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -2702,3 +2702,9 @@ The command injection check logic in `cli_tools.py` has been fortified. The inpu

- Removed chained array maps and reduces in the parseVariableAssignments function within `src/web_applications/calculator/static/app.js`.
- Improved execution speed by using standard single pass for loop and string `indexOf` / `substring` techniques.

## Changelog
- **2026-08-09**: Optimized CSV parsing in `p1am_control_system/frontend` and `data_explorer` by replacing `Array.from()` with standard `for` loops and pre-allocated arrays to eliminate iterability overhead in hot paths.
## Changelog
- **2026-08-09**: Optimized CSV parsing in `p1am_control_system/frontend` and `data_explorer` by replacing `Array.from()` with standard `for` loops and pre-allocated arrays to eliminate iterability overhead in hot paths.
- **2026-08-09**: Optimized CSV parsing in `p1am_control_system/frontend` and `data_explorer` by replacing `Array.from()` with standard `for` loops and pre-allocated arrays to eliminate iterability overhead in hot paths.
4 changes: 3 additions & 1 deletion launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def launch_tool(tool_identifier: str) -> int:
gui_configs = registration.gui_configs
config = gui_configs.get(GUIType.PYQT6)
if config is None:
print(f"Tool '{registration.display_name}' has no PyQt6 configuration.") # noqa: T201
print(
f"Tool '{registration.display_name}' has no PyQt6 configuration."
) # noqa: T201
return 1

display_name = registration.display_name
Expand Down
6 changes: 3 additions & 3 deletions scripts/bump_vendor_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def validate_consumer(consumer_repo: str) -> None:
Precondition: consumer_repo is a non-empty string.
Postcondition: no exception means the repo is safe to target.
"""
assert isinstance(consumer_repo, str) and consumer_repo, (
"consumer_repo must be a non-empty string"
)
assert (
isinstance(consumer_repo, str) and consumer_repo
), "consumer_repo must be a non-empty string"
if consumer_repo not in CONSUMER_REPOS:
raise ValueError(
f"Unknown consumer repo {consumer_repo!r}. Allowed: {CONSUMER_REPOS}"
Expand Down
42 changes: 21 additions & 21 deletions scripts/runner_capacity_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,18 @@ def calculate_needed_runners(
Returns:
:class:`CapacityRecommendation` with suggested runner count.
"""
assert isinstance(queue_depth, int) and queue_depth >= 0, (
f"queue_depth must be a non-negative int, got {queue_depth!r}"
)
assert isinstance(current_runners, int) and current_runners > 0, (
f"current_runners must be a positive int, got {current_runners!r}"
)
assert isinstance(target_wait_sec, int) and target_wait_sec > 0, (
f"target_wait_sec must be a positive int, got {target_wait_sec!r}"
)
assert isinstance(avg_job_sec, int) and avg_job_sec > 0, (
f"avg_job_sec must be a positive int, got {avg_job_sec!r}"
)
assert (
isinstance(queue_depth, int) and queue_depth >= 0
), f"queue_depth must be a non-negative int, got {queue_depth!r}"
assert (
isinstance(current_runners, int) and current_runners > 0
), f"current_runners must be a positive int, got {current_runners!r}"
assert (
isinstance(target_wait_sec, int) and target_wait_sec > 0
), f"target_wait_sec must be a positive int, got {target_wait_sec!r}"
assert (
isinstance(avg_job_sec, int) and avg_job_sec > 0
), f"avg_job_sec must be a positive int, got {avg_job_sec!r}"

if queue_depth == 0:
return CapacityRecommendation(
Expand Down Expand Up @@ -341,16 +341,16 @@ def check_and_alert(
Advisory string: one of ``"OK"``, ``"WARN: ..."``, or ``"ALERT: ..."``.
"""
assert isinstance(token, str) and token, "token must be a non-empty string"
assert isinstance(current_runners, int) and current_runners > 0, (
f"current_runners must be a positive int, got {current_runners!r}"
)
assert (
isinstance(current_runners, int) and current_runners > 0
), f"current_runners must be a positive int, got {current_runners!r}"
assert isinstance(org, str) and org, "org must be a non-empty string"
assert isinstance(alert_threshold, int) and alert_threshold > 0, (
f"alert_threshold must be a positive int, got {alert_threshold!r}"
)
assert isinstance(target_wait_sec, int) and target_wait_sec > 0, (
f"target_wait_sec must be a positive int, got {target_wait_sec!r}"
)
assert (
isinstance(alert_threshold, int) and alert_threshold > 0
), f"alert_threshold must be a positive int, got {alert_threshold!r}"
assert (
isinstance(target_wait_sec, int) and target_wait_sec > 0
), f"target_wait_sec must be a positive int, got {target_wait_sec!r}"

queue_depth = get_queue_depth(token=token, org=org)
rec = calculate_needed_runners(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ def benchmark_file_loading(self) -> dict[str, dict[str, float | int]]:
elapsed = time.perf_counter() - start

# Validate all files loaded successfully
assert len(dataframes) == len(files), (
f"Expected {len(files)} dataframes, got {len(dataframes)}"
)
assert len(dataframes) == len(
files
), f"Expected {len(files)} dataframes, got {len(dataframes)}"

results["load_multiple_5_files"] = {
"time": elapsed,
Expand Down Expand Up @@ -225,9 +225,9 @@ def benchmark_filtering(self) -> dict[str, dict[str, float]]:
elapsed = time.perf_counter() - start

# Validate filter output
assert filtered_df is not None and len(filtered_df) == n_rows, (
f"Filter {filter_name} failed"
)
assert (
filtered_df is not None and len(filtered_df) == n_rows
), f"Filter {filter_name} failed"

throughput = n_rows / elapsed
results[f"filter_{filter_name}"] = {
Expand Down Expand Up @@ -384,9 +384,9 @@ def benchmark_end_to_end_workflow(self) -> dict[str, dict[str, float]]:
stats_time = time.perf_counter() - start

# Validate statistics output
assert stats is not None and "mean" in stats, (
"Statistics calculation failed"
)
assert (
stats is not None and "mean" in stats
), "Statistics calculation failed"

# Step 6: Save
start = time.perf_counter()
Expand Down Expand Up @@ -437,9 +437,9 @@ def benchmark_scalability(self) -> dict[str, dict[str, float]]:
elapsed = time.perf_counter() - start

# Validate filter output
assert filtered is not None and len(filtered) == n_rows, (
f"Scalability test failed for {n_rows} rows"
)
assert (
filtered is not None and len(filtered) == n_rows
), f"Scalability test failed for {n_rows} rows"

throughput = n_rows / elapsed

Expand Down Expand Up @@ -474,9 +474,9 @@ def benchmark_memory_usage(self) -> dict[str, dict[str, float]]:
filtered = self.processor.apply_filter(df, config)

# Validate filter was applied
assert filtered is not None and len(filtered) == n_rows, (
"Memory benchmark filter failed"
)
assert (
filtered is not None and len(filtered) == n_rows
), "Memory benchmark filter failed"

memory_after = self.get_memory_usage_mb()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def _create_high_performance_loader(self) -> HighPerformanceDataLoader | None:
try:
loader_class = self._import_high_performance_loader()
return loader_class()
except Exception as exc: # noqa: BLE001 - optional accelerator, any failure degrades
except (
Exception
) as exc: # noqa: BLE001 - optional accelerator, any failure degrades
logger.warning(
"High-performance loader unavailable; using standard loader: %s",
exc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def test_worker_runs_off_main_thread(qtbot: Any, sample_df: pd.DataFrame) -> Non

assert results == [{"ok": True, "rows": 100}]
assert trainer.train_thread is not None
assert trainer.train_thread != main_thread_id, (
"train() ran on the Qt main thread β€” UI would freeze"
)
assert (
trainer.train_thread != main_thread_id
), "train() ran on the Qt main thread β€” UI would freeze"


def test_worker_ui_stays_responsive(qtbot: Any, sample_df: pd.DataFrame) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,19 @@ def test_output_columns_preserved(
) -> None:
df = _make_df(n=300)
result = engine.apply_filter_batch(df, filter_type, params)
assert list(result.columns) == list(df.columns), (
f"{filter_type}: columns changed"
)
assert list(result.columns) == list(
df.columns
), f"{filter_type}: columns changed"

@pytest.mark.parametrize("filter_type,params", FILTER_TYPES)
def test_output_row_count_preserved(
self, engine, filter_type: str, params: dict
) -> None:
df = _make_df(n=300)
result = engine.apply_filter_batch(df, filter_type, params)
assert len(result) == len(df), (
f"{filter_type}: row count changed {len(result)} != {len(df)}"
)
assert len(result) == len(
df
), f"{filter_type}: row count changed {len(result)} != {len(df)}"


class TestMovingAverageCorrectness:
Expand Down Expand Up @@ -210,9 +210,9 @@ def test_nan_rows_remain_nan(self, engine, filter_type: str, params: dict) -> No
nan_after = result["x"].index[result["x"].isna()]
# All original NaN positions should still be NaN
for idx in nan_idx:
assert idx in nan_after, (
f"{filter_type}: NaN at index {idx} was filled unexpectedly"
)
assert (
idx in nan_after
), f"{filter_type}: NaN at index {idx} was filled unexpectedly"


class TestParallelVsSequentialConsistency:
Expand Down
12 changes: 6 additions & 6 deletions src/flow_rate_converter/tests/test_flow_rate_converter_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def test_lod_constants_present_in_source(self):
if isinstance(target, ast.Name):
top_level_names.add(target.id)

assert "_ALIGN_CENTER" in top_level_names, (
"Missing _ALIGN_CENTER constant in main_window"
)
assert "_EXPANDING" in top_level_names, (
"Missing _EXPANDING constant in main_window"
)
assert (
"_ALIGN_CENTER" in top_level_names
), "Missing _ALIGN_CENTER constant in main_window"
assert (
"_EXPANDING" in top_level_names
), "Missing _EXPANDING constant in main_window"
assert "_FIXED" in top_level_names, "Missing _FIXED constant in main_window"

def test_no_bare_qt_alignment_flag_chain_in_source(self):
Expand Down
6 changes: 3 additions & 3 deletions src/humanoid_builder_gui/tests/test_humanoid_builder_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ def test_no_deep_attribute_chains_in_method_body(
)
matches = pattern.findall(source)
# Only the alias definitions should match (7 lines)
assert len(matches) <= 7, (
f"Unexpected deep attribute chains found: {matches}"
)
assert (
len(matches) <= 7
), f"Unexpected deep attribute chains found: {matches}"
except ImportError:
pytest.skip("PyQt6 not available in this environment")
4 changes: 3 additions & 1 deletion src/lower_body_model/launch_pyqt6.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ def on_torque_imported(self, joint_name: str, coeffs: object) -> None:
c = [float(x) for x in coeffs]
self.sim.set_joint_polynomial(joint_name, c)
logging.info(f"Imported torque polynomial for {joint_name}: {c}")
except Exception as e: # noqa: BLE001 β€” caller-supplied data may be any type
except (
Exception
) as e: # noqa: BLE001 β€” caller-supplied data may be any type
logging.error(f"Failed to set polynomial: {e}")

def physics_loop(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

# Mathematical constants
PI: float = math.pi # [dimensionless] Ratio of circumference to diameter
E: float = 2.718281828459045 # [dimensionless] Euler's number, base of natural logarithm # noqa: E501
E: float = (
2.718281828459045 # [dimensionless] Euler's number, base of natural logarithm # noqa: E501
)

# Physical constants - SI units
GRAVITY_M_S2: float = 9.80665 # [m/sΒ²] Standard gravity, ISO 80000-3:2006
Expand Down
28 changes: 21 additions & 7 deletions src/movement_optimizer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ def _add_body_args(parser: argparse.ArgumentParser) -> None:
"--body-mass",
type=float,
default=75.0,
help=(f"Body mass in kg (range {BODY_MASS_RANGE[0]}-{BODY_MASS_RANGE[1]}, default: 75.0)."),
help=(
f"Body mass in kg (range {BODY_MASS_RANGE[0]}-{BODY_MASS_RANGE[1]}, default: 75.0)."
),
)
parser.add_argument(
"--height",
type=float,
default=1.75,
help=(f"Height in metres (range {HEIGHT_RANGE[0]}-{HEIGHT_RANGE[1]}, default: 1.75)."),
help=(
f"Height in metres (range {HEIGHT_RANGE[0]}-{HEIGHT_RANGE[1]}, default: 1.75)."
),
)
parser.add_argument(
"--bar-mass",
Expand Down Expand Up @@ -99,7 +103,9 @@ def _add_run_args(parser: argparse.ArgumentParser) -> None:
default=None,
help="Path to save results as JSON. If omitted, prints summary to stdout.",
)
parser.add_argument("--verbose", action="store_true", help="Enable verbose logging.")
parser.add_argument(
"--verbose", action="store_true", help="Enable verbose logging."
)


def _build_parser() -> argparse.ArgumentParser:
Expand Down Expand Up @@ -263,7 +269,9 @@ def _build_optimizer(
return opt, dyn


def _save_or_emit(result: OptimizationResult, exercise: str, output: str | None) -> None:
def _save_or_emit(
result: OptimizationResult, exercise: str, output: str | None
) -> None:
"""Write result to file or emit summary to stdout.

Args:
Expand All @@ -279,7 +287,9 @@ def _save_or_emit(result: OptimizationResult, exercise: str, output: str | None)
_emit_cli_summary(_result_to_summary(result, exercise))


def _validate_cli_args(parser: argparse.ArgumentParser, args: argparse.Namespace) -> None:
def _validate_cli_args(
parser: argparse.ArgumentParser, args: argparse.Namespace
) -> None:
"""Reject invalid numeric CLI arguments via parser.error.

Delegates to :func:`movement_optimizer.validation.validate_all` so the
Expand Down Expand Up @@ -338,9 +348,13 @@ def main(argv: list[str] | None = None) -> int:
_configure_logging(args.verbose)
body = BodyModel(body_mass=args.body_mass, height=args.height)
duration = _resolve_duration(args.exercise, args.duration)
_log_optimization_start(args.exercise, args.body_mass, args.height, args.bar_mass, duration)
_log_optimization_start(
args.exercise, args.body_mass, args.height, args.bar_mass, duration
)
t_start = time.perf_counter()
opt, _dyn = _build_optimizer(body, args.exercise, args.bar_mass, duration, args.smoothness)
opt, _dyn = _build_optimizer(
body, args.exercise, args.bar_mass, duration, args.smoothness
)
result = opt.optimize()
_log_optimization_done(time.perf_counter() - t_start, result.cost, result.success)
_save_or_emit(result, args.exercise, args.output)
Expand Down
4 changes: 3 additions & 1 deletion src/movement_optimizer/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@
# ~7 mm for a 1.75 m person β€” effectively a grip-only link.
WRIST_SEGMENT_FRAC: float = 0.01

BENCH_UPPER_ARM_FRAC: float = 0.56 # shoulder to elbow (anatomical ~48% + shoulder width)
BENCH_UPPER_ARM_FRAC: float = (
0.56 # shoulder to elbow (anatomical ~48% + shoulder width)
)
BENCH_FOREARM_FRAC: float = 0.44 # elbow to wrist (Winter 2009: ~44% of arm length)

BENCH_PRESS_JOINT_LIMITS: dict[str, tuple[float, float]] = {
Expand Down
4 changes: 3 additions & 1 deletion src/movement_optimizer/exercises/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def balance_config_pose(
adjust_joint: int,
) -> NDArray:
"""Balance a raw pose using the shared planar balance helper."""
return balance_pose(dynamics, raw_pose, exercise_type, bar_mass, adjust_joint=adjust_joint)
return balance_pose(
dynamics, raw_pose, exercise_type, bar_mass, adjust_joint=adjust_joint
)


def default_bounds_deg(
Expand Down
4 changes: 3 additions & 1 deletion src/movement_optimizer/exercises/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def make_clean_config(
dyn = LagrangianDynamics(body, body.m_deadlift.copy(), body.I_deadlift.copy(), load)

q_start_raw = pull_start_angles(body, q2_deg=52)
q_start = balance_config_pose(dyn, q_start_raw, "deadlift", bar_mass, adjust_joint=0)
q_start = balance_config_pose(
dyn, q_start_raw, "deadlift", bar_mass, adjust_joint=0
)

q_end_raw = _clean_end_angles(body)
q_end = balance_config_pose(dyn, q_end_raw, "deadlift", bar_mass, adjust_joint=2)
Expand Down
Loading
Loading