Molara-Lab / Molara

Molara is a Python package for the visualization of chemical structures such as molecules or crystals. It provides a graphical user interface for importing structures from output files of popular computational chemistry software as well as for creating custom structures.
GNU General Public License v3.0
11 stars 0 forks source link

Feature/350 implement showing multiple structures at the same time #351

Closed Michel-Heinz closed 2 months ago

Michel-Heinz commented 2 months ago

I added a feature, where when a trajectory is loaded, all structures can be displayed at once. Therefore I enable loading multiple structures into the structure_widget. Please have a look and test a bit!

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago

Walkthrough

The recent updates focus on enhancing the GUI to support multiple structures, adjusting OpenGL and shader versions for wider compatibility, and refining tests to accommodate these changes. These modifications span across various components of the application, including GUI elements, rendering processes, and associated test suites.

Changes

Files Change Summary
.../structure_widget.py Updated to handle multiple structures; renamed variables and methods from singular to plural.
.../shaders.py, .../__main__.py, .../Rendering/rendering.py Shader versions downgraded from 410 to 330 core; OpenGL version set to 3.3; adjusted rendering logic.
.../test_shaders.py Renamed test function and updated expected hash values for shader sources.
.../test_measurement_dialog.py, .../test_main_window.py Tests updated to handle lists of structures instead of single objects; modified assertions and initializations.

🐇✨ In the realm of code, where shaders glow, Changes abound, the structures grow. Lists now hold what once was one, Compatibility's tune, sweetly sung. Hop, hop, hurray, let's render the show! 🌟 🐇✨


Recent Review Details **Configuration used: CodeRabbit UI**
Commits Files that changed from the base of the PR and between eb70ffd9b290ad9b62c1a00b30d0a806667b0dc4 and 40470e9e6e302d304518c21f9e46d602b44e1709.
Files selected for processing (1) * src/molara/Gui/structure_widget.py (16 hunks)
Additional Context Used
GitHub Check Runs (1)
codecov/patch success (28)
src/molara/Gui/structure_widget.py: [warning] 81-81: src/molara/Gui/structure_widget.py#L81 Added line #L81 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 88-88: src/molara/Gui/structure_widget.py#L88 Added line #L88 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 111-111: src/molara/Gui/structure_widget.py#L111 Added line #L111 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 113-113: src/molara/Gui/structure_widget.py#L113 Added line #L113 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 163-163: src/molara/Gui/structure_widget.py#L163 Added line #L163 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 429-429: src/molara/Gui/structure_widget.py#L429 Added line #L429 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 438-439: src/molara/Gui/structure_widget.py#L438-L439 Added lines #L438 - L439 were not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 469-469: src/molara/Gui/structure_widget.py#L469 Added line #L469 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 488-489: src/molara/Gui/structure_widget.py#L488-L489 Added lines #L488 - L489 were not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 515-516: src/molara/Gui/structure_widget.py#L515-L516 Added lines #L515 - L516 were not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 524-525: src/molara/Gui/structure_widget.py#L524-L525 Added lines #L524 - L525 were not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 529-529: src/molara/Gui/structure_widget.py#L529 Added line #L529 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 574-575: src/molara/Gui/structure_widget.py#L574-L575 Added lines #L574 - L575 were not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 583-584: src/molara/Gui/structure_widget.py#L583-L584 Added lines #L583 - L584 were not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 588-588: src/molara/Gui/structure_widget.py#L588 Added line #L588 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 611-611: src/molara/Gui/structure_widget.py#L611 Added line #L611 was not covered by tests --- src/molara/Gui/structure_widget.py: [warning] 616-616: src/molara/Gui/structure_widget.py#L616 Added line #L616 was not covered by tests
Additional comments not posted (3)
src/molara/Gui/structure_widget.py (3)
`43-43`: Initialization of `structures` as an empty list is a good practice to avoid potential `AttributeError`. --- `110-115`: The `reset_view` method has several checks for the presence and properties of structures, which is good for robustness. However, consider simplifying the checks to improve readability. Consider merging some of the conditions to reduce complexity and improve code readability. --- `203-240`: The `set_vertex_attribute_objects` method updates vertex attribute objects for multiple structures. Ensure that the method handles empty or null structures to prevent runtime errors.
Verification successful --- The verification process has confirmed that the `set_vertex_attribute_objects` method includes checks for empty or null structures before accessing `structures[0]`. This is evident from the conditional check `if not len(self.structures) or not self.structures[0]:` found in the code. This implementation should effectively prevent runtime errors related to accessing null or non-existent elements in the `structures` list. - Location: `src/molara/Gui/structure_widget.py`
Scripts Executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Check for null or empty checks in the method handling multiple structures. rg "structures\[0\]" src/molara/Gui/structure_widget.py ``` Length of output: 2777
--- 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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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 generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@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.` 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 as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
Michel-Heinz commented 2 months ago

What happened to code cov?

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 71.31148% with 35 lines in your changes are missing coverage. Please review.

Project coverage is 70.83%. Comparing base (5fc6739) to head (40470e9). Report is 3 commits behind head on main.

Files Patch % Lines
src/molara/Gui/structure_widget.py 64.61% 23 Missing :warning:
src/molara/Gui/main_window.py 33.33% 4 Missing :warning:
src/molara/Gui/builder.py 0.00% 3 Missing :warning:
src/molara/Gui/trajectory_dialog.py 81.25% 3 Missing :warning:
src/molara/Gui/crystal_dialog.py 0.00% 1 Missing :warning:
src/molara/__main__.py 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #351 +/- ## ========================================== + Coverage 69.44% 70.83% +1.39% ========================================== Files 38 38 Lines 3198 3251 +53 ========================================== + Hits 2221 2303 +82 + Misses 977 948 -29 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ab5424 commented 2 months ago

What happened to code cov?

It's there now. I think it can be delayed from time to time, depending on traffic.

GereonFeldmann commented 2 months ago

The measurement tool does not work correctly with the new code architecture. If you import a trajectory, you are not able to use the measurement tool anymore.

One receives the following error:

File "/Users/gfeldmann/GitHub/Molara/src/molara/Gui/main_window.py", line 168, in show_measurement_dialog if self.structure_widget.structure_is_set: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'StructureWidget' object has no attribute 'structure_is_set'. Did you mean: 'structures_is_set'?

Michel-Heinz commented 2 months ago

I ll take a look at it. It sounds like a straight forward fix tho

Michel-Heinz commented 2 months ago

@adrianusler Any idea why tests on ubuntu are failing? I cannot figure it out