PlotSpecEccentricityControl#6
Open
vtommasini wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new plotting utility (PlotSpecEccentricityControl) modeled after SpEC’s eccentricity-control plotting, along with a Gaussian Process Regression helper module and accompanying tests.
Changes:
- Introduces
src/SimulationSupport/PlotSpecEccentricityControl.pyto generate eccentricity-vs-iteration, trajectory, and iteration-count plots. - Adds a GPR training/prediction pipeline in
src/SimulationSupport/gpr.py(and a duplicate root-levelGPR_library.py). - Adds unit tests for the plotting helpers and GPR pipeline.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
src/SimulationSupport/PlotSpecEccentricityControl.py |
New plotting + parsing + CLI code for eccentricity-control visualizations. |
src/SimulationSupport/gpr.py |
New GPR model, training loop, prediction, and pipeline helper. |
tests/test_PlotSpecEccentricityControl.py |
New tests for plot/data helper functions (currently not collected by pytest config). |
tests/test_gpr.py |
New tests for GPR functions (currently not collected; also imports wrong module path). |
GPR_library.py |
Duplicate GPR implementation at repo root (not packaged under src/). |
TestGPRLibrary.py |
Additional test file at repo root (not executed by pytest due to testpaths). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+208
to
+212
| if loss.item() < best_loss: | ||
| best_loss = loss.item() | ||
| best_state = model.state_dict().copy() | ||
|
|
||
| # Load the best model state after training |
Comment on lines
+25
to
+29
| def setUp(self): | ||
| self.test_dir = Path("SimulationSupport") / "gpr_library_tests" | ||
|
|
||
| # Clean up any existing test directory and create a new one | ||
| shutil.rmtree(self.test_dir, ignore_errors=True) |
|
|
||
| sizes = 80 * counts_df["Iterations"] | ||
| unique_sims = counts_df["Sim"].unique() | ||
| color_map = dict(zip(unique_sims, plt.cm.tab20.colors[: len(unique_sims)])) |
Comment on lines
+319
to
+320
| grouped[sim].append(root / Path(path)) | ||
| return grouped |
Comment on lines
+1
to
+5
| # Distributed under the MIT License. | ||
| # See LICENSE.txt for details. | ||
|
|
||
| # Unit test for GPR_library.py | ||
| # Generate a simple, synthetic regression problem and run the pipeline |
Comment on lines
+234
to
+237
| # Normalize the input using the model's stored parameters | ||
| normalized_X = (raw_X - model.input_mean) / model.input_std | ||
| X_tensor = torch.from_numpy(normalized_X).float() | ||
|
|
Comment on lines
+4
to
+8
| """ | ||
| Unit test for gpr.py | ||
| Generate a simple, synthetic regression problem and run the pipeline | ||
| Assert that the shapes are reasonable, uncertainties are positive, and | ||
| that the mean predictions are within a reasonable range of the true values |
Comment on lines
+657
to
+658
| fig (matplotlib.figure.Figure): Figure containing the plot | ||
| ax (matplotlib.axes.Axes): Axis |
Comment on lines
+16
to
+20
| from gpr import ( | ||
| predict_with_gpr_model, | ||
| run_gpr_pipeline, | ||
| train_gpr_model, | ||
| ) |
| model | ||
| likelihood | ||
| Y_pred | ||
| uncertainties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modeled after Spectre's PlotEccentricityControl.py
Makes the three plots below: