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

Use a dictionary-style interface for setting, adding and getting of attributes of the mesh #286

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aaarne
Copy link
Contributor

@aaarne aaarne commented Mar 8, 2021

This pull request adds a dictionary-style interface to the mesh class.

Before this PR

mesh = pymesh.form_mesh(...)
mesh.add_attribute("attr1")
mesh.set_attribute("attr1", compute_the_first_attribute(mesh))
attr = mesh.get_attribute('attr1')

After this PR is merged

mesh = py.mesh.form_mesh(...)
mesh['attr1'] = compute_the_first_attribute(mesh)
attr = mesh['attr1']

Question:

Is it maybe better to return the correct shape of the matrix returned by __getitem__? It might be more straightforward to use then for the user. In order to implement this feature it is required to keep track of the attributes being vertex, edge, face, voxel attributes, which is not yet there in the class. What do you think, would that make sense?
Thank you :)

@aaarne aaarne changed the title Use a dictionary-style for setting, adding and getting of attributes of the mesh Use a dictionary-style interface for setting, adding and getting of attributes of the mesh Mar 8, 2021
Copy link

@ekalosak ekalosak left a comment

Choose a reason for hiding this comment

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

LGTM but needs unit test

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.

None yet

2 participants