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

Add docstring for jupyterviz make_user_input that documents supported inputs #1784

Merged
merged 5 commits into from
Sep 1, 2023

Conversation

rlskoeser
Copy link
Contributor

@rlskoeser rlskoeser commented Aug 30, 2023

  • add a docstring to jupyterviz make_user_input method that documents the supported solara inputs
  • update parameters to make_user_input - drop unused parameter, use more readable variable names

some related conversation on #1772 and follow up work to #1777

I haven't added any tests yet since there is no existing testing infrastructure for the jupyterviz stuff, but I did test locally with a simulation that uses a slider int and a switch parameter and the changes work

@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Patch coverage: 45.45% and project coverage change: +0.29% 🎉

Comparison is base (fb81c1a) 79.58% compared to head (1bd1f73) 79.88%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1784      +/-   ##
==========================================
+ Coverage   79.58%   79.88%   +0.29%     
==========================================
  Files          15       15              
  Lines         877      880       +3     
  Branches      188      188              
==========================================
+ Hits          698      703       +5     
+ Misses        158      154       -4     
- Partials       21       23       +2     
Files Changed Coverage Δ
mesa/experimental/jupyter_viz.py 18.65% <45.45%> (+3.38%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -133,28 +133,37 @@ def function(viz):
return function


def make_user_input(user_input, k, v):
if v["type"] == "SliderInt":
def make_user_input(user_input, options):
Copy link
Contributor

Choose a reason for hiding this comment

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

I initially included the name ("k") because I figured it might be used in the future. Looking at the code again, I think the name can be used as a fallback label instead of the current generic "label".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, ok, that makes sense; I'll revise.

Should the method throw an exception if the type is not supported? If so, does ValueError seem appropriate to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rht updated with name fallback logic, exception for unsupported type, and preliminary unit test for this method

@rlskoeser rlskoeser requested a review from rht August 31, 2023 15:46
@rht
Copy link
Contributor

rht commented Aug 31, 2023

This PR LGTM, but I'm merging #1786 first because that PR is a huge refactor, will cause a merge conflict, and it is easier to redo this PR instead of that one. Sorry for this.

@rht
Copy link
Contributor

rht commented Sep 1, 2023

There is indeed a merge conflict.

@rlskoeser
Copy link
Contributor Author

@rht thanks for letting me know. I'll see what I can figure out; looking forward to seeing the updates.

Resolve merge conflict with recent jupyterviz refactor
@rlskoeser rlskoeser force-pushed the document-jupyterviz-userinput branch from 9cc867e to 1bd1f73 Compare September 1, 2023 13:52
@rht rht merged commit 47637a7 into projectmesa:main Sep 1, 2023
@rht
Copy link
Contributor

rht commented Sep 1, 2023

Merged, thank you @rlskoeser !

@rlskoeser rlskoeser deleted the document-jupyterviz-userinput branch September 1, 2023 15:17
@tpike3 tpike3 added this to the Release 2.1.2 milestone Sep 19, 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.

3 participants