-
Notifications
You must be signed in to change notification settings - Fork 75
Fix adaptive refinement #571
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
Conversation
5e9ccc6
to
ca57ef0
Compare
Code Coverage Summary
Results for commit: 2a316a8 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes issue #539 by refactoring the adaptive refinement functionality and updating the related tests and documentation. Key changes include the migration of the R3Refinement callback to a new module structure, the removal of the deprecated adaptive_refinement_callback, and an addition of a dataset update method to support the new refinement logic.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
tests/test_callback/test_adaptive_refinement_callback.py | Updated imports and test functions for the new R3Refinement callback, including a keyword change from "callback" to "callbacks". |
pina/data/dataset.py | Added update_data() method to enable dataset updates with new conditions. |
pina/callback/refinement/refinement_interface.py | Introduced the new refinement interface with adaptive point updating logic. |
pina/callback/refinement/r3_refinement.py | Implemented the R3Refinement callback for adaptive point sampling. |
pina/callback/adaptive_refinement_callback.py | Removed the deprecated adaptive refinement callback implementation. |
pina/callback/init.py | Updated callback exports to reflect the new module structure. |
docs | Revised documentation to reference updated module paths for refinement callbacks. |
@dario-coscia I fixed codacy warnings in your code! Let me know if the changes are ok! |
Great! Code-wise and test, I think we are ready to go. Would you mind adjusting the docstrings ? |
@dario-coscia Done! |
For me is good to go, @GiovanniCanali what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice update! I left few comments to address before merging.
pina/data/dataset.py
Outdated
parameter. | ||
|
||
:param dict new_conditions_dict: Dictionary containing the new data. | ||
:type new_conditions_dict: dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove :type new_conditions_dict: dict
, as type is already specified in the previous line.
:param ~lightning.pytorch.trainer.trainer.Trainer: The trainer object. | ||
:param PINNInterface solver: The solver object. | ||
""" | ||
if trainer.current_epoch % self.sample_every == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would modify this control as follows:
if (trainer.current_epoch % self.sample_every == 0) and (trainer.current_epoch != 0)
This is done to avoid resampling after the first epoch.
:param solver: The solver object. | ||
:return: New points sampled based on the R3 strategy. | ||
:rtype: LabelTensor | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add parameters' type to this docstring.
Description
This PR fixes #539
Checklist