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

Pyvista #463

Merged
merged 67 commits into from
Mar 6, 2024
Merged

Pyvista #463

merged 67 commits into from
Mar 6, 2024

Conversation

samjrholt
Copy link
Member

@samjrholt samjrholt commented Aug 29, 2023

To-do

  • Default colour maps
  • Default lighting
  • Colour based on field
  • Better default arrows
  • Docstrings
  • Tests
  • Docstring examples # doctest: +SKIP
    Client/server rendering
  • ipynb
  • see also docstring
  • Test alternative valid implementation
  • pytest parameterize
    preimage

@samjrholt samjrholt marked this pull request as draft August 29, 2023 16:02
@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2023

Image description CodeRabbit

Walkthrough

This update introduces a new feature for 3D visualization using the PyVista library. It adds pyvista properties to various classes, enabling direct access to PyVista-based plotting interfaces. New classes PyVistaMesh and PyVistaRegion are introduced for handling 3D mesh plotting and region visualization respectively.

Changes

File(s) Summary
discretisedfield/field.py Simplified array naming in to_vtk function and added pyvista property for PyVista-based plotting interface.
discretisedfield/mesh.py, discretisedfield/region.py Introduced pyvista property returning instances of dfp.PyVistaMesh and dfp.PyVistaRegion respectively.
discretisedfield/plotting/__init__.py Added PyVistaMesh and PyVistaRegion modules to the package.
discretisedfield/plotting/pyvista_mesh.py, discretisedfield/plotting/pyvista_region.py Introduced PyVistaMesh and PyVistaRegion classes for 3D mesh plotting and region visualization. Provided customization methods for visualizations.

🐰🎉

In the land of code, where logic intertwines,
A rabbit hops forth, leaving tracks in the lines.
With each leap and bound, a change is unfurled,
Adding depth and dimension to our digital world.
Through meshes and regions, in 3D we now play,
Celebrating these changes in the PyVista way! 🎊🥳


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

@samjrholt samjrholt self-assigned this Aug 30, 2023
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between e03dc36 and 113b49e commits.
Files selected (8)
  • dev/pyvista.ipynb (1)
  • discretisedfield/field.py (2)
  • discretisedfield/mesh.py (1)
  • discretisedfield/plotting/init.py (1)
  • discretisedfield/plotting/pyvista_field.py (1)
  • discretisedfield/plotting/pyvista_mesh.py (1)
  • discretisedfield/plotting/pyvista_region.py (1)
  • discretisedfield/region.py (1)
Files not summarized due to errors (1)
  • dev/pyvista.ipynb (diff tokens exceeds limit)
Files not reviewed due to errors (3)
  • discretisedfield/plotting/pyvista_field.py (no response)
  • dev/pyvista.ipynb (no response)
  • discretisedfield/plotting/init.py (no response)
Review comments generated (14)
  • Review: 12
  • LGTM: 2

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

discretisedfield/field.py Show resolved Hide resolved
discretisedfield/mesh.py Outdated Show resolved Hide resolved
discretisedfield/plotting/pyvista_mesh.py Outdated Show resolved Hide resolved
Comment on lines 54 to 58
if self.mesh.region.ndim != 3:
raise ValueError(
"Only meshes with 3 spatial dimensions can be plotted not"
f" {self.data.mesh.region.ndim=}."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Image description CodeRabbit

Similarly, the dimension check in the subregions method is also unnecessary as it's already done in the __init__ method.

-        if self.mesh.region.ndim != 3:
-            raise ValueError(
-                "Only meshes with 3 spatial dimensions can be plotted not"
-                f" {self.data.mesh.region.ndim=}."
-            )

Copy link
Member

Choose a reason for hiding this comment

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

I would agree with the automated check. Why do we need to repeat this check? It should have already been performed when initialising the class.

discretisedfield/plotting/pyvista_mesh.py Outdated Show resolved Hide resolved
discretisedfield/plotting/pyvista_mesh.py Show resolved Hide resolved
discretisedfield/plotting/pyvista_region.py Show resolved Hide resolved
Comment on lines +52 to +53
if self.region.ndim != 3:
raise RuntimeError("Only 3-dimensional regions can be plotted.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Image description CodeRabbit

This check for the region's dimension is redundant as it was already checked during the initialization of the class. This can be removed to improve performance and reduce unnecessary code.

- if self.region.ndim != 3:
-     raise RuntimeError("Only 3-dimensional regions can be plotted.")

discretisedfield/plotting/pyvista_region.py Show resolved Hide resolved
discretisedfield/plotting/pyvista_region.py Show resolved Hide resolved
@samjrholt samjrholt requested a review from kzqureshi November 10, 2023 11:02
@samjrholt samjrholt marked this pull request as ready for review November 10, 2023 11:03
Copy link
Contributor

@kzqureshi kzqureshi left a comment

Choose a reason for hiding this comment

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

It seems good to me, no specific typos as well, as per my vague notion of pyvista, code is very well written.

@lang-m
Copy link
Member

lang-m commented Jan 12, 2024

@swapneelap Could you maybe review this so that we can move on. I can have a look at some later point (after merge) as I won't be able to (thoroughly) do this anytime soon.

Copy link
Member

@swapneelap swapneelap left a comment

Choose a reason for hiding this comment

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

Looks OK to me.

@lang-m
Copy link
Member

lang-m commented Jan 15, 2024

@samjrholt Please resolve the issues pointed out by @kzqureshi . Afterwards you can merge unless you think we have to discuss any remaining issues (a few items in the list in the description are not yet ticked).

Copy link
Member

@lang-m lang-m left a comment

Choose a reason for hiding this comment

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

Here is a very quick review. General remarks:

  • Looks like we use the default pyvista colormaps? I think that is a good decision.
  • We should have a (short) documentation notebook. Maybe the dev notebook could be modified for that purpose?

discretisedfield/io/vtk.py Outdated Show resolved Hide resolved
discretisedfield/mesh.py Outdated Show resolved Hide resolved
discretisedfield/plotting/pyvista_field.py Outdated Show resolved Hide resolved
discretisedfield/plotting/util.py Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
discretisedfield/plotting/pyvista_field.py Outdated Show resolved Hide resolved
discretisedfield/plotting/pyvista_field.py Outdated Show resolved Hide resolved
discretisedfield/plotting/pyvista_field.py Outdated Show resolved Hide resolved
discretisedfield/plotting/pyvista_mesh.py Show resolved Hide resolved
Comment on lines 54 to 58
if self.mesh.region.ndim != 3:
raise ValueError(
"Only meshes with 3 spatial dimensions can be plotted not"
f" {self.data.mesh.region.ndim=}."
)
Copy link
Member

Choose a reason for hiding this comment

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

I would agree with the automated check. Why do we need to repeat this check? It should have already been performed when initialising the class.

@samjrholt samjrholt merged commit 1b28a81 into master Mar 6, 2024
8 checks passed
@samjrholt samjrholt deleted the pyvista branch March 6, 2024 15:12
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.

5 participants