Skip to content

Use configured observations in Pinball and fix render() - #363

Open
NopeCharon wants to merge 2 commits into
dynamicslab:mainfrom
NopeCharon:fix/pinball-observations-render
Open

NopeCharon wants to merge 2 commits into
dynamicslab:mainfrom
NopeCharon:fix/pinball-observations-render

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Closes #361

Changes

  • Removed the Pinball.get_observations() override. It always returned lift/drag and skipped the ObservationFunction that FlowConfig builds from observation_type. num_outputs, and so FlowEnv.observation_space, still followed observation_type, so probe observations came back with the wrong length. The inherited method returns the same (CL1, CL2, CL3, CD1, CD2, CD3) for the default lift_drag, so default behaviour doesn't change.
  • Pinball.render() used self.flow.*, but Pinball is itself the flow and has no flow attribute. It now uses its own attributes, like the other Firedrake flows, and turns the radius Constant into a float for matplotlib.
  • Added test_probe_observations (velocity probes through FlowEnv) and test_render to test/test_pinball.py.
  • Fixed the documented order of the Pinball lift_drag observation in the getting-started docs and README. They listed (CL1, CD1, CL2, CD2, CL3, CD3).

Validation

All runs used the firedrakeproject/firedrake-vanilla-default container.

  • On main, test_probe_observations fails ((6,) == (12,)), and so does test_render (AttributeError: 'Pinball' object has no attribute 'flow'). Both pass with this change.
  • gymnasium.utils.env_checker.check_env on a velocity-probe Pinball env: on main it fails with "The first element returned by env.reset() is not within the observation space". With this change it gets past the observation checks. It then stops on a separate check, because FlowEnv.reset() doesn't call super().reset(seed=seed). That's out of scope here.
  • render() draws the vorticity field and all three cylinders in the right places.
  • test_import_fine, test_steady, test_integrate and test_control pass. test_steady_rotation (wrong CL) and test_env (no dt passed to SemiImplicitBDF) fail the same way on main.
  • ruff check, ruff format --check, isort --check-only and codespell pass.

NopeCharon and others added 2 commits October 29, 2026 02:21
Pinball overrode get_observations() to always return the lift and drag
coefficients, bypassing the ObservationFunction that FlowConfig builds
from observation_type. num_outputs, and therefore the FlowEnv
observation space, still followed observation_type, so with probe
observations the environment returned 6 values for an observation space
of 2 * len(probes) entries and failed gymnasium's env checker. Drop the
override: the inherited FlowConfig.get_observations() already returns
(CL1, CL2, CL3, CD1, CD2, CD3) for the default "lift_drag" observation,
so the default behaviour is unchanged.

Pinball.render() referred to self.flow.u, self.flow.pressure_space,
self.flow.x0, self.flow.y0 and self.flow.rad, but Pinball is itself the
flow and has no flow attribute, so every call raised AttributeError.
Use the instance attributes, matching the other Firedrake flows, and
convert the radius Constant to a float for matplotlib.

Add tests for probe observations through FlowEnv and for render(), and
correct the documented ordering of the Pinball lift_drag observation.

Closes dynamicslab#361

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Pinball ignores observation_type and render() raises AttributeError

2 participants