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

AgentSet.get is hardcoded to raise AttributeError for agents with missing attribute #2045

Open
rht opened this issue Feb 21, 2024 · 3 comments

Comments

@rht
Copy link
Contributor

rht commented Feb 21, 2024

What's the problem this feature will solve?

This is #2044 (comment) turned into an issue. Currently, AgentSet.get requires member agents to possess the attribute(s) it specifies. This may not be convenient if user wants to quickly get the result and intentionally want to specify undefined attribute(s) as None.

Describe the solution you'd like

What I have in mind is to add an extra optional argument called handle_undefined, which defaults to "raise_exception" (raise AttributeError). The other option would be "fallback_none" to fallback to None without raising an exception. Though user might want to fallback to np.nan instead of None, so this idea still needs further iteration.

@ai-naymul
Copy link

@EwoutH
Here's a brief overview of the proposed change:

Add handle_undefined parameter with default "raise_exception".
Introduce fallback_value parameter to specify the value to return when handle_undefined is set to "fallback_value".
This modification aims to offer more flexibility and convenience for users dealing with diverse agent attributes. I believe this could be a valuable addition to our project, and I'm eager to hear your thoughts, suggestions, or any concerns you might have regarding this proposal.

@EwoutH
Copy link
Contributor

EwoutH commented Mar 1, 2024

Generally sounds good. Maybe handle_undefined could just be a boolean, I don't know how many options we are going to add.

fallback_value might be interesting to allow getting a median, or average.

Feel free to start implementing this and open a (draft) PR.

@ai-naymul
Copy link

Hi @rht,
Could you please have a look at the pr and let me know if I am on the right path..
Thanks :)

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

No branches or pull requests

3 participants