-
Notifications
You must be signed in to change notification settings - Fork 883
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
JupyterViz: Simplify SliderInt and SliderFloat specification using slice #1945
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1945 +/- ##
==========================================
- Coverage 79.87% 79.73% -0.14%
==========================================
Files 15 15
Lines 1267 1278 +11
Branches 277 279 +2
==========================================
+ Hits 1012 1019 +7
- Misses 216 220 +4
Partials 39 39 ☔ View full report in Codecov by Sentry. |
It’s shorter, but also less explicit. So I’m a bit mixed about this. |
It's reminiscent of |
I like the brevity of this. Also, because it is similar to how, e.g., range and slicing work; it is easy to explain. I am a bit less sure about the choice to reuse |
I agree that using
It seems that I will have to define class arange:
def __init__(self, start, stop, step):
self.start = start
self.stop = stop
self.step = step
self.current = start
def __iter__(self):
return self
def __next__(self):
if self.current >= self.stop:
raise StopIteration
else:
result = self.current
self.current += self.step
return result |
I indeed see two options:
|
Regardless of how it should be implemented under the hood, |
https://emaworkbench.readthedocs.io/en/latest/examples/example_mesa.html has a more concise description. Instead of {
"type": "SliderFloat",
"value": 0.8,
"label": "Agent density",
"min": 0.1,
"max": 1.0,
"step": 0.1,
} we have from mesa.experimental import `Slider`
Slider("Agent density", 0.8, 0.1, 1.0, 0.1)
# optionally
# min_value instead of min in order to avoid collision with reserved keywords
Slider(name="Agent density", value=0.8, min_value=0.1, max_value=1.0, step=0.1)
|
We could have named it |
Superseded by #1972. |
With this PR, instead of the lengthy
model_params
This becomes