Skip to content

Conversation

@pavelacamposp
Copy link
Owner

This PR improves the flexibility of plot functions by adding support for dynamic setpoint lines that vary over time. Additionally, it centralizes plot data validation in plot functions.

Key changes:

  • Modified plot functions in data_visualization.py to support time-varying setpoints.
  • Centralized plot data validation in data_visualization.py.
  • Updated example scripts to align with the new plot function signatures.
  • Updated unit and integration tests to reflect these changes.

- Modify plot functions in `data_visualization.py` to accept
  setpoint data of shape (T, n) instead of (n, 1) arrays, where
  `T` is the number of time steps and `n` is the number of setpoint
  dimensions. This allows plotting dynamic setpoint lines that vary
  over time.
- Update example scripts (`lti_dd_mpc_example.py`,
  `nonlinear_dd_mpc_example.py`) to construct setpoint data
  matrices from controller input-output setpoints and pass them to
  the updated plot functions.
- Update test scripts to align with these changes.
- Centralize plot data validation in `data_visualization.py`:
  - Add `validate_data_dimensions` to validate the dimensions of
    input-output data arrays, and bound and ylimit lists.
  - Update `plot_input_output` and `plot_input_output_animation`
    functions to use `validate_data_dimensions` for plot data
    validation.
- Add unit tests for `validate_data_dimensions` in
  `test_data_visualization.py` and remove redundant test
  `test_plot_input_output_mismatched_dim_len`.
@pavelacamposp pavelacamposp self-assigned this Jun 4, 2025
@pavelacamposp
Copy link
Owner Author

All checks have passed and the new functionality looks good. Merging now.

@pavelacamposp pavelacamposp merged commit b9dfbc7 into main Jun 4, 2025
4 checks passed
@pavelacamposp pavelacamposp deleted the feature/varying-setpoint-plots branch June 4, 2025 20:15
pavelacamposp added a commit that referenced this pull request Jun 5, 2025
Update the reproduction script to construct setpoint data matrices
from controller input-output setpoints and pass them to the
reproduction plot function, which uses plot functions updated in
PR #17.

This prevents the error `ValueError: Shape mismatch.` and ensures
compatibility with the updated plot utilities.
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.

2 participants