Skip to content

Conversation

radka-j
Copy link
Member

@radka-j radka-j commented Jun 11, 2025

Closes #414

Overview

This PR:

  • primarily just moves new base Simulator from 414 combine simulator implementations #485 with associated tests and updates to learners
  • removes the output_variables argument as input to Simulator as it was specific to the NaghaviSimulator implementation rather than a generic simulator argument
  • updates ActiveLearning notebook to use this Simulator
  • adds a Projectile and Epidemic simulators

I left updates to NaghaviSimulator to be tackled as a separate PR (see discussion in #492).

Questions

  • When creating this PR I run into an issue when the sample_inputs method started retuning tensors of float64 whereas everywhere else in the code base the tensors are float32 (this is the torch default). I have no idea why this happened and it made me think we might want to enforce consistency of types across the codebase. This could be us picking a type to stick to or enforcing a type based on inputs. Should we open an issue for that?

radka-j and others added 2 commits June 10, 2025 15:35
@codecov-commenter
Copy link

codecov-commenter commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 79.25532% with 39 lines in your changes missing coverage. Please review.

Project coverage is 76.55%. Comparing base (e31bcf1) to head (4f587d7).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
autoemulate/experimental/simulations/projectile.py 0.00% 24 Missing ⚠️
autoemulate/experimental/simulations/epidemic.py 0.00% 14 Missing ⚠️
autoemulate/experimental/simulations/base.py 98.24% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #520      +/-   ##
==========================================
- Coverage   81.90%   76.55%   -5.36%     
==========================================
  Files         107      113       +6     
  Lines        7571     8270     +699     
==========================================
+ Hits         6201     6331     +130     
- Misses       1370     1939     +569     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

github-actions bot commented Jun 11, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  autoemulate/emulators
  gaussian_process.py
  autoemulate/experimental/learners
  base.py
  autoemulate/experimental/simulations
  base.py 40
  epidemic.py 1-39
  projectile.py 1-76
  tests
  test_compare.py
  tests/experimental
  test_experimental_base_simulator.py
  test_learners.py
Project Total  

This report was generated by python-coverage-comment-action

@radka-j radka-j requested review from EdwinB12 and sgreenbury June 11, 2025 14:12
This was referenced Jun 11, 2025
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the new cell outputs might need to be included here given the current way the docs are published without rerunning with jupyterbook.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed them because when I run the notebook and committed the output I got a git error complaining about the commit size.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point - as discussed opened #538 to look at a solution for this.

Copy link
Collaborator

@sgreenbury sgreenbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks really great, thanks @radka-j @EdwinB12! I left a couple of small comments in the code but otherwise think this looks good to merge.

Comment on lines +86 to +89
# TODO: have option to set dtype and ensure consistency throughout codebase?
# added here as method was returning float64 and elsewhere had tensors of
# float32 and this caused issues
return torch.tensor(sample_array, dtype=torch.float32)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be great to potentially have a default constant somewhere (e.g. DEFAULT_DTYPE: torch.dtype = torch.float32) that we can import to use such as here. We might also consider adding API to e.g. the base simulator/emulators so that dtype= can be provided. Perhaps this would be good to handle in a new issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, I created issue #537 for this

Comment on lines 11 to 18
class SimulatorMetadata:
"""
Simulation metadata.

NOTE: the output metadata is going to get more complex. e.g.:
- indicate if output is temporal
- indicate if output is spatial
- ...
Copy link
Collaborator

@sgreenbury sgreenbury Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following on from discussion/question in the PR - it seems like this separate class might be currently not providing much use and could be brought into the base simulator.

The comment regarding the complexity that will increase with different data types is important and perhaps a refactor around a common metadata into a base class and data-type specific metadata (e.g. tabular data or spatio-temporal data) would be useful at that point.

Perhaps it would be worth opening an issue specifically for the spatio-temporal simulator as an enhancement? (we currently have #459 that I think is more focussed on the emulator aspect)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class has been removed for now. I think the enhancement could be done as part of #472

@radka-j radka-j merged commit 97df2d7 into main Jun 17, 2025
4 checks passed
@radka-j radka-j deleted the experimental_sim branch June 25, 2025 14:39
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.

Refactor: combine simulator implementations

3 participants