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

Protocol on update_states #32

Open
hanson-hschang opened this issue Sep 9, 2024 · 3 comments
Open

Protocol on update_states #32

hanson-hschang opened this issue Sep 9, 2024 · 3 comments
Labels
question Further information is requested

Comments

@hanson-hschang
Copy link
Collaborator

@skim0119

Is the current protocol on update_states good?

def update_states(self, *args: Any) -> None:
"""Updates the mesh object with the given states."""

Will it be better to change *args to **kwargs? Since the states might be different for different objects?

I have the following protocol on update_material:

def update_material(self, **kwargs: dict[str, Any]) -> None:
"""Updates the material of the mesh object."""

@hanson-hschang hanson-hschang added the question Further information is requested label Sep 9, 2024
@skim0119
Copy link
Collaborator

Will it be better to change *args to **kwargs? Since the states might be different for different objects?

Both args and kwargs can support all kinds of state. The difference is whether we want to be called with explicit parameter name or just an order.

I'll probably need to see what kind of parameters are suited for update_material to make the decision. For update_states, I would prefer using args.

@hanson-hschang
Copy link
Collaborator Author

hanson-hschang commented Sep 10, 2024

If args is used, then the order of arguments matters, right?

For update_material, I think kwargs might be better.

@hanson-hschang
Copy link
Collaborator Author

In the following case, if the radii does not need to be updated, it still needs to be provided, right?

def update_states(self, positions: NDArray, radii: NDArray) -> None:
"""
Update the states of the rod object
Parameters
----------
positions : NDArray
The positions of the sphere objects. Expected shape is (n_nodes, 3).
radii : NDArray
The radii of the sphere objects. Expected shape is (n_nodes-1,).
"""

@hanson-hschang hanson-hschang mentioned this issue Sep 11, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants