{"id":15583307,"url":"https://github.com/glvis/pyglvis","last_synced_at":"2025-04-13T08:54:47.606Z","repository":{"id":34123407,"uuid":"170217985","full_name":"GLVis/pyglvis","owner":"GLVis","description":"GLVis Jupyter Widget ","archived":false,"fork":false,"pushed_at":"2024-10-01T03:51:43.000Z","size":1894,"stargazers_count":17,"open_issues_count":8,"forks_count":4,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-12T04:40:10.185Z","etag":null,"topics":["finite-elements","glvis","jupyter","visualization"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GLVis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-11T23:15:56.000Z","updated_at":"2025-04-09T10:13:51.000Z","dependencies_parsed_at":"2024-10-23T02:50:39.990Z","dependency_job_id":null,"html_url":"https://github.com/GLVis/pyglvis","commit_stats":{"total_commits":176,"total_committers":6,"mean_commits":"29.333333333333332","dds":0.7329545454545454,"last_synced_commit":"6dbdf1be8d50d166e926b5fb599e13105beb0936"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GLVis%2Fpyglvis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GLVis%2Fpyglvis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GLVis%2Fpyglvis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GLVis%2Fpyglvis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GLVis","download_url":"https://codeload.github.com/GLVis/pyglvis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688543,"owners_count":21145763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["finite-elements","glvis","jupyter","visualization"],"created_at":"2024-10-02T20:06:53.657Z","updated_at":"2025-04-13T08:54:47.584Z","avatar_url":"https://github.com/GLVis.png","language":"Python","readme":"# PyGLVis\n\n[![badge](examples/.assets/ex1.svg)](https://colab.research.google.com/github/GLVis/pyglvis/blob/main/examples/ex1.ipynb)\n[![badge](examples/.assets/ex9.svg)](https://colab.research.google.com/github/GLVis/pyglvis/blob/main/examples/ex9.ipynb)\n\n\n\\\nPyGLVis is an interactive [Jupyter](https://jupyter.org/) widget for visualizing finite element meshes and functions, built on-top of the [GLVis](https://glvis.org/) library.\n\n## 📦 Installation\n\nThe GLVis Jupyter widget is installed using `pip`. To install the latest version from the repository:\n\n```bash\ngit clone https://github.com/GLVis/pyglvis.git\ncd pyglvis\npip install .\n```\n\nOr, install directly from PyPi,\n```bash\npip install glvis\n```\n\nPyGLVis requires the Python wrapper for MFEM, [PyMFEM](https://github.com/mfem/pymfem), which can be installed with\n```bash\npip install mfem\n```\n\n\n\n## 🚀 Usage\n\n### Basic usage\n\n```python\nfrom glvis import glvis\n\n# Create a `glvis` object\ng = glvis(data, width=640, height=480)\n\n# Run a cell with `g` as the last statement to display the widget\ng\n```\n\nThe `data` object can be one of:\n\n- `Mesh`, defined in [PyMFEM](https://github.com/mfem/pymfem)\n- `(Mesh, GridFunction)` tuple, defined in [PyMFEM](https://github.com/mfem/pymfem)\n- `str`, in the format of `*.saved` files [used by MFEM and GLVis](https://mfem.org/mesh-format-v1.0/). See [examples/basic.ipynb](examples/basic.ipynb) for an example.\n\n### Customization with key commands\n\nGLVis has many keyboard commands that can be used to customize the visualization.\nA few of the most common are listed below. See the [GLVis README](https://github.com/GLVis/glvis?tab=readme-ov-file#key-commands) for a full list.\n - `r` - reset the view\n - `c` - toggle the colorbar\n - `j` - toggle perspective\n - `l` - toggle the light\n - `g` - toggle the background color (white/black)\n - `a` - cycle through bounding box axes states\n - `m` - cycle through mesh states\n - `p` - cycle through color palettes\n - `t` - cycle through materials and lights\n - `0` - begin rotating around z-axis\n - `.` - pause rotation\n - `*`/`/` - zoom in/out\n\nThese can be set using the `keys` argument when creating a `glvis` object.\n```python\nglvis(data, keys='rljgac//0')\n```\nThis combination of keys would: `r` reset the view, `l` toggle the light, `j` toggle perspective, `g` toggle the background color to black (default is white), `a` show the bounding box, `c` show the colorbar, `//` zoom out twice, and `0` begin rotating around the z-axis:\n\n![pyglvis_preset_keys](https://github.com/GLVis/pyglvis/assets/27717785/de0e0a99-72ac-4a88-8369-708515600b09)\n\nAlternatively, keys can be typed directly into the widget after it has been created:\n\n![pyglvis_using_keys](https://github.com/GLVis/pyglvis/assets/27717785/625f4f06-8f99-4390-94d7-4d317fd11e7f)\n\n### Other methods\n\nOnce you have a `glvis` object there are a few methods that can used to update the\nvisualization, besides using keys:\n```python\n# Show a new Mesh/GridFunction, resets keys\ng.plot(data)\n# Show an updated visualization with the same data, preserving keys\ng.update(data)\n# Change the image size\ng.set_size(width, height)\n# Force the widget to render. If the widget isn't the last statement in a cell it\n# will not be shown without this. See ex9.ipynb\ng.render()\n```\n\nSee the [examples](examples/) directory for additional examples. To test those locally, start a Jupyter lab server with\n\n```\njupyter lab\n```\n\n## 🐛 Troubleshooting\n\nThis widget was originally developed using the [jupyter widget cookiecutter](https://github.com/jupyter-widgets/widget-cookiecutter); however, [recent changes to the Jupyter ecosystem](https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html#why-a-new-version) have broken a lot of functionality, leading to a rewrite using [anywidget](https://anywidget.dev/). If you encounter any problems, please consider supporting development by opening an [issue](https://github.com/GLVis/pyglvis/issues).\n\n\n\n## 🤖 Development\n\n### PyGLVis dependencies\n\n```mermaid\ngraph TD;\n    A[mfem] --\u003e B[pymfem];\n    A --\u003e C[glvis];\n    C --\u003e D[glvis-js];\n    Ext1[emscripten] --\u003e D;\n    D-.-E[\"glvis-js\\n(npm/esm mirror)\"]\n    B \u0026 E --\u003e G[pyglvis];\n    Ext2[jupyter] --\u003e G;\n```\n\n`pyglvis` is most directly depednent on `PyMFEM` and `glvis-js`. [PyMFEM](https://github.com/mfem/pymfem) is a Python wrapper of the finite element library, `MFEM`, while `glvis-js` is a JavaScript/WebAssembly port of `glvis`.\n\n`glvis-js` is hosted on [github](https://github.com/glvis/glvis-js) and mirrored on [npm](https://www.npmjs.com/package/glvis). [esm.sh](https://esm.sh/glvis) allows `pyglvis` to pull the latest version of `glvis-js` directly from npm. This can be seen in the first line of [glvis/widget.js](glvis/widget.js):\n\n```\nimport glvis from \"https://esm.sh/glvis\";\n```\n\nYou can specify a different version of `glvis-js` by adding `@x.y.z` to the end of this import statement, where `x.y.z` matches a version number available on `npm`, e.g.\n\n```\nimport glvis from \"https://esm.sh/glvis@0.6.3\";\n```\n\n\n### Releasing a new version of glvis on NPM:\n\nTo publish a new version of `glvis-js`, follow the instructions on the [repo](https://github.com/GLVis/glvis-js/tree/master).\n\n\n### Releasing a new version of glvis on PyPI:\n\n- Update `__version__` in `glvis/__about__.py`\n\n- `git add` and `git commit` changes\n\n\nYou will need [twine](https://pypi.org/project/twine/) to publish to PyPI, install with `pip`.\n\n```\npython -m hatch build\ntwine upload dist/*\ngit tag -a X.X.X -m 'comment'\ngit push --tags\n```\n\n\n## 🌐 Links\n- MFEM ([website](https://mfem.org/), [github](https://github.com/mfem/mfem))\n- PyMFEM ([github](https://github.com/mfem/pymfem), [pypi](https://pypi.org/project/mfem/))\n- GLVis ([website](https://glvis.org/), [github](https://github.com/glvis/glvis))\n- glvis-js ([github](https://github.com/glvis/glvis-js), [npm](https://www.npmjs.com/package/glvis), [esm](https://esm.sh/glvis))\n- pyglvis ([github](https://github.com/GLVis/pyglvis), [pypi]())\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglvis%2Fpyglvis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglvis%2Fpyglvis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglvis%2Fpyglvis/lists"}