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

keep pyattrs on compute_from_hier #919

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

PhilipDeegan
Copy link
Member

@PhilipDeegan PhilipDeegan commented Oct 25, 2024

closes #918

Summary by CodeRabbit

  • New Features

    • Enhanced simulation testing with additional assertions to verify patch attributes.
    • Updated simulation duration and timestamps for improved accuracy.
  • Bug Fixes

    • Adjusted simulation parameters to ensure correct output validation.
  • Documentation

    • Improved clarity in test code formatting and structure.

Copy link

coderabbitai bot commented Oct 25, 2024

📝 Walkthrough

Walkthrough

The changes primarily involve modifications to the new_patches_from function in hierarchy_utils.py, where the iteration over patches is simplified by using enumeration instead of length-based looping. Additionally, the attributes of the original patches are now preserved in newly created Patch instances. In test_run.py, simulation parameters are adjusted, and additional assertions are added to validate the attributes of patches returned by the GetB method, enhancing the testing framework without altering the overall logic.

Changes

File Path Change Summary
pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py Modified new_patches_from to use enumeration for iterating over patches; preserved attrs in new Patch instances.
tests/simulator/test_run.py Updated final_time from 0.1 to 0.05, adjusted timestamps, added assertions in test_run, and reorganized import statements.

Assessment against linked issues

Objective Addressed Explanation
Ensure patch attributes are not empty when all_primal is True (918) It's unclear if the changes directly address the issue regarding patch attributes.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
tests/simulator/test_run.py (1)

237-241: Consider more robust verification methods.

The current approach of verifying file existence and minimum size might be fragile. Consider:

  1. Using content-based verification instead of size-based checks
  2. Implementing proper cleanup of generated files in tearDown
  3. Adding explicit error messages explaining why a particular size threshold was chosen
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 52e733e and 2558d44.

📒 Files selected for processing (2)
  • pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py (1 hunks)
  • tests/simulator/test_run.py (2 hunks)
🔇 Additional comments (4)
tests/simulator/test_run.py (2)

223-229: Well-structured test additions addressing the core issue.

The new assertions effectively verify that patch attributes are preserved in both all_primal=True and all_primal=False cases, directly addressing the issue described in #918.


19-21: Verify the impact of reduced simulation time.

The simulation time has been halved from 0.1 to 0.05. While this might improve test execution speed, please verify that this shorter duration is sufficient to capture all relevant physics phenomena and test scenarios.

✅ Verification successful

Reduced simulation time is appropriate for this test case

The codebase analysis shows that different tests use varying time configurations based on their specific testing needs:

  • Most unit tests in tests/simulator/ use small time steps (0.001-0.005) and short durations
  • Only functional tests (e.g., dispersion.py, translation1d.py) use longer durations (20.0-100.0) for physics validation

The change from 0.1 to 0.05 in test_run.py is consistent with other unit tests' time scales and appears sufficient for testing the patch attributes functionality, which is the focus of this PR.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other tests that might be using similar time configurations
rg -l "final_time\s*=\s*0\.1" tests/

Length of output: 38


Script:

#!/bin/bash
# Let's try a broader search for time configurations in tests
rg -l "final_time\s*=" tests/

# Also search for timestamp configurations
rg -l "timestamps\s*=" tests/

# Look for any numerical time values in test files
rg "time.*=.*0\.[0-9]+" tests/

Length of output: 4714

pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py (2)

195-196: LGTM! More Pythonic iteration style.

The change to use enumeration directly over patches improves code readability while maintaining the same functionality.


202-204: LGTM! Preserves patch attributes as intended.

This change correctly addresses the issue by ensuring patch attributes are preserved when creating new patches. This fixes the problem described in issue #918 where patch attributes were empty when all_primal=True.

@nicolasaunai nicolasaunai merged commit e61b34c into PHAREHUB:master Oct 27, 2024
12 checks passed
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.

patch attrs empty when all_primal True
2 participants