Skip to content

Conversation

@UCaromel
Copy link
Contributor

@UCaromel UCaromel commented Jul 3, 2025

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Jul 3, 2025

📝 Walkthrough

Walkthrough

The plot1d method in the PatchHierarchy class was completely rewritten. The new implementation adds dynamic defaults for plotting quantities and levels, extensive customization of plot styles via keyword arguments, improved handling of ghost cells, and optional visualization of patch boundaries and extents. The method now returns the figure and axis objects.

Changes

File(s) Change Summary
pyphare/pyphare/pharesee/hierarchy/hierarchy.py Rewrote the plot1d method: dynamic defaults, style customization, ghost cell handling, patch visualization, and updated return values.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PatchHierarchy
    participant Patch
    participant Matplotlib

    User->>PatchHierarchy: plot1d(**kwargs)
    PatchHierarchy->>PatchHierarchy: Determine quantity, levels, time
    PatchHierarchy->>Patch: Extract data, coordinates (handle ghost cells)
    PatchHierarchy->>Matplotlib: Plot each patch's data with style params
    alt plot_patches enabled
        PatchHierarchy->>Matplotlib: Draw dashed lines at patch boundaries
    end
    alt highlight_patches enabled
        PatchHierarchy->>Matplotlib: Highlight patch extents with rectangles
    end
    PatchHierarchy->>Matplotlib: Set labels, limits, grid, legend, title
    alt filename provided
        PatchHierarchy->>Matplotlib: Save figure
    end
    PatchHierarchy-->>User: Return figure, axis
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (3.3.7)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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: 3

🧹 Nitpick comments (2)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py (2)

446-446: Rename unused loop variable.

The loop variable lvl is not used within the loop body.

-for lvl_nbr, lvl in self.levels(time).items():
+for lvl_nbr, _ in self.levels(time).items():

461-461: Fix whitespace before colon.

Remove the extra space before the colon to comply with PEP 8.

-    x = np.copy(x[nbrGhosts[0] : -nbrGhosts[0]])
+    x = np.copy(x[nbrGhosts[0]:-nbrGhosts[0]])
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09e9954 and 3db14b3.

📒 Files selected for processing (1)
  • pyphare/pyphare/pharesee/hierarchy/hierarchy.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py (1)
Learnt from: PhilipDeegan
PR: PHAREHUB/PHARE#910
File: pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py:7-7
Timestamp: 2024-10-18T13:23:32.074Z
Learning: In the `pyphare.pharesee.hierarchy` module, importing `PatchHierarchy` and `format_timestamp` from `hierarchy.py` into `hierarchy_utils.py` is acceptable as long as `hierarchy.py` does not import `hierarchy_utils.py`, thereby avoiding a cyclic import.
🧬 Code Graph Analysis (1)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py (4)
pyphare/pyphare/pharesee/hierarchy/patchdata.py (1)
  • x (37-46)
pyphare/pyphare/core/box.py (3)
  • copy (68-69)
  • copy (138-142)
  • shape (32-34)
pyphare/pyphare/pharesee/hierarchy/patch.py (1)
  • copy (43-47)
tests/simulator/test_run.py (1)
  • plot (165-193)
🪛 Ruff (0.11.9)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py

407-407: mpl_toolkits.axes_grid1.make_axes_locatable imported but unused

Remove unused import: mpl_toolkits.axes_grid1.make_axes_locatable

(F401)


446-446: Loop control variable lvl not used within loop body

Rename unused lvl to _lvl

(B007)

🪛 Flake8 (7.2.0)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py

[error] 407-407: 'mpl_toolkits.axes_grid1.make_axes_locatable' imported but unused

(F401)


[error] 461-461: whitespace before ':'

(E203)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build (ubuntu-latest, gcc)
  • GitHub Check: build (ubuntu-latest, clang)
  • GitHub Check: build (macos-13)
  • GitHub Check: Analyze (python)
  • GitHub Check: build (macos-14)
  • GitHub Check: Analyze (cpp)
🔇 Additional comments (2)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py (2)

472-502: Well-implemented patch visualization features!

The optional patch boundary lines and highlight rectangles provide excellent visual debugging capabilities for AMR hierarchies.


504-525: Excellent improvements to plot configuration and usability!

The addition of:

  • Smart y-axis limits with 5% padding
  • Optional grid display
  • Configurable DPI for file saving
  • Return of figure and axis objects for further customization

These changes significantly enhance the method's flexibility and usability.

qty = kwargs.get("qty", None)
time = kwargs.get("time", self.times()[0])
from matplotlib.patches import Rectangle
from mpl_toolkits.axes_grid1 import make_axes_locatable
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove unused import.

The make_axes_locatable import is not used in this method.

 from matplotlib.patches import Rectangle
-from mpl_toolkits.axes_grid1 import make_axes_locatable
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.patches import Rectangle
🧰 Tools
🪛 Ruff (0.11.9)

407-407: mpl_toolkits.axes_grid1.make_axes_locatable imported but unused

Remove unused import: mpl_toolkits.axes_grid1.make_axes_locatable

(F401)

🪛 Flake8 (7.2.0)

[error] 407-407: 'mpl_toolkits.axes_grid1.make_axes_locatable' imported but unused

(F401)

🤖 Prompt for AI Agents
In pyphare/pyphare/pharesee/hierarchy/hierarchy.py at line 407, remove the
import statement for make_axes_locatable from mpl_toolkits.axes_grid1 since it
is not used anywhere in the method or file, eliminating unnecessary imports.

@nicolasaunai nicolasaunai self-requested a review July 3, 2025 12:49
@PHAREHUB PHAREHUB deleted a comment from coderabbitai bot Jul 3, 2025
@nicolasaunai
Copy link
Member

Is it possible to try having a contiguous line plot for contiguous patches.
At the moment this plots a line per patch, no matter whether they are contiguous or not.
While it is clear we do not want a straight ligne joining the last and first points of distant patches, we would rather prefer having a single line joining points of contiguous ones.

Thinking about it quickly, I suggest trying first to loop through patches and count the total number of nodes contained in patchdatas whose ghost boxes overlap, making an array of that size and copy associated patchdata datatasets into it, and the plot those collections of arrays.

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.

2 participants