-
Notifications
You must be signed in to change notification settings - Fork 972
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
Adds Altair plot component and some other fixes #2644
base: main
Are you sure you want to change the base?
Conversation
Performance benchmarks:
|
Thanks for the PR! A few of the automated checks broke, could you look into what caused that? I will leave the review to others. |
@nissu99 also please look at #2643 and #2641 As you are @sanika-n are working in the same space As it looks like you two are looking over the entire altair implementation I would also recommend looking at #2642 discussion It is always good to collaborate and think together you may address some larger visualization challenges. |
"alt defined"
for more information, see https://pre-commit.ci
@tpike3 When I run the tests locally, they don't fail, but they are failing here. |
I am not sure why your tests are passing locally, however for tests to pass they need to updated. It is expecting
|
"removed a line"
"updated toml"
"removed suppress"
for more information, see https://pre-commit.ci
"doc string "
for more information, see https://pre-commit.ci
"operator bug"
Thank You, the issue got resolved by adding altair to the toml file. |
Removing stuff that has become redundant is fine. |
@quaquel i have added all the stuff,can you review it? |
I'll try to review it over the weekend, but I am rather bussy at the moment. This is a part of the code base I am not intimately familiar with and his been a while since I used Altair, so reviewing will take more time than parts of the code base I know inside out. |
You've done a great job @nissu99 on the grids. It will take some time to test them all but I will do a review soon enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done a basic review, the grid drawing can wait, let's go step by step.
Our first step here should be to finalize the agent data collecting logic, therefore why is the agent data collecting logic not made into a function like is done in matplotlib
part?
Also does this implementation cover all the grids (again compare with this)
with contextlib.suppress(ImportError): | ||
import altair as alt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't suppress the import error here.
import mesa.experimental | ||
from mesa.experimental.cell_space import HexGrid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the experimental imports to mesa.discrete_space
visualized. The dictionary can contain the following keys: | ||
- "color": A string representing the agent's color (e.g., "red", "#FF0000"). | ||
- "size": A number representing the agent's size. | ||
- "tooltip": A string to display as a tooltip when hovering over the agent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this tooltip a new feature for altair
? I don't think this is necessary for the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is used for displaying metadata.
update_counter.get() | ||
space = getattr(model, "grid", None) | ||
if space is None: | ||
# Sometimes the space is defined as model.space instead of model.grid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should keep this comment.
space = model.space | ||
|
||
chart = _draw_grid(space, agent_portrayal) | ||
# Apply post-processing if provided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should keep this comment as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will be more cautious while deleting comments.
stuff like vernoi grid has not been added ,will have to look into it to properly add it. |
@nissu99 I can see why you got confused, I think he meant the generic function should be called in the respective draw functions and hence |
I thought ,later he wants to make some universal function which can be reused. |
You don't have to worry about the new API, its still in discussion. |
i tried using the collect_agent_data function it does not give the desired results. |
How did you test it, can you please elaborate how is it not working? |
will ha
i used the internal examples ,somehow it shows no agent showing ,it is not able to extract the data ,will have to properly look into it to understand the issue well. |
That's because you are just getting the agent data, no plotting them on the grid. Maybe check if the data extraction is working or not don't not rely on this visualization. |
@Sahil-Chhoker sorry for not getting back ,just got my college holidays started , i think the extraction is the fault here |
Its working fine for me, can you test again. I don't think its a difficult task, you just replace the agent data collection logic with the |
i get that , it is not working for OrthogonalMooreGrid somehow,for others it works fine. |
It's working for |
It worked ,i made a dumb mistake ,should i make a commit for changing the extraction logic? |
Yeah, refactor the agent placement logic inline with the extraction logic. |
I encountered several issues while reviewing this PR. First, the previous review comments have not been addressed. Additionally, you're not using the new grids in Due to the excessive length of this PR, it's difficult for me to review it entirely. I strongly recommend breaking it down into smaller, atomic PRs that address specific issues. A better approach could be:
This will make the review process smoother and ensure that changes are properly implemented step by step. |
I will change all the experimental to discrete_space ,I agree the changes have increased and i understand it is becoming very hard to review , is the extraction logic fine ? |
I have only tested it once, so it may be a good starting point. And again I strongly recommend you to break this PR into smaller once. |
Maybe to clarify what this means: Just open a series of new PRs, one after another. So start with some minimal changes as a single PR, which includes the groundwork for the rest. Once this PR is merged, open the next PR with changes to some other function/grid/whatever. And so on. Its more tedious this way, but overall it will speed things up. Right now the PR is too big to properly review, because it requires code review, which is already almost too much, but also manually testing everything. You can also just leave this PR open for now as a reference. |
Thanks for the clarification @Corvince! |
Thank You for clarity ,will be making individual PR's . |
#2435
@quaquel @EwoutH I’ve added a new component, make_altair_plot_component. Could you kindly check if it aligns well with the project?
P.S working on space support.