mosdef-hub / mbuild

A hierarchical, component based molecule builder
https://mbuild.mosdef.org
Other
171 stars 79 forks source link

Added ability to adjust bead_size #1158

Closed jaclark5 closed 6 months ago

jaclark5 commented 9 months ago

PR Summary:

Fixes #1157

Allow a user to adjust the bead size in Jupyter notebook visualization. This is especially useful for CG models where the default bead size may be too small.

PR Checklist


jaclark5 commented 9 months ago

How can I add unit tests for features in a Jupyter notebook?

daico007 commented 9 months ago

Hi @jaclark5, good question, and I don't think we have a good way to explicitly tests those (the visualization). Currently, the py3dmol and nglview tests basically just try to make sure that we can create the visualization object without error. So in this case, I think you can just add a simple test case (maybe a box of CG beads or something that you have ready) and make sure there's no error pops up.

    @pytest.mark.skipif(not has_py3Dmol, reason="Py3Dmol is not installed")
    def test_visualize_py3dmol(self, ethane):
        py3Dmol = import_("py3Dmol")
        vis_object = ethane._visualize_py3dmol()
        assert isinstance(vis_object, py3Dmol.view)

    @pytest.mark.skipif(not has_nglview, reason="NGLView is not installed")
    def test_visualize_nglview(self, ethane):
        nglview = import_("nglview")
        vis_object = ethane._visualize_nglview()
        assert isinstance(
            vis_object.component_0, nglview.component.ComponentViewer
        )
daico007 commented 9 months ago

And those tests are currently located in test_compound.py

codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c684f92) 87.18% compared to head (1dcb209) 87.18%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1158 +/- ## ======================================= Coverage 87.18% 87.18% ======================================= Files 62 62 Lines 6492 6492 ======================================= Hits 5660 5660 Misses 832 832 ```

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