From 47f83a4759fedc6e41953155a9148adfbc27e9ce Mon Sep 17 00:00:00 2001 From: Tom Schierenbeck Date: Tue, 26 Mar 2024 17:35:27 +0100 Subject: [PATCH] Started to work on more engaging examples. --- doc/conf.py | 4 +- doc/examples | 1 + doc/index.rst | 5 +- doc/logo/Tomato.png | Bin 0 -> 787 bytes doc/notebooks/example.ipynb | 1 - doc/notebooks/independent_constraints.ipynb | 1 - examples/door.ipynb | 2510 ++++++++++++ {example => examples}/example.ipynb | 195 +- examples/logo_generation.ipynb | 3348 +++++++++++++++++ .../product_spaces.ipynb | 4 +- src/random_events/events.py | 11 +- test/test_events.py | 1 + 12 files changed, 5991 insertions(+), 90 deletions(-) create mode 120000 doc/examples create mode 100644 doc/logo/Tomato.png delete mode 120000 doc/notebooks/example.ipynb delete mode 120000 doc/notebooks/independent_constraints.ipynb create mode 100644 examples/door.ipynb rename {example => examples}/example.ipynb (99%) create mode 100644 examples/logo_generation.ipynb rename example/independent_constraints.ipynb => examples/product_spaces.ipynb (99%) diff --git a/doc/conf.py b/doc/conf.py index a29b0af..faba1d5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -5,6 +5,7 @@ # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config +import os # -- Path setup -------------------------------------------------------------- @@ -98,7 +99,8 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['static'] +html_static_path = ['_static'] +html_logo = os.path.join("logo", "Tomato.png") # Custom sidebar templates, must be a dictionary that maps document names # to template names. diff --git a/doc/examples b/doc/examples new file mode 120000 index 0000000..785887f --- /dev/null +++ b/doc/examples @@ -0,0 +1 @@ +../examples/ \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index 49ebf47..fe18133 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -96,8 +96,9 @@ Examples ======== .. nbgallery:: - notebooks/example - notebooks/independent_constraints + examples/example + examples/product_spaces + examples/logo_generation .. toctree:: :maxdepth: 2 diff --git a/doc/logo/Tomato.png b/doc/logo/Tomato.png new file mode 100644 index 0000000000000000000000000000000000000000..b780415a1c2acdfe65eacebd37c8ee0bddb84297 GIT binary patch literal 787 zcmeAS@N?(olHy`uVBq!ia0vp^$AEY@2OE&IQ-A0Lq!^2X+?^QKos)UVz`%6Y)5S5Q zV$R#U8-0&B2si}t1u_YmxSG1OxP&+d3tVJo@tE-EKyk)X<0}1aYqp+?m#)}SzUz_9 z{O)(vQ6=$h>%PY^#3&^?2(YnW5C%;jvOmu_e);v|Nvt;Zdwlf1-_}hz-k`w4aR>`> zjO$!-&6D|?ld+m5z}7N*ulR-=tL!T*rRqzJaho&!lV|_M@7wQI6mL8jVc z zdmdKI;Vst0DZ6pwg3PC literal 0 HcmV?d00001 diff --git a/doc/notebooks/example.ipynb b/doc/notebooks/example.ipynb deleted file mode 120000 index ee4b7a5..0000000 --- a/doc/notebooks/example.ipynb +++ /dev/null @@ -1 +0,0 @@ -../../example/example.ipynb \ No newline at end of file diff --git a/doc/notebooks/independent_constraints.ipynb b/doc/notebooks/independent_constraints.ipynb deleted file mode 120000 index af1d645..0000000 --- a/doc/notebooks/independent_constraints.ipynb +++ /dev/null @@ -1 +0,0 @@ -../../example/independent_constraints.ipynb \ No newline at end of file diff --git a/examples/door.ipynb b/examples/door.ipynb new file mode 100644 index 0000000..f4a9463 --- /dev/null +++ b/examples/door.ipynb @@ -0,0 +1,2510 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 5, + "id": "initial_id", + "metadata": { + "collapsed": true, + "ExecuteTime": { + "end_time": "2024-03-26T16:33:15.695152Z", + "start_time": "2024-03-26T16:33:15.610016Z" + } + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "data": [ + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": true, + "x": [ + 0, + 0, + 2, + 2, + 0, + 0, + 2, + 2 + ], + "y": [ + 5, + 10, + 10, + 5, + 5, + 10, + 10, + 5 + ], + "z": [ + 0, + 0, + 0, + 0, + 10, + 10, + 10, + 10 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 4, + 4, + 6, + 6, + 4, + 4, + 6, + 6 + ], + "y": [ + 5, + 10, + 10, + 5, + 5, + 10, + 10, + 5 + ], + "z": [ + 0, + 0, + 0, + 0, + 10, + 10, + 10, + 10 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 4, + 4, + 2, + 2, + 4, + 4 + ], + "y": [ + 5, + 10, + 10, + 5, + 5, + 10, + 10, + 5 + ], + "z": [ + 0, + 0, + 0, + 0, + 10, + 10, + 10, + 10 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 0, + 0, + 2, + 2, + 0, + 0, + 2, + 2 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 0, + 0, + 0, + 0, + 10, + 10, + 10, + 10 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 4, + 4, + 6, + 6, + 4, + 4, + 6, + 6 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 0, + 0, + 0, + 0, + 10, + 10, + 10, + 10 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 2.5, + 2.5, + 2, + 2, + 2.5, + 2.5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 0, + 0, + 0, + 0, + 6, + 6, + 6, + 6 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 2.5, + 2.5, + 2, + 2, + 2.5, + 2.5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 8, + 8, + 8, + 8, + 10, + 10, + 10, + 10 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 3.5, + 3.5, + 4, + 4, + 3.5, + 3.5, + 4, + 4 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 0, + 0, + 0, + 0, + 6, + 6, + 6, + 6 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 3.5, + 3.5, + 4, + 4, + 3.5, + 3.5, + 4, + 4 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 8, + 8, + 8, + 8, + 10, + 10, + 10, + 10 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 2.5, + 2.5, + 3.5, + 3.5, + 2.5, + 2.5, + 3.5, + 3.5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 0, + 0, + 0, + 0, + 3, + 3, + 3, + 3 + ], + "type": "mesh3d" + }, + { + "color": "grey", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375482657952", + "name": "Event", + "showlegend": false, + "x": [ + 2.5, + 2.5, + 3.5, + 3.5, + 2.5, + 2.5, + 3.5, + 3.5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 8, + 8, + 8, + 8, + 10, + 10, + 10, + 10 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140376849258528", + "name": "Event", + "showlegend": true, + "x": [ + 2, + 2, + 4, + 4, + 2, + 2, + 4, + 4 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 6, + 6, + 6, + 6, + 8, + 8, + 8, + 8 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140376849258528", + "name": "Event", + "showlegend": false, + "x": [ + 2.5, + 2.5, + 3.5, + 3.5, + 2.5, + 2.5, + 3.5, + 3.5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 3, + 3, + 3, + 3, + 6, + 6, + 6, + 6 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375508535424", + "name": "Event", + "showlegend": true, + "x": [ + 1, + 1, + 2, + 2, + 1, + 1, + 2, + 2 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 5, + 5, + 5, + 5, + 9, + 9, + 9, + 9 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375508535424", + "name": "Event", + "showlegend": false, + "x": [ + 4, + 4, + 5, + 5, + 4, + 4, + 5, + 5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 5, + 5, + 5, + 5, + 9, + 9, + 9, + 9 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375508535424", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 2.5, + 2.5, + 2, + 2, + 2.5, + 2.5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 5, + 5, + 5, + 5, + 6, + 6, + 6, + 6 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375508535424", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 2.5, + 2.5, + 2, + 2, + 2.5, + 2.5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 8, + 8, + 8, + 8, + 9, + 9, + 9, + 9 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375508535424", + "name": "Event", + "showlegend": false, + "x": [ + 3.5, + 3.5, + 4, + 4, + 3.5, + 3.5, + 4, + 4 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 5, + 5, + 5, + 5, + 6, + 6, + 6, + 6 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375508535424", + "name": "Event", + "showlegend": false, + "x": [ + 3.5, + 3.5, + 4, + 4, + 3.5, + 3.5, + 4, + 4 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 8, + 8, + 8, + 8, + 9, + 9, + 9, + 9 + ], + "type": "mesh3d" + }, + { + "color": "#bcbd22", + "flatshading": true, + "i": [ + 7, + 0, + 0, + 0, + 4, + 4, + 6, + 6, + 4, + 0, + 3, + 2 + ], + "j": [ + 3, + 4, + 1, + 2, + 5, + 6, + 5, + 2, + 0, + 1, + 6, + 3 + ], + "k": [ + 0, + 7, + 2, + 3, + 6, + 7, + 1, + 1, + 5, + 5, + 7, + 6 + ], + "legendgroup": "140375508535424", + "name": "Event", + "showlegend": false, + "x": [ + 2.5, + 2.5, + 3.5, + 3.5, + 2.5, + 2.5, + 3.5, + 3.5 + ], + "y": [ + 0, + 5, + 5, + 0, + 0, + 5, + 5, + 0 + ], + "z": [ + 8, + 8, + 8, + 8, + 9, + 9, + 9, + 9 + ], + "type": "mesh3d" + } + ], + "layout": { + "template": { + "data": { + "histogram2dcontour": [ + { + "type": "histogram2dcontour", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "choropleth": [ + { + "type": "choropleth", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "histogram2d": [ + { + "type": "histogram2d", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "heatmap": [ + { + "type": "heatmap", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "heatmapgl": [ + { + "type": "heatmapgl", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "contourcarpet": [ + { + "type": "contourcarpet", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "contour": [ + { + "type": "contour", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "surface": [ + { + "type": "surface", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "mesh3d": [ + { + "type": "mesh3d", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "parcoords": [ + { + "type": "parcoords", + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterpolargl": [ + { + "type": "scatterpolargl", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "scattergeo": [ + { + "type": "scattergeo", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterpolar": [ + { + "type": "scatterpolar", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scatter3d": [ + { + "type": "scatter3d", + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scattermapbox": [ + { + "type": "scattermapbox", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterternary": [ + { + "type": "scatterternary", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scattercarpet": [ + { + "type": "scattercarpet", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ] + }, + "layout": { + "autotypenumbers": "strict", + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "hovermode": "closest", + "hoverlabel": { + "align": "left" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "bgcolor": "rgb(17,17,17)", + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "ternary": { + "bgcolor": "rgb(17,17,17)", + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "sequential": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ], + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ] + }, + "xaxis": { + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "automargin": true, + "zerolinewidth": 2 + }, + "yaxis": { + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "automargin": true, + "zerolinewidth": 2 + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "subunitcolor": "#506784", + "showland": true, + "showlakes": true, + "lakecolor": "rgb(17,17,17)" + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "borderwidth": 1, + "bordercolor": "rgb(17,17,17)", + "tickwidth": 0 + }, + "mapbox": { + "style": "dark" + } + } + } + }, + "config": { + "plotlyServerURL": "https://plot.ly" + } + }, + "text/html": "
" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from random_events.events import Event, ComplexEvent\n", + "from random_events.variables import Continuous\n", + "import portion\n", + "import plotly.graph_objects as go\n", + "\n", + "\n", + "grey = \"#7f7f7f\"\n", + "gold = \"#bcbd22\"\n", + "\n", + "x = Continuous(\"x\")\n", + "y = Continuous(\"y\")\n", + "z = Continuous(\"z\")\n", + "\n", + "lock = Event({x: portion.closedopen(0, 6), y: portion.closedopen(0, 10), z: portion.closedopen(0, 10)})\n", + "\n", + "keyhole = Event({y: portion.closedopen(0, 5), x: portion.closedopen(2, 4), z: portion.closedopen(6, 8)})\n", + "keyhole_rod = Event({y: portion.closedopen(0, 5), x: portion.closedopen(2.5, 3.5), z: portion.closedopen(3, 6)})\n", + "keyhole |= keyhole_rod\n", + "\n", + "keyhole_outer_ring = Event({y: portion.closedopen(0, 5), x: portion.closedopen(1, 5), z: portion.closedopen(5, 9)})\n", + "keyhole_outer_ring = keyhole_outer_ring.difference(keyhole)\n", + "\n", + "lock = lock.difference(keyhole)\n", + "fig = go.Figure()\n", + "fig.add_traces(lock.plot(color=\"grey\"))\n", + "fig.add_traces(keyhole.plot(gold))\n", + "fig.add_traces(keyhole_outer_ring.plot(gold))\n", + "fig.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/example/example.ipynb b/examples/example.ipynb similarity index 99% rename from example/example.ipynb rename to examples/example.ipynb index dcaa6b9..e6e7b71 100644 --- a/example/example.ipynb +++ b/examples/example.ipynb @@ -16,13 +16,13 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 15, "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.222155Z", - "start_time": "2024-03-15T13:14:44.039779Z" + "end_time": "2024-03-26T12:36:19.578198Z", + "start_time": "2024-03-26T12:36:19.539637Z" } }, "outputs": [ @@ -55,13 +55,13 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 16, "outputs": [ { "data": { "text/plain": "(Symbolic(symbol), Integer(integer), Continuous(real))" }, - "execution_count": 2, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -89,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 17, "outputs": [ { "name": "stdout", @@ -107,8 +107,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.262305Z", - "start_time": "2024-03-15T13:14:44.229945Z" + "end_time": "2024-03-26T12:36:19.624431Z", + "start_time": "2024-03-26T12:36:19.622170Z" } }, "id": "a3aed36278dab281" @@ -125,13 +125,13 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 18, "outputs": [ { "data": { "text/plain": "{Symbolic(symbol): ('Rain',), Continuous(real): (-inf,2)}" }, - "execution_count": 4, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -143,8 +143,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.267754Z", - "start_time": "2024-03-15T13:14:44.263508Z" + "end_time": "2024-03-26T12:36:19.630312Z", + "start_time": "2024-03-26T12:36:19.625221Z" } }, "id": "a81cd22d80129c04" @@ -162,7 +162,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 19, "outputs": [ { "name": "stdout", @@ -180,8 +180,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.276053Z", - "start_time": "2024-03-15T13:14:44.268462Z" + "end_time": "2024-03-26T12:36:19.634878Z", + "start_time": "2024-03-26T12:36:19.630986Z" } }, "id": "4975045ed9540d52" @@ -198,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 20, "outputs": [ { "name": "stdout", @@ -217,8 +217,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.286677Z", - "start_time": "2024-03-15T13:14:44.284174Z" + "end_time": "2024-03-26T12:36:19.640375Z", + "start_time": "2024-03-26T12:36:19.635510Z" } }, "id": "b4da0a20e367a1c0" @@ -235,15 +235,15 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 21, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{Symbolic(symbol): ('Rain',), Continuous(real): (-inf,2)} u {Symbolic(symbol): ('Apple',), Continuous(real): (1,4)} u {Symbolic(symbol): ('Rain',), Continuous(real): [2,4)}\n", - "{Symbolic(symbol): ('Apple',), Continuous(real): (1,4)} u {Symbolic(symbol): ('Rain',), Continuous(real): [2,4)}\n", - "{Symbolic(symbol): ('Apple', 'Dog'), Continuous(real): (-inf,+inf)} u {Continuous(real): [2,+inf), Symbolic(symbol): ('Rain',)}\n" + "{Continuous(real): (-inf,2), Symbolic(symbol): ('Rain',)} u {Continuous(real): (1,4), Symbolic(symbol): ('Apple',)} u {Continuous(real): [2,4), Symbolic(symbol): ('Rain',)}\n", + "{Continuous(real): (1,4), Symbolic(symbol): ('Apple',)} u {Continuous(real): [2,4), Symbolic(symbol): ('Rain',)}\n", + "{Continuous(real): (-inf,+inf), Symbolic(symbol): ('Apple', 'Dog')} u {Continuous(real): [2,+inf), Symbolic(symbol): ('Rain',)}\n" ] } ], @@ -255,8 +255,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.329622Z", - "start_time": "2024-03-15T13:14:44.326152Z" + "end_time": "2024-03-26T12:36:19.646899Z", + "start_time": "2024-03-26T12:36:19.641439Z" } }, "id": "e8bb102d6d36e9a8" @@ -273,7 +273,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 22, "outputs": [ { "name": "stdout", @@ -291,8 +291,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.411528Z", - "start_time": "2024-03-15T13:14:44.408918Z" + "end_time": "2024-03-26T12:36:19.652239Z", + "start_time": "2024-03-26T12:36:19.647768Z" } }, "id": "1463b40805ebaddd" @@ -323,14 +323,16 @@ 0, 1, 1, - 0 + 0, + null ], "y": [ 0, 1, 1, 0, - 0 + 0, + null ], "type": "scatter" } @@ -1176,7 +1178,7 @@ "plotlyServerURL": "https://plot.ly" } }, - "text/html": "
" + "text/html": "
" }, "metadata": {}, "output_type": "display_data" @@ -1192,12 +1194,12 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.466827Z", - "start_time": "2024-03-15T13:14:44.453509Z" + "end_time": "2024-03-26T12:36:19.659964Z", + "start_time": "2024-03-26T12:36:19.652890Z" } }, "id": "8c25f3846c860230", - "execution_count": 9 + "execution_count": 23 }, { "cell_type": "markdown", @@ -1218,81 +1220,79 @@ "data": [ { "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, "mode": "lines", "name": "Event", + "showlegend": true, "x": [ -1, -1, + 0, + 0, + -1, + null, + 1, + 1, 2, 2, - -1 + 1, + null ], "y": [ -1, - 0, - 0, + 2, + 2, -1, - -1 - ], - "type": "scatter" - }, - { - "fill": "toself", - "mode": "lines", - "name": "Event", - "x": [ -1, + null, -1, 2, 2, - -1 - ], - "y": [ - 1, - 2, - 2, - 1, - 1 + -1, + -1, + null ], "type": "scatter" }, { "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, "mode": "lines", "name": "Event", + "showlegend": false, "x": [ - -1, - -1, 0, - 0, - -1 - ], - "y": [ 0, 1, 1, 0, - 0 - ], - "type": "scatter" - }, - { - "fill": "toself", - "mode": "lines", - "name": "Event", - "x": [ + null, + 0, + 0, 1, 1, - 2, - 2, - 1 + 0, + null ], "y": [ + -1, 0, + 0, + -1, + -1, + null, + 1, + 2, + 2, 1, 1, - 0, - 0 + null ], "type": "scatter" } @@ -1300,12 +1300,12 @@ "layout": { "xaxis": { "title": { - "text": "y" + "text": "x" } }, "yaxis": { "title": { - "text": "x" + "text": "y" } }, "template": { @@ -2138,7 +2138,7 @@ "plotlyServerURL": "https://plot.ly" } }, - "text/html": "
" + "text/html": "
" }, "metadata": {}, "output_type": "display_data" @@ -2154,12 +2154,49 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-15T13:14:44.525560Z", - "start_time": "2024-03-15T13:14:44.519667Z" + "end_time": "2024-03-26T12:36:19.670541Z", + "start_time": "2024-03-26T12:36:19.660541Z" } }, "id": "d22ef1b9c9b7c767", - "execution_count": 10 + "execution_count": 24 + }, + { + "cell_type": "markdown", + "source": [ + "Serialization from and to json is also possible." + ], + "metadata": { + "collapsed": false + }, + "id": "45dd9ba23b5c9d74" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "text/plain": "True" + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "complement_json = complement.to_json()\n", + "complement_from_json = ComplexEvent.from_json(complement_json)\n", + "complement_from_json == complement" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-26T12:36:29.802735Z", + "start_time": "2024-03-26T12:36:29.799361Z" + } + }, + "id": "12b0c378134e8a09", + "execution_count": 26 } ], "metadata": { diff --git a/examples/logo_generation.ipynb b/examples/logo_generation.ipynb new file mode 100644 index 0000000..4c5d3fe --- /dev/null +++ b/examples/logo_generation.ipynb @@ -0,0 +1,3348 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Advanced Use of Random Events\n", + "\n", + "In this tutorial we will look at a humorous application of random events. This examples shows, that elements from the product algebra, can take almost any shape, such as a tomato. \n", + "First, we import the necessary packages and define two variables." + ], + "metadata": { + "collapsed": false + }, + "id": "398a700bb678f08f" + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "initial_id", + "metadata": { + "collapsed": true, + "ExecuteTime": { + "end_time": "2024-03-26T12:53:03.558691Z", + "start_time": "2024-03-26T12:53:03.390668Z" + } + }, + "outputs": [ + { + "data": { + "text/html": " \n " + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import os.path\n", + "from random_events.events import Event, ComplexEvent\n", + "from random_events.variables import Continuous\n", + "from PIL import Image\n", + "import numpy as np\n", + "import portion\n", + "import plotly\n", + "plotly.offline.init_notebook_mode()\n", + "import plotly.graph_objects as go" + ] + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "x = Continuous(\"x\")\n", + "y = Continuous(\"y\")" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-26T12:53:03.562325Z", + "start_time": "2024-03-26T12:53:03.559940Z" + } + }, + "id": "29d0b28a5e6f48ca", + "execution_count": 2 + }, + { + "cell_type": "markdown", + "source": [ + "Next, let's load the logo of this package." + ], + "metadata": { + "collapsed": false + }, + "id": "754e1b2e8e1fb9f5" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "text/plain": "", + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMYAAAC7CAYAAAA+J+FCAAAGNklEQVR4Ae3dMZIUVxBFUUahJWDBpliNLJmyWI02NVjsAaEQEbj/datyyHoHCyN/Z+Z9daOM/jH98s6/Rwh8e+TQwZmXgxolAwR+G+ihBQLrCBBjXWQGniBAjAnKeqwjQIx1kRl4ggAxJijrsY4AMdZFZuAJAsSYoKzHOgLEWBeZgScIEGOCsh7rCBBjXWQGniDgCsJPysfXPP78+4+fp/7H//316XPyabJLaIW13hghMOUdBIjRkbMtQwLECIEp7yBAjI6cbRkSIEYITHkHAWJ05GzLkAAxQmDKOwgQoyNnW4YEiBECU95BgBgdOdsyJOBaQQjsR7nrI49xW3PKG2NNVAadJECMSdp6rSFAjDVRGXSSADEmaeu1hgAx1kRl0EkCxJikrdcaAsRYE5VBJwkQY5K2XmsIEGNNVAadJECMSdp6rSHw+5pJHxv0+OrGYx+/5tRVHG57pcgbY82zbdBJAsSYpK3XGgLEWBOVQScJEGOStl5rCBBjTVQGnSRAjEnaeq0hQIw1URl0kgAxJmnrtYYAMdZEZdBJAsSYpK3XGgK/ylf6l1xZuOoHXtake/Gg4Q/dJNO8+XPpjZHEpbaGADFqorZoQoAYCS21NQSIURO1RRMCxEhoqa0hQIyaqC2aECBGQkttDQFi1ERt0YQAMRJaamsIEKMmaosmBK786n3VNY/kesO2qya/wm7JDMkD/L32kmfYGyNMQXkHAWJ05GzLkAAxQmDKOwgQoyNnW4YEiBECU95BgBgdOdsyJECMEJjyDgLE6MjZliEBYoTAlHcQIEZHzrYMCaQ/HHN8zePrh4/Ho7z/8npcmxQm1xCieT99Ph7jqusjd94tyuLL6/Ez+T204+sj3hjHj7jCJgLEaErbrscEiHGMSmETAWI0pW3XYwLEOEalsIkAMZrStusxAWIco1LYRIAYTWnb9ZgAMY5RKWwiQIymtO16TOD4K/Ifn3j89Xv4tf7xwElhMkPyuUntVddd7PZfCiHf4+fdGyN5ytXWECBGTdQWTQgQI6GltoYAMWqitmhCgBgJLbU1BIhRE7VFEwLESGiprSFAjJqoLZoQIEZCS20NAWLURG3RhMC/X5Ffcs0jGUItAhMEkusj3hgTieixjgAx1kVm4AkCxJigrMc6AsRYF5mBJwgQY4KyHusIEGNdZAaeIECMCcp6rCNAjHWRGXiCADEmKOuxjgAx1kVm4AkCxJigrMc6AsRYF5mBJwgQY4KyHusIEGNdZAaeIECMCcp6rCNAjHWRGXiCADEmKOuxjgAx1kVm4AkCxJigrMc6AsRYF5mBJwgQY4KyHusIEGNdZAaeIECMCcp6rCNAjHWRGXiCADEmKOuxjgAx1kVm4AkCxJigrMc6AsRYF5mBJwgQY4KyHusIEGNdZAaeIECMCcp6rCNAjHWRGXiCADEmKOuxjgAx1kVm4AkCxJigrMc6AsRYF5mBJwgQY4KyHusIEGNdZAaeIECMCcp6rCNAjHWRGXiCADEmKOuxjgAx1kVm4AkCxJigrMc6Ai/hxN9O679++Hhaqg6Bhwm8//KanD1+3r0xEqxqawgQoyZqiyYEiJHQUltDgBg1UVs0IUCMhJbaGgLEqInaogkBYiS01NYQIEZN1BZNCBAjoaW2hgAxaqK2aEKAGAkttTUEiFETtUUTAsRIaKmtIUCMmqgtmhAgRkJLbQ0BYtREbdGEADESWmprCBCjJmqLJgSIkdBSW0OAGDVRWzQhQIyEltoaAsd/NeEBIv6iyAPQHHn37qq//JGw9cZIaKmtIUCMmqgtmhAgRkJLbQ0BYtREbdGEADESWmprCBCjJmqLJgSIkdBSW0OAGDVRWzQhQIyEltoaAsSoidqiCYErr4QkcxxfH0k+1I/XJLTy2vDqRtLgzZ9Lb4wkLrU1BIhRE7VFEwLESGiprSFAjJqoLZoQIEZCS20NAWLURG3RhAAxElpqawgQoyZqiyYEiJHQUltDgBg1UVs0IfDmX70nwz5Qe8lVkwfmuOuR2z4/3hh3fWTt9RQBYjyFz+G7EiDGXZO111MEiPEUPofvSoAYd03WXk8RIMZT+By+KwFi3DVZez1FgBhP4XP4rgSIcddk7fUUAWI8hc/huxL4B6D7SoucxoO8AAAAAElFTkSuQmCC" + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "path = os.path.join(\"..\", \"doc\", \"logo\", \"Tomato.png\")\n", + "image = im=Image.open(path)\n", + "image" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-26T12:53:03.620120Z", + "start_time": "2024-03-26T12:53:03.562953Z" + } + }, + "id": "6dfb4ca602b7491b", + "execution_count": 3 + }, + { + "cell_type": "markdown", + "source": [ + "We can express this image as an event that can be reasoned about." + ], + "metadata": { + "collapsed": false + }, + "id": "89195166d6606571" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "data": [ + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": true, + "x": [ + 5, + 5, + 13, + 13, + 5, + null + ], + "y": [ + -17, + -16, + -16, + -17, + -17, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 3, + 3, + 5, + 5, + 3, + null, + 3, + 3, + 5, + 5, + 3, + null, + 13, + 13, + 15, + 15, + 13, + null, + 13, + 13, + 15, + 15, + 13, + null + ], + "y": [ + -16, + -15, + -15, + -16, + -16, + null, + -5, + -4, + -4, + -5, + -5, + null, + -16, + -15, + -15, + -16, + -16, + null, + -5, + -4, + -4, + -5, + -5, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 3, + 3, + 2, + null, + 15, + 15, + 16, + 16, + 15, + null + ], + "y": [ + -15, + -14, + -14, + -15, + -15, + null, + -15, + -14, + -14, + -15, + -15, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 1, + 1, + 2, + 2, + 1, + null, + 16, + 16, + 17, + 17, + 16, + null + ], + "y": [ + -14, + -12, + -12, + -14, + -14, + null, + -14, + -12, + -12, + -14, + -14, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 0, + 0, + 1, + 1, + 0, + null, + 17, + 17, + 18, + 18, + 17, + null + ], + "y": [ + -12, + -8, + -8, + -12, + -12, + null, + -12, + -8, + -8, + -12, + -12, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 1, + 1, + 2, + 2, + 1, + null, + 3, + 3, + 5, + 5, + 3, + null, + 8, + 8, + 10, + 10, + 8, + null, + 13, + 13, + 15, + 15, + 13, + null, + 16, + 16, + 17, + 17, + 16, + null + ], + "y": [ + -8, + -7, + -7, + -8, + -8, + null, + -8, + -7, + -7, + -8, + -8, + null, + -8, + -7, + -7, + -8, + -8, + null, + -8, + -7, + -7, + -8, + -8, + null, + -8, + -7, + -7, + -8, + -8, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 1, + 1, + 2, + 2, + 1, + null, + 3, + 3, + 4, + 4, + 3, + null, + 5, + 5, + 6, + 6, + 5, + null, + 7, + 7, + 8, + 8, + 7, + null, + 10, + 10, + 11, + 11, + 10, + null, + 12, + 12, + 13, + 13, + 12, + null, + 14, + 14, + 15, + 15, + 14, + null, + 16, + 16, + 17, + 17, + 16, + null + ], + "y": [ + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 4, + 4, + 2, + null, + 6, + 6, + 7, + 7, + 6, + null, + 11, + 11, + 12, + 12, + 11, + null, + 14, + 14, + 16, + 16, + 14, + null + ], + "y": [ + -6, + -5, + -5, + -6, + -6, + null, + -6, + -5, + -5, + -6, + -6, + null, + -6, + -5, + -5, + -6, + -6, + null, + -6, + -5, + -5, + -6, + -6, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 5, + 5, + 8, + 8, + 5, + null, + 10, + 10, + 13, + 13, + 10, + null + ], + "y": [ + -4, + -3, + -3, + -4, + -4, + null, + -4, + -3, + -3, + -4, + -4, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 7, + 7, + 8, + 8, + 7, + null, + 10, + 10, + 11, + 11, + 10, + null + ], + "y": [ + -3, + -2, + -2, + -3, + -3, + null, + -3, + -2, + -2, + -3, + -3, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 6, + 6, + 7, + 7, + 6, + null, + 9, + 9, + 10, + 10, + 9, + null + ], + "y": [ + -2, + -1, + -1, + -2, + -2, + null, + -2, + -1, + -1, + -2, + -2, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(0,0,0)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 7, + 7, + 9, + 9, + 7, + null + ], + "y": [ + -1, + 0, + 0, + -1, + -1, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(124,176,118)" + }, + "mode": "lines", + "name": "Event", + "showlegend": true, + "x": [ + 4, + 4, + 5, + 5, + 4, + null, + 8, + 8, + 10, + 10, + 8, + null, + 13, + 13, + 14, + 14, + 13, + null + ], + "y": [ + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(124,176,118)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 4, + 4, + 6, + 6, + 4, + null, + 7, + 7, + 11, + 11, + 7, + null, + 12, + 12, + 14, + 14, + 12, + null + ], + "y": [ + -6, + -5, + -5, + -6, + -6, + null, + -6, + -5, + -5, + -6, + -6, + null, + -6, + -5, + -5, + -6, + -6, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(124,176,118)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 5, + 5, + 13, + 13, + 5, + null + ], + "y": [ + -5, + -4, + -4, + -5, + -5, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(124,176,118)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 8, + 8, + 10, + 10, + 8, + null + ], + "y": [ + -4, + -2, + -2, + -4, + -4, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(124,176,118)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 7, + 7, + 9, + 9, + 7, + null + ], + "y": [ + -2, + -1, + -1, + -2, + -2, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(236,26,27)" + }, + "mode": "lines", + "name": "Event", + "showlegend": true, + "x": [ + 5, + 5, + 13, + 13, + 5, + null + ], + "y": [ + -16, + -15, + -15, + -16, + -16, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(236,26,27)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 3, + 3, + 15, + 15, + 3, + null + ], + "y": [ + -15, + -14, + -14, + -15, + -15, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(236,26,27)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 16, + 16, + 2, + null + ], + "y": [ + -14, + -12, + -12, + -14, + -14, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(236,26,27)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 1, + 1, + 17, + 17, + 1, + null + ], + "y": [ + -12, + -8, + -8, + -12, + -12, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(236,26,27)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 3, + 3, + 2, + null, + 5, + 5, + 8, + 8, + 5, + null, + 10, + 10, + 13, + 13, + 10, + null, + 15, + 15, + 16, + 16, + 15, + null + ], + "y": [ + -8, + -7, + -7, + -8, + -8, + null, + -8, + -7, + -7, + -8, + -8, + null, + -8, + -7, + -7, + -8, + -8, + null, + -8, + -7, + -7, + -8, + -8, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "rgb(236,26,27)" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 3, + 3, + 2, + null, + 6, + 6, + 7, + 7, + 6, + null, + 11, + 11, + 12, + 12, + 11, + null, + 15, + 15, + 16, + 16, + 15, + null + ], + "y": [ + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null, + -7, + -6, + -6, + -7, + -7, + null + ], + "type": "scatter" + } + ], + "layout": { + "template": { + "data": { + "histogram2dcontour": [ + { + "type": "histogram2dcontour", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "choropleth": [ + { + "type": "choropleth", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "histogram2d": [ + { + "type": "histogram2d", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "heatmap": [ + { + "type": "heatmap", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "heatmapgl": [ + { + "type": "heatmapgl", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "contourcarpet": [ + { + "type": "contourcarpet", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "contour": [ + { + "type": "contour", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "surface": [ + { + "type": "surface", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "mesh3d": [ + { + "type": "mesh3d", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "parcoords": [ + { + "type": "parcoords", + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterpolargl": [ + { + "type": "scatterpolargl", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "scattergeo": [ + { + "type": "scattergeo", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterpolar": [ + { + "type": "scatterpolar", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scatter3d": [ + { + "type": "scatter3d", + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scattermapbox": [ + { + "type": "scattermapbox", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterternary": [ + { + "type": "scatterternary", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scattercarpet": [ + { + "type": "scattercarpet", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ] + }, + "layout": { + "autotypenumbers": "strict", + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "hovermode": "closest", + "hoverlabel": { + "align": "left" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "bgcolor": "rgb(17,17,17)", + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "ternary": { + "bgcolor": "rgb(17,17,17)", + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "sequential": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ], + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ] + }, + "xaxis": { + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "automargin": true, + "zerolinewidth": 2 + }, + "yaxis": { + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "automargin": true, + "zerolinewidth": 2 + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "subunitcolor": "#506784", + "showland": true, + "showlakes": true, + "lakecolor": "rgb(17,17,17)" + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "borderwidth": 1, + "bordercolor": "rgb(17,17,17)", + "tickwidth": 0 + }, + "mapbox": { + "style": "dark" + } + } + }, + "xaxis": { + "title": { + "text": "x" + } + }, + "yaxis": { + "title": { + "text": "y" + } + }, + "title": { + "text": "Random Events Tomato" + } + }, + "config": { + "plotlyServerURL": "https://plot.ly" + } + }, + "text/html": "
" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "image = np.array(image.resize((18, 17), Image.NEAREST))\n", + "colors = np.unique(image.reshape((image.shape[0] * image.shape[1], image.shape[2])), axis=0)[1:]\n", + "def indices_to_complex_event(indices: np.array) -> ComplexEvent:\n", + " result = ComplexEvent([])\n", + " for index in indices:\n", + " event = Event({y: portion.closedopen(-index[0] - 1, -index[0]),\n", + " x: portion.closedopen(index[1], index[1] + 1)})\n", + " result.events.append(event)\n", + " result = result.simplify()\n", + " return result.simplify()\n", + "\n", + "fig = go.Figure()\n", + "\n", + "complex_events = []\n", + "\n", + "for color in colors:\n", + " pixel_indices = np.transpose(np.nonzero(np.all(image == color, axis=-1)))\n", + " complex_event = indices_to_complex_event(pixel_indices)\n", + " complex_events.append(complex_event)\n", + " traces = complex_event.plot(f\"rgb({color[0]},{color[1]},{color[2]})\")\n", + " fig.update_layout(complex_event.plotly_layout())\n", + " fig.add_traces(traces)\n", + "\n", + "fig.update_layout(title=\"Random Events Tomato\")\n", + "fig.show()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-26T12:53:03.707686Z", + "start_time": "2024-03-26T12:53:03.621171Z" + } + }, + "id": "767c932bc1a6beb", + "execution_count": 4 + }, + { + "cell_type": "markdown", + "source": [ + "While the shape of a tomato as an event that can be used for probabilistic reasoning serves no particular research, it showcases that random events can take approximately any shape and not \"just\" rectangles.\n", + "Unions of complex events of any shape can also performed to get the tomato as an entire event and not a union of three different events." + ], + "metadata": { + "collapsed": false + }, + "id": "5bdcd00ab2fac7cf" + }, + { + "cell_type": "code", + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "data": [ + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": true, + "x": [ + 1, + 1, + 17, + 17, + 1, + null + ], + "y": [ + -12, + -6, + -6, + -12, + -12, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 2, + 2, + 16, + 16, + 2, + null, + 2, + 2, + 16, + 16, + 2, + null + ], + "y": [ + -15, + -12, + -12, + -15, + -15, + null, + -6, + -5, + -5, + -6, + -6, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 5, + 5, + 13, + 13, + 5, + null, + 5, + 5, + 13, + 13, + 5, + null + ], + "y": [ + -17, + -15, + -15, + -17, + -17, + null, + -5, + -4, + -4, + -5, + -5, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 6, + 6, + 10, + 10, + 6, + null + ], + "y": [ + -2, + -1, + -1, + -2, + -2, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 3, + 3, + 5, + 5, + 3, + null, + 3, + 3, + 5, + 5, + 3, + null, + 13, + 13, + 15, + 15, + 13, + null, + 13, + 13, + 15, + 15, + 13, + null + ], + "y": [ + -16, + -15, + -15, + -16, + -16, + null, + -5, + -4, + -4, + -5, + -5, + null, + -16, + -15, + -15, + -16, + -16, + null, + -5, + -4, + -4, + -5, + -5, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 1, + 1, + 2, + 2, + 1, + null, + 16, + 16, + 17, + 17, + 16, + null + ], + "y": [ + -14, + -12, + -12, + -14, + -14, + null, + -14, + -12, + -12, + -14, + -14, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 0, + 0, + 1, + 1, + 0, + null, + 17, + 17, + 18, + 18, + 17, + null + ], + "y": [ + -12, + -8, + -8, + -12, + -12, + null, + -12, + -8, + -8, + -12, + -12, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 5, + 5, + 8, + 8, + 5, + null, + 10, + 10, + 13, + 13, + 10, + null + ], + "y": [ + -4, + -3, + -3, + -4, + -4, + null, + -4, + -3, + -3, + -4, + -4, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 7, + 7, + 8, + 8, + 7, + null, + 10, + 10, + 11, + 11, + 10, + null + ], + "y": [ + -3, + -2, + -2, + -3, + -3, + null, + -3, + -2, + -2, + -3, + -3, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 7, + 7, + 9, + 9, + 7, + null + ], + "y": [ + -1, + 0, + 0, + -1, + -1, + null + ], + "type": "scatter" + }, + { + "fill": "toself", + "legendgroup": "Event", + "line": { + "color": "#636EFA" + }, + "mode": "lines", + "name": "Event", + "showlegend": false, + "x": [ + 8, + 8, + 10, + 10, + 8, + null + ], + "y": [ + -4, + -2, + -2, + -4, + -4, + null + ], + "type": "scatter" + } + ], + "layout": { + "xaxis": { + "title": { + "text": "x" + } + }, + "yaxis": { + "title": { + "text": "y" + } + }, + "template": { + "data": { + "histogram2dcontour": [ + { + "type": "histogram2dcontour", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "choropleth": [ + { + "type": "choropleth", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "histogram2d": [ + { + "type": "histogram2d", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "heatmap": [ + { + "type": "heatmap", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "heatmapgl": [ + { + "type": "heatmapgl", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "contourcarpet": [ + { + "type": "contourcarpet", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "contour": [ + { + "type": "contour", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "surface": [ + { + "type": "surface", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ] + } + ], + "mesh3d": [ + { + "type": "mesh3d", + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + ], + "scatter": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scatter" + } + ], + "parcoords": [ + { + "type": "parcoords", + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterpolargl": [ + { + "type": "scatterpolargl", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "bar": [ + { + "error_x": { + "color": "#f2f5fa" + }, + "error_y": { + "color": "#f2f5fa" + }, + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "scattergeo": [ + { + "type": "scattergeo", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterpolar": [ + { + "type": "scatterpolar", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "scattergl": [ + { + "marker": { + "line": { + "color": "#283442" + } + }, + "type": "scattergl" + } + ], + "scatter3d": [ + { + "type": "scatter3d", + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scattermapbox": [ + { + "type": "scattermapbox", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scatterternary": [ + { + "type": "scatterternary", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "scattercarpet": [ + { + "type": "scattercarpet", + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + } + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "baxis": { + "endlinecolor": "#A2B1C6", + "gridcolor": "#506784", + "linecolor": "#506784", + "minorgridcolor": "#506784", + "startlinecolor": "#A2B1C6" + }, + "type": "carpet" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#506784" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "header": { + "fill": { + "color": "#2a3f5f" + }, + "line": { + "color": "rgb(17,17,17)" + } + }, + "type": "table" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "rgb(17,17,17)", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ] + }, + "layout": { + "autotypenumbers": "strict", + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#f2f5fa" + }, + "hovermode": "closest", + "hoverlabel": { + "align": "left" + }, + "paper_bgcolor": "rgb(17,17,17)", + "plot_bgcolor": "rgb(17,17,17)", + "polar": { + "bgcolor": "rgb(17,17,17)", + "angularaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "radialaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "ternary": { + "bgcolor": "rgb(17,17,17)", + "aaxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "baxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + }, + "caxis": { + "gridcolor": "#506784", + "linecolor": "#506784", + "ticks": "" + } + }, + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "sequential": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0.0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1.0, + "#f0f921" + ] + ], + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ] + }, + "xaxis": { + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "automargin": true, + "zerolinewidth": 2 + }, + "yaxis": { + "gridcolor": "#283442", + "linecolor": "#506784", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#283442", + "automargin": true, + "zerolinewidth": 2 + }, + "scene": { + "xaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + }, + "yaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + }, + "zaxis": { + "backgroundcolor": "rgb(17,17,17)", + "gridcolor": "#506784", + "linecolor": "#506784", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#C8D4E3", + "gridwidth": 2 + } + }, + "shapedefaults": { + "line": { + "color": "#f2f5fa" + } + }, + "annotationdefaults": { + "arrowcolor": "#f2f5fa", + "arrowhead": 0, + "arrowwidth": 1 + }, + "geo": { + "bgcolor": "rgb(17,17,17)", + "landcolor": "rgb(17,17,17)", + "subunitcolor": "#506784", + "showland": true, + "showlakes": true, + "lakecolor": "rgb(17,17,17)" + }, + "title": { + "x": 0.05 + }, + "updatemenudefaults": { + "bgcolor": "#506784", + "borderwidth": 0 + }, + "sliderdefaults": { + "bgcolor": "#C8D4E3", + "borderwidth": 1, + "bordercolor": "rgb(17,17,17)", + "tickwidth": 0 + }, + "mapbox": { + "style": "dark" + } + } + }, + "title": { + "text": "Random Events Tomato as one Event" + } + }, + "config": { + "plotlyServerURL": "https://plot.ly" + } + }, + "text/html": "
" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "entire_event = complex_events[0] | complex_events[1] | complex_events[2]\n", + "fig = go.Figure(entire_event.plot(), entire_event.plotly_layout())\n", + "fig.update_layout(title=\"Random Events Tomato as one Event\")\n", + "fig.show()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-26T12:53:03.755929Z", + "start_time": "2024-03-26T12:53:03.708529Z" + } + }, + "id": "ce38e8a948d2a0d5", + "execution_count": 5 + }, + { + "cell_type": "markdown", + "source": [ + "I hope this bizarre examples aids you in understanding of the product algebra capabilities. \n", + "Using this event, you can calculate things like the probability of a tomato or the conditional distribution given a tomato. " + ], + "metadata": { + "collapsed": false + }, + "id": "576ab8ad7c53f09e" + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/example/independent_constraints.ipynb b/examples/product_spaces.ipynb similarity index 99% rename from example/independent_constraints.ipynb rename to examples/product_spaces.ipynb index 39e13d9..11050ce 100644 --- a/example/independent_constraints.ipynb +++ b/examples/product_spaces.ipynb @@ -3,9 +3,9 @@ { "cell_type": "markdown", "source": [ - "# Understanding product spaces\n", + "# Product Spaces\n", "\n", - "This tutorial aims to understand product spaces as they are implemented in the `random_events` package.\n", + "This tutorial aids in understanding product spaces and there implementation in the `random_events` package.\n", "As mentioned in the introduction, research has shown that events that are described by independent constraints (rules) are most likely the only events where probability estimation is tractable.\n", "Spaces that are constructed by independent constraints are called product spaces.\n", "\n", diff --git a/src/random_events/events.py b/src/random_events/events.py index 51d8c90..67117f6 100644 --- a/src/random_events/events.py +++ b/src/random_events/events.py @@ -368,7 +368,7 @@ def plot_3d(self) -> List[go.Mesh3d]: """ # form cartesian product of all intervals - intervals = [value._intervals for value in self.values()] + intervals = [value._intervals for _, value in sorted(self.items())] simple_events = list(itertools.product(*intervals)) traces = [] @@ -649,7 +649,7 @@ def complement(self) -> Self: for event in self.events[1:]: current_complement = event.complement() result = result.intersection(current_complement) - return result.make_events_disjoint().simplify() + return result.make_events_disjoint() # .simplify() def are_events_disjoint(self) -> bool: """ @@ -689,8 +689,11 @@ def plot(self, color="#636EFA") -> Union[List[go.Scatter], List[go.Mesh3d]]: event_traces = event.plot() for event_trace in event_traces: if len(event.keys()) == 2: - event_trace.update(legendgroup="Event", showlegend=show_legend, line=dict(color=color)) - show_legend = False + event_trace.update(name="Event", legendgroup=id(self), showlegend=show_legend, + line=dict(color=color)) + if len(event.keys()) == 3: + event_trace.update(name="Event", legendgroup=id(self), showlegend=show_legend, color=color) + show_legend = False traces.append(event_trace) return traces diff --git a/test/test_events.py b/test/test_events.py index fc987ac..57a93c4 100644 --- a/test/test_events.py +++ b/test/test_events.py @@ -369,6 +369,7 @@ def test_from_discrete_complement(self): def test_chained_complement(self): event = Event({self.x: portion.closed(0, 1), self.y: portion.closed(0, 1)}) complement = event.complement() + self.assertEqual(len(complement.events), 2) copied_event = complement.complement() self.assertEqual(len(copied_event.events), 1) self.assertEqual(copied_event.events[0], event)