Skip to content

Conversation

vineetvermait
Copy link

This visualization allows the developer to add any pyplot visualization. removes all dependencies on the js components

@EwoutH
Copy link
Member

EwoutH commented Jan 22, 2022

This looks awsome! Could you add a few example screenshots?

@vineetvermait
Copy link
Author

Updated the code, Added Documentation

@codecov
Copy link

codecov bot commented Jan 24, 2022

Codecov Report

Merging #1139 (c9e2694) into main (4a79705) will increase coverage by 0.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1139      +/-   ##
==========================================
+ Coverage   89.30%   89.48%   +0.18%     
==========================================
  Files          19       20       +1     
  Lines        1253     1294      +41     
  Branches      256      255       -1     
==========================================
+ Hits         1119     1158      +39     
- Misses         98      100       +2     
  Partials       36       36              
Impacted Files Coverage Δ
mesa/visualization/modules/PyPlotVisualization.py 100.00% <100.00%> (ø)
mesa/visualization/modules/__init__.py 100.00% <100.00%> (ø)
mesa/space.py 94.91% <0.00%> (-1.00%) ⬇️
mesa/batchrunner.py 92.28% <0.00%> (+0.72%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a79705...c9e2694. Read the comment docs.

Copy link
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

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

This is great @vineetvermait, thanks! I requested a few changes. A major concern is ensuring the graphs render cleanly.

@vineetvermait
Copy link
Author

Fixed

@vineetvermait vineetvermait requested a review from tpike3 January 27, 2022 06:19
Copy link
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

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

@vineetvermait could you please correct the failing checks and squash your commits so it is one commit.

@rht Can you please give it a second look

Then it should be good to merge

@rht
Copy link
Contributor

rht commented Jan 28, 2022

The CI fails because matplotlib is not installed.
TODO:

  • inside PyPlotVisualization.py, do a try import matplotlib. If this fail raises an error and say that the optional dependency matplotlib is missing
  • in setup.py, in extras_require, in dev, add matplotlib.

@rht
Copy link
Contributor

rht commented Jan 28, 2022

If the 3 TODOs are addressed, then this LGTM.

@vineetvermait vineetvermait requested a review from tpike3 January 28, 2022 04:45
@@ -0,0 +1,24 @@
let PyPlotModule = function(canvas_width, canvas_height) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be const.

Copy link
Contributor

@rht rht Jan 28, 2022

Choose a reason for hiding this comment

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

And all the vars inside this function need to be declared with const/let. Default to const unless if it needs to be re-declared.

Copy link
Contributor

Choose a reason for hiding this comment

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

PyPlotModule must be const.

@rht
Copy link
Contributor

rht commented Jan 30, 2022

The CI fails because matplotlib is not installed. TODO:

  • inside PyPlotVisualization.py, do a try import matplotlib. If this fail raises an error and say that the optional dependency matplotlib is missing
  • in setup.py, in extras_require, in dev, add matplotlib.

Not yet addressed.

@vineetvermait
Copy link
Author

Resolved issues

@rht
Copy link
Contributor

rht commented Jan 30, 2022

inside PyPlotVisualization.py, do a try import matplotlib. If this fail raises an error and say that the optional dependency matplotlib is missing

Not yet addressed.

Also the new const comments not yet addressed.

@vineetvermait
Copy link
Author

Anything pending??

@rht
Copy link
Contributor

rht commented Feb 1, 2022

  • There is one issue with the import matplotlib still not yet resolved
  • You need to squash your commits into 1 commit

@rht
Copy link
Contributor

rht commented Feb 5, 2022

Here is an example UX in Pandas. I was trying to use the string[pyarrow] feature, which depends on an optional dependency of PyArrow. I got this error message:

ImportError: pyarrow>=1.0.0 is required for PyArrow backed StringArray.

We could use this concise error message instead of the long one I suggested.

def render(self, model: Model):
fig = self.img_func(model)
io_bytes = io.BytesIO()
fig.savefig(io_bytes, format="jpg")
Copy link
Contributor

Choose a reason for hiding this comment

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

The format should be "svg" instead.

@Corvince
Copy link
Contributor

@vineetvermait are you still availabe for the remaining small points? If not would you mind me finishing the PR for you so we can get this merged?

@rht
Copy link
Contributor

rht commented May 17, 2022

It has been 2 days. @Corvince you should just go for it.

@rht
Copy link
Contributor

rht commented Oct 13, 2022

Bump.

@Corvince
Copy link
Contributor

Thanks for the bump, I totally forgot about this!

@rht
Copy link
Contributor

rht commented May 11, 2023

Closing, because I think the next-gent frontend for Mesa should be based on Streamlit/Panel/ipywidgets. This would result in simpler code (plus for maintainability), and that it is easier to be customized by the user. Followup discussion on #1622.

@rht rht closed this May 11, 2023
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.

5 participants