syd 0.1.7__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- syd/__init__.py +1 -1
- syd/flask_deployment/__init__.py +1 -1
- syd/flask_deployment/deployer.py +563 -238
- syd/flask_deployment/static/__init__.py +1 -0
- syd/flask_deployment/static/css/styles.css +280 -0
- syd/flask_deployment/static/js/viewer.js +795 -138
- syd/flask_deployment/templates/__init__.py +1 -0
- syd/flask_deployment/templates/index.html +34 -0
- syd/flask_deployment/testing_principles.md +4 -4
- syd/notebook_deployment/__init__.py +0 -1
- syd/notebook_deployment/deployer.py +124 -213
- syd/notebook_deployment/widgets.py +78 -60
- syd/parameters.py +299 -345
- syd/support.py +195 -0
- syd/viewer.py +310 -347
- syd-1.0.0.dist-info/METADATA +219 -0
- syd-1.0.0.dist-info/RECORD +19 -0
- syd/flask_deployment/components.py +0 -510
- syd/flask_deployment/static/css/viewer.css +0 -82
- syd/flask_deployment/templates/base.html +0 -29
- syd/flask_deployment/templates/viewer.html +0 -51
- syd/notebook_deployment/_ipympl_deployer.py +0 -258
- syd/plotly_deployment/__init__.py +0 -1
- syd/plotly_deployment/components.py +0 -531
- syd/plotly_deployment/deployer.py +0 -376
- syd-0.1.7.dist-info/METADATA +0 -120
- syd-0.1.7.dist-info/RECORD +0 -22
- {syd-0.1.7.dist-info → syd-1.0.0.dist-info}/WHEEL +0 -0
- {syd-0.1.7.dist-info → syd-1.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -31,7 +31,7 @@ class BaseWidget(Generic[T, W], ABC):
|
|
|
31
31
|
|
|
32
32
|
_widget: W
|
|
33
33
|
_callbacks: List[Dict[str, Union[Callable, Union[str, List[str]]]]]
|
|
34
|
-
|
|
34
|
+
is_action: bool = False
|
|
35
35
|
|
|
36
36
|
def __init__(
|
|
37
37
|
self,
|
|
@@ -240,30 +240,33 @@ class IntegerWidget(BaseWidget[IntegerParameter, widgets.IntSlider]):
|
|
|
240
240
|
margin: str = "3px 0px",
|
|
241
241
|
description_width: str = "initial",
|
|
242
242
|
) -> widgets.IntSlider:
|
|
243
|
+
"""Create the integer slider widget."""
|
|
243
244
|
return widgets.IntSlider(
|
|
244
245
|
value=parameter.value,
|
|
245
|
-
min=parameter.
|
|
246
|
-
max=parameter.
|
|
246
|
+
min=parameter.min,
|
|
247
|
+
max=parameter.max,
|
|
248
|
+
step=1,
|
|
247
249
|
description=parameter.name,
|
|
248
|
-
|
|
249
|
-
layout=widgets.Layout(width=width, margin=margin),
|
|
250
|
+
continuous_update=continuous,
|
|
250
251
|
style={"description_width": description_width},
|
|
252
|
+
layout=widgets.Layout(width=width, margin=margin),
|
|
251
253
|
)
|
|
252
254
|
|
|
253
255
|
def matches_parameter(self, parameter: IntegerParameter) -> bool:
|
|
254
|
-
"""Check if the widget
|
|
256
|
+
"""Check if the widget values match the parameter."""
|
|
255
257
|
return (
|
|
256
|
-
self.
|
|
257
|
-
and self._widget.
|
|
258
|
-
and self._widget.
|
|
258
|
+
self._widget.description == parameter.name
|
|
259
|
+
and self._widget.value == parameter.value
|
|
260
|
+
and self._widget.min == parameter.min
|
|
261
|
+
and self._widget.max == parameter.max
|
|
259
262
|
)
|
|
260
263
|
|
|
261
264
|
def extra_updates_from_parameter(self, parameter: IntegerParameter) -> None:
|
|
262
|
-
"""
|
|
265
|
+
"""Update the widget attributes from the parameter."""
|
|
263
266
|
current_value = self._widget.value
|
|
264
|
-
self._widget.min = parameter.
|
|
265
|
-
self._widget.max = parameter.
|
|
266
|
-
self.value = max(parameter.
|
|
267
|
+
self._widget.min = parameter.min
|
|
268
|
+
self._widget.max = parameter.max
|
|
269
|
+
self.value = max(parameter.min, min(parameter.max, current_value))
|
|
267
270
|
|
|
268
271
|
|
|
269
272
|
class FloatWidget(BaseWidget[FloatParameter, widgets.FloatSlider]):
|
|
@@ -277,32 +280,35 @@ class FloatWidget(BaseWidget[FloatParameter, widgets.FloatSlider]):
|
|
|
277
280
|
margin: str = "3px 0px",
|
|
278
281
|
description_width: str = "initial",
|
|
279
282
|
) -> widgets.FloatSlider:
|
|
283
|
+
"""Create the float slider widget."""
|
|
280
284
|
return widgets.FloatSlider(
|
|
281
285
|
value=parameter.value,
|
|
282
|
-
min=parameter.
|
|
283
|
-
max=parameter.
|
|
286
|
+
min=parameter.min,
|
|
287
|
+
max=parameter.max,
|
|
284
288
|
step=parameter.step,
|
|
285
289
|
description=parameter.name,
|
|
286
|
-
|
|
287
|
-
layout=widgets.Layout(width=width, margin=margin),
|
|
290
|
+
continuous_update=continuous,
|
|
288
291
|
style={"description_width": description_width},
|
|
292
|
+
layout=widgets.Layout(width=width, margin=margin),
|
|
289
293
|
)
|
|
290
294
|
|
|
291
295
|
def matches_parameter(self, parameter: FloatParameter) -> bool:
|
|
292
|
-
"""Check if the widget
|
|
296
|
+
"""Check if the widget values match the parameter."""
|
|
293
297
|
return (
|
|
294
|
-
self.
|
|
295
|
-
and self._widget.
|
|
296
|
-
and self._widget.
|
|
298
|
+
self._widget.description == parameter.name
|
|
299
|
+
and self._widget.value == parameter.value
|
|
300
|
+
and self._widget.min == parameter.min
|
|
301
|
+
and self._widget.max == parameter.max
|
|
302
|
+
and self._widget.step == parameter.step
|
|
297
303
|
)
|
|
298
304
|
|
|
299
305
|
def extra_updates_from_parameter(self, parameter: FloatParameter) -> None:
|
|
300
|
-
"""
|
|
306
|
+
"""Update the widget attributes from the parameter."""
|
|
301
307
|
current_value = self._widget.value
|
|
302
|
-
self._widget.min = parameter.
|
|
303
|
-
self._widget.max = parameter.
|
|
308
|
+
self._widget.min = parameter.min
|
|
309
|
+
self._widget.max = parameter.max
|
|
304
310
|
self._widget.step = parameter.step
|
|
305
|
-
self.value = max(parameter.
|
|
311
|
+
self.value = max(parameter.min, min(parameter.max, current_value))
|
|
306
312
|
|
|
307
313
|
|
|
308
314
|
class IntegerRangeWidget(BaseWidget[IntegerRangeParameter, widgets.IntRangeSlider]):
|
|
@@ -316,33 +322,39 @@ class IntegerRangeWidget(BaseWidget[IntegerRangeParameter, widgets.IntRangeSlide
|
|
|
316
322
|
margin: str = "3px 0px",
|
|
317
323
|
description_width: str = "initial",
|
|
318
324
|
) -> widgets.IntRangeSlider:
|
|
325
|
+
"""Create the integer range slider widget."""
|
|
326
|
+
low, high = parameter.value
|
|
319
327
|
return widgets.IntRangeSlider(
|
|
320
|
-
value=
|
|
321
|
-
min=parameter.
|
|
322
|
-
max=parameter.
|
|
328
|
+
value=[low, high],
|
|
329
|
+
min=parameter.min,
|
|
330
|
+
max=parameter.max,
|
|
331
|
+
step=1,
|
|
323
332
|
description=parameter.name,
|
|
324
|
-
|
|
325
|
-
layout=widgets.Layout(width=width, margin=margin),
|
|
333
|
+
continuous_update=continuous,
|
|
326
334
|
style={"description_width": description_width},
|
|
335
|
+
layout=widgets.Layout(width=width, margin=margin),
|
|
327
336
|
)
|
|
328
337
|
|
|
329
338
|
def matches_parameter(self, parameter: IntegerRangeParameter) -> bool:
|
|
330
|
-
"""Check if the widget
|
|
339
|
+
"""Check if the widget values match the parameter."""
|
|
340
|
+
low, high = parameter.value
|
|
331
341
|
return (
|
|
332
|
-
self.
|
|
333
|
-
and self._widget.
|
|
334
|
-
and self._widget.
|
|
342
|
+
self._widget.description == parameter.name
|
|
343
|
+
and self._widget.value[0] == low
|
|
344
|
+
and self._widget.value[1] == high
|
|
345
|
+
and self._widget.min == parameter.min
|
|
346
|
+
and self._widget.max == parameter.max
|
|
335
347
|
)
|
|
336
348
|
|
|
337
349
|
def extra_updates_from_parameter(self, parameter: IntegerRangeParameter) -> None:
|
|
338
|
-
"""
|
|
339
|
-
|
|
340
|
-
self._widget.min = parameter.
|
|
341
|
-
self._widget.max = parameter.
|
|
342
|
-
|
|
343
|
-
low = max(parameter.
|
|
344
|
-
high = max(parameter.
|
|
345
|
-
self.value =
|
|
350
|
+
"""Update the widget attributes from the parameter."""
|
|
351
|
+
low, high = self._widget.value
|
|
352
|
+
self._widget.min = parameter.min
|
|
353
|
+
self._widget.max = parameter.max
|
|
354
|
+
# Ensure values stay within bounds
|
|
355
|
+
low = max(parameter.min, min(parameter.max, low))
|
|
356
|
+
high = max(parameter.min, min(parameter.max, high))
|
|
357
|
+
self.value = [low, high]
|
|
346
358
|
|
|
347
359
|
|
|
348
360
|
class FloatRangeWidget(BaseWidget[FloatRangeParameter, widgets.FloatRangeSlider]):
|
|
@@ -356,35 +368,41 @@ class FloatRangeWidget(BaseWidget[FloatRangeParameter, widgets.FloatRangeSlider]
|
|
|
356
368
|
margin: str = "3px 0px",
|
|
357
369
|
description_width: str = "initial",
|
|
358
370
|
) -> widgets.FloatRangeSlider:
|
|
371
|
+
"""Create the float range slider widget."""
|
|
372
|
+
low, high = parameter.value
|
|
359
373
|
return widgets.FloatRangeSlider(
|
|
360
|
-
value=
|
|
361
|
-
min=parameter.
|
|
362
|
-
max=parameter.
|
|
374
|
+
value=[low, high],
|
|
375
|
+
min=parameter.min,
|
|
376
|
+
max=parameter.max,
|
|
363
377
|
step=parameter.step,
|
|
364
378
|
description=parameter.name,
|
|
365
|
-
|
|
366
|
-
layout=widgets.Layout(width=width, margin=margin),
|
|
379
|
+
continuous_update=continuous,
|
|
367
380
|
style={"description_width": description_width},
|
|
381
|
+
layout=widgets.Layout(width=width, margin=margin),
|
|
368
382
|
)
|
|
369
383
|
|
|
370
384
|
def matches_parameter(self, parameter: FloatRangeParameter) -> bool:
|
|
371
|
-
"""Check if the widget
|
|
385
|
+
"""Check if the widget values match the parameter."""
|
|
386
|
+
low, high = parameter.value
|
|
372
387
|
return (
|
|
373
|
-
self.
|
|
374
|
-
and self._widget.
|
|
375
|
-
and self._widget.
|
|
388
|
+
self._widget.description == parameter.name
|
|
389
|
+
and self._widget.value[0] == low
|
|
390
|
+
and self._widget.value[1] == high
|
|
391
|
+
and self._widget.min == parameter.min
|
|
392
|
+
and self._widget.max == parameter.max
|
|
393
|
+
and self._widget.step == parameter.step
|
|
376
394
|
)
|
|
377
395
|
|
|
378
396
|
def extra_updates_from_parameter(self, parameter: FloatRangeParameter) -> None:
|
|
379
|
-
"""
|
|
380
|
-
|
|
381
|
-
self._widget.min = parameter.
|
|
382
|
-
self._widget.max = parameter.
|
|
397
|
+
"""Update the widget attributes from the parameter."""
|
|
398
|
+
low, high = self._widget.value
|
|
399
|
+
self._widget.min = parameter.min
|
|
400
|
+
self._widget.max = parameter.max
|
|
383
401
|
self._widget.step = parameter.step
|
|
384
|
-
|
|
385
|
-
low = max(parameter.
|
|
386
|
-
high = max(parameter.
|
|
387
|
-
self.value =
|
|
402
|
+
# Ensure values stay within bounds
|
|
403
|
+
low = max(parameter.min, min(parameter.max, low))
|
|
404
|
+
high = max(parameter.min, min(parameter.max, high))
|
|
405
|
+
self.value = [low, high]
|
|
388
406
|
|
|
389
407
|
|
|
390
408
|
class UnboundedIntegerWidget(BaseWidget[UnboundedIntegerParameter, widgets.IntText]):
|
|
@@ -447,7 +465,7 @@ class UnboundedFloatWidget(BaseWidget[UnboundedFloatParameter, widgets.FloatText
|
|
|
447
465
|
class ButtonWidget(BaseWidget[ButtonAction, widgets.Button]):
|
|
448
466
|
"""Widget for button parameters."""
|
|
449
467
|
|
|
450
|
-
|
|
468
|
+
is_action: bool = True
|
|
451
469
|
|
|
452
470
|
def _create_widget(
|
|
453
471
|
self,
|