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

Update perturbIC.py #5

Merged
merged 138 commits into from
Jan 28, 2025
Merged

Update perturbIC.py #5

merged 138 commits into from
Jan 28, 2025

Conversation

leoberhelman
Copy link
Contributor

This is a draft of a pull request to keep track of comments and questions I will have during refactoring and testing. Nothing yet but I am creating my unit tests.

@leoberhelman leoberhelman self-assigned this Oct 16, 2024
@leoberhelman leoberhelman linked an issue Oct 16, 2024 that may be closed by this pull request
@MartinDix
Copy link
Contributor

I can't work out why I specified it this way. In any case RandomState is no longer the recommended generator and the more up to date way of doing it would be

from numpy.random import Generator, PCG64
rg = Generator(PCG64(seed))
.. .rg.random(...)

This will give different results to the current implementation but will be stable in the future. PCG64 is currently the default bit generator but that could change so it's used explicitly here.

@leoberhelman leoberhelman marked this pull request as ready for review November 5, 2024 22:55
@leoberhelman
Copy link
Contributor Author

Fixes Issue #8 #4 #6

@atteggiani
Copy link
Collaborator

atteggiani commented Nov 13, 2024

Fixes Issue #8 #4 #6

I think this would not work. You will have to write the issues in separate lines, e.g.:

Fixes #8
Fixes #4
Fixes #6

Also, I would write them in the main text of the PR to be more visible (I'm also not sure if they would even work within a comment).

Copy link
Collaborator

@atteggiani atteggiani left a comment

Choose a reason for hiding this comment

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

Thank you for this PR @leoberhelman!

Overall I think you did a pretty good job restructuring and refactoring the code into functional portions that can be easily tested! Well done!

I left many comments, but please don't get scared by their amount:

  • Many of them are minor corrections to docstrings or function/variable names that I think would make the code clearer
  • Some are related to the python environment and CI, which have good structures but might be restructured a bit
  • Some are related to the structure and performance of some functions and of the overall main function

I have not reviewed the unit-testing file (perturbIC_test.py), because I believe some tests will need modifications after the suggested restructuring.
Therefore, I think it might be better you to address the comments first, and change the tests accordingly. Then, I can re-review everything including the tests.

I tried to leave comments and explain most of my suggestions, but feel free to comment back for further explanations, or ask me directly.

Copy link
Contributor Author

@leoberhelman leoberhelman left a comment

Choose a reason for hiding this comment

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

I made the changes and a few more to correct some errors. Still need to update the unit tests

Copy link
Collaborator

@atteggiani atteggiani left a comment

Choose a reason for hiding this comment

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

Thank you @leoberhelman for the amazing work restructuring this after my extensive review!

I added a few other minor suggestions. Please refer to the specific comments.

Two important points:

  • I am going to open up a PR with a revision of the testing suite. That can also serve as a guideline an example for future testing suites.
    As a consequence, there is no need to address the specific comment I left regarding the test_create_default_outname function. I will include that part in my testing-suite PR. The test_create_default_outname comment should be viewed as an example of a testing approach.
  • With the restructuring of the repo and creation of the original branch, I think the main branch should now only include the portions of the codebase we are restructuring, and potentially be in a "releasable" state (in the not-too-far future). Therefore, I would delete all the scripts that we are not using from this branch.
    Namely, I would only keep the perturbIC.py script (moving it inside the umfile_utils folder, along with the already present _version.py and __init__.py files) while movind the README.md at the top-level of the repo.
    Note that, after this restructure, some minor modifications might be needed with the imports (from perturbIC import ... should become from umfile_utils.perturbIC for example). Also, in the pyproject.toml file the following lines should be added to ensure pytest works correctly:
    [tool.pytest.ini_options]
    pythonpath = "src"

Copy link
Collaborator

@atteggiani atteggiani left a comment

Choose a reason for hiding this comment

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

Just added another comment

@atteggiani atteggiani self-requested a review January 21, 2025 10:46
Copy link
Collaborator

@atteggiani atteggiani left a comment

Choose a reason for hiding this comment

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

Looks good!

Thank you @leoberhelman for your great work on this!

Copy link
Collaborator

@atteggiani atteggiani left a comment

Choose a reason for hiding this comment

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

I have another comment that I thought about when reviewing the subset function.

@atteggiani atteggiani mentioned this pull request Jan 23, 2025
atteggiani
atteggiani previously approved these changes Jan 27, 2025
Copy link
Collaborator

@atteggiani atteggiani left a comment

Choose a reason for hiding this comment

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

LGTM!

Update perturbIC.py

Can the random generator be simplified?

Refactored changes to the perturbIC. Most of the code is not in smaller functions. The descriptions are still in progress.

Update perturbIC.py

Added more documentation and created variables for the integers
Adding the pytests
Create the necessary environments for testing for 3.10

Update environment-3.10.yml
Create the environment for Python 3.11

Update environment-3.11.yml
leoberhelman and others added 23 commits January 28, 2025 13:43
Minor comments

Co-authored-by: Davide Marchegiani <[email protected]>
Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Random seed but need to discuss more about how to restrict parameters

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>

Update perturbIC.py
Condensing the environment files into one file.

Update environment-dev.yml

Update environment-dev.yml
Co-authored-by: Davide Marchegiani <[email protected]>
Co-authored-by: Davide Marchegiani <[email protected]>
Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>
Co-authored-by: Davide Marchegiani <[email protected]>
Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>
Co-authored-by: Davide Marchegiani <[email protected]>
Co-authored-by: Davide Marchegiani <[email protected]>

Update src/perturbIC.py

Co-authored-by: Davide Marchegiani <[email protected]>
Update to unit tests

Update perturbIC.py
It was failing dues to  hypothesis.errors.InvalidArgument:
Co-authored-by: Davide Marchegiani <[email protected]>
@atteggiani atteggiani force-pushed the lindsey/4-requirements-for-perturbic branch from fce0537 to c83b74e Compare January 28, 2025 02:51
Update perturbIC.py
@atteggiani atteggiani force-pushed the lindsey/4-requirements-for-perturbic branch from c83b74e to e8a0be2 Compare January 28, 2025 02:52
@atteggiani atteggiani merged commit d5add57 into main Jan 28, 2025
3 checks passed
@atteggiani atteggiani deleted the lindsey/4-requirements-for-perturbic branch January 28, 2025 03:02
@atteggiani
Copy link
Collaborator

Thank you so much for the work on this @leoberhelman!
Merged.

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.

Requirements for perturbIC.py
3 participants