Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optview rewrite #291

Draft
wants to merge 113 commits into
base: main
Choose a base branch
from
Draft

Optview rewrite #291

wants to merge 113 commits into from

Conversation

lamkina
Copy link
Contributor

@lamkina lamkina commented Apr 4, 2022

Purpose

This PR introduces a new version of OptView that uses an MVC design pattern and PtQt6, built on the pyOptSparse history file api. This new version will fully replace the old version of OptView and add PyQt6 and matplotlib as dependencies if installed with the pip install .[optview] tag. OpenMDAO case recorder files will no longer be supported in the new version. Features include:

  • Updated user interface.
  • Command line interface for adding files on startup.
  • Support for multiple history files.
  • Support for plotting major and minor iterations.
  • Ability to add multiple plots and configure them individually.
  • Optimization problem metadata viewer with searchable options list.
  • Support for multiple plotting tabs that can support up to three subplots each.
  • Default niceplots formatting for matplotlib.
  • Support for saving plots as pdf, pgf, jpeg, png, and eps using the matplotlib Qt5Agg backend.
  • Plot configuration toolbar from the matplotlib Qt5Agg backend.
  • All classes and functions are fully documented with docstrings and comments!

Expected time until merged

This PR is quite large and introduces a lot of postprocessing functionality that did not previously exist. This PR will take a long time and likely sit as a draft for a while as people test it out and give feedback.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

This change will not affect the main functionality of pyOptSparse, but will completely replace the old version of OptView.

Testing

This PR introduces a working version of the new OptView, but still needs lots of test coverage. I plan to add tests for each function in the future, but for now, to check out the functionality, do these steps:

  1. Navigate to the postprocessing directory.
  2. Run python OptView.py in a terminal.

Checklist

  • I have run flake8 and black to make sure the code adheres to PEP-8 and is consistently formatted
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@lamkina
Copy link
Contributor Author

lamkina commented Apr 8, 2022

Just pushed new commits with the following updates and features:

  • Data is now loaded when the file is loaded. This takes slightly more time up front but makes most other operations quicker.
  • Variable groups are now parsed by index and displayed with a color code in the plot configuration window.
  • Custom labels can be added for variables that will also show up in the legend.
  • When removing variables from the plot, the background color will reset to the system default.
  • You can now add and remove batches of variables at once using multi-selection.
  • When searching variables or metadata options, the data will now auto-filter to show you only relevant results.
  • The variables are now sorted first by name and second by index
  • The variable index is now displayed along with the variable.
  • A small display was added to the main window to see what files are already loaded.
  • You will now be prompted to enter a refresh interval time when the auto-refresh feature is turned on.
  • Many bug fixes to minor/major iteration handling and plotting.

…erations. Also refactored the file and variable data structures to be more pythonic
@lamkina
Copy link
Contributor Author

lamkina commented May 15, 2022

Lates commit update:

  • Added legend configuration tab to the matplotlib toolbar figure options.
  • Legend can be made draggable in the configuration options.
  • Refactored the File and Variable data structures to be more useful and efficient.
  • Added dark mode using the qdarkstyle package. I couldn't find a better way to do this because Qt doesn't inherit the system theme for MacOS. If we don't want the extra dependency this can easily be removed and stick with light mode only.

@lamkina
Copy link
Contributor Author

lamkina commented May 17, 2022

New Additions:

  • Keyboard shortcuts
    • ctrl+f: Figure parameters dialog
    • ctrl+s: Save figure dialog
    • ctrl+o: Load file dialog
    • ctrl+p: Add plot
    • ctrl+t: Format figure with a "tight layout"
    • ctrl+shift+h: Re-center the figure
  • Plot order is now configurable
    • The order of subplots can be changed by dragging and dropping the list items.
    • This can also be done by selecting the plot list item you want to move and pressing ctrl+up and ctrl+down

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants