diff --git a/CAD_Engine.ipynb b/CAD_Engine.ipynb
index e32980f..a3fd59e 100644
--- a/CAD_Engine.ipynb
+++ b/CAD_Engine.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 65,
"metadata": {},
"outputs": [],
"source": [
@@ -18,13 +18,15 @@
"import numpy as np\n",
"from datetime import datetime, timedelta\n",
"from decimal import Decimal, getcontext, ROUND_DOWN\n",
- "getcontext().prec=4\n",
- "getcontext().rounding = ROUND_DOWN"
+ "TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01')\n",
+ "import pandas as pd\n",
+ "# getcontext().prec=None\n",
+ "# getcontext().rounding = ROUND_DOWN"
]
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -55,38 +57,35 @@
" return lambda x: x\n",
" return partial(env_step_trigger, trigger_step, update_f)\n",
"\n",
- "def env_proc(trigger_step, update_f):\n",
- " def env_step_trigger(trigger_step, update_f, step):\n",
- " if step == trigger_step:\n",
- " return update_f\n",
- " else:\n",
- " return lambda x: x\n",
- " return partial(env_step_trigger, trigger_step, update_f)\n",
- "\n",
"def time_step(s, dt_str, fromat_str='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=1):\n",
" if s['mech_step'] == 0:\n",
" dt = datetime.strptime(dt_str, fromat_str)\n",
" t = dt + timedelta(days=days, minutes=minutes, seconds=seconds)\n",
" return t.strftime(fromat_str)\n",
" else: \n",
- " return dt_str"
+ " return dt_str\n",
+ "\n",
+ "def round_down(x, fp=TWOPLACES):\n",
+ " return x.quantize(TWOPLACES, rounding=ROUND_DOWN)\n",
+ " \n",
+ "# def round_down(f, fp=TWOPLACES):\n",
+ "# return (f).quantize(fp, ROUND_DOWN)"
]
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
- "# def pipeline(*steps):\n",
- "# return reduce(lambda x, y: y(x), list(steps))\n",
- "# def compose(*funcs):\n",
- "# return lambda x: reduce(lambda f, g: g(f), list(funcs), x)"
+ "\n",
+ "# esceptions:\n",
+ "# point to line giving problems and pass a sentinel"
]
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
@@ -95,29 +94,8 @@
" 'a': np.random.RandomState(2),\n",
" 'b': np.random.RandomState(3),\n",
" 'c': np.random.RandomState(3)\n",
- "}\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [],
- "source": [
- "a = np.random.RandomState(1)\n",
- "proc_one_coef_B = 1.3\n",
- "b = np.random.RandomState(2)\n",
+ "}\n",
"\n",
- "def pipe_f(x):\n",
- " return x"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {},
- "outputs": [],
- "source": [
"# UI Behaviors per Mechanism\n",
"def b1m1(step, sL, s):\n",
" return s['s1']\n",
@@ -138,7 +116,7 @@
"# UI Internal States per Mechanism\n",
"def s1m1(step, sL, s, _input):\n",
"# print(s['s1'])\n",
- " s['s1'] = s['s1']**2 + _input\n",
+ " s['s1'] = s['s1'] + _input\n",
"def s2m1(step, sL, s, _input):\n",
" s['s2'] = s['s2'] + 1 + _input\n",
"\n",
@@ -152,8 +130,7 @@
"def s2m3(step, sL, s, _input):\n",
" s['s2'] = s['s2'] + _input\n",
"\n",
- "# UI Exogenous States //per Mechanism \n",
- "\n",
+ "# UI Exogenous States #per Mechanism\n",
"proc_one_coef_A = 0.7\n",
"proc_one_coef_B = 1.3\n",
"def es3p1(step, sL, s, _input):\n",
@@ -164,7 +141,7 @@
" s['timestamp'] = time_step(s, s['timestamp'], seconds=1)\n",
"\n",
"\n",
- "#add env process f(s) read from time es\n",
+ "# add env process f(s) read from time es\n",
"# funcs execute in order\n",
"def env_a(x): \n",
" return x + 1\n",
@@ -189,7 +166,8 @@
" \"timestamp\": es5p2\n",
"}\n",
"\n",
- "# update time at the end of each pipeline (once per 'block')\n",
+ "# Update time at the end of each pipeline (once per 'block')\n",
+ "# Enable the acceptance of user defined time\n",
"env_processes = {\n",
" \"s3\": env_proc(1, env_a),\n",
" \"s4\": env_proc(1, pipe | env_b | what_ever)\n",
@@ -231,7 +209,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 73,
"metadata": {},
"outputs": [],
"source": [
@@ -273,6 +251,12 @@
"\n",
" apply_env_proc(env_processes, last_mut_obj, t_step)\n",
" \n",
+ "# print(last_mut_obj)\n",
+ " \n",
+ "# non_numeric = {k: v for k, v in last_mut_obj.items() if type(v) != Decimal}\n",
+ "# last_mut_obj = {k: round_down(v) for k, v in last_mut_obj.items() if type(v) == Decimal}\n",
+ "# last_mut_obj.update(non_numeric)\n",
+ "\n",
" for f in state_funcs:\n",
" f(m_step, sL, last_mut_obj, _input)\n",
" \n",
@@ -310,54 +294,39 @@
" # should only occur once for genesis state, placed before loop\n",
" head, *tail = simulation_list\n",
" head[-1]['mech_step'], head[-1]['time_step'] = 0, 0\n",
- " simulation_list = head, *tail\n",
+ " simulation_list = [head] + tail\n",
" return simulation_list"
]
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "{'s1': Decimal('2.221384236472411425810660220E+330'),\n",
- " 's2': Decimal('2.845096899831187764579913612E+330'),\n",
- " 's3': Decimal('3.622519693611211445932083740'),\n",
- " 's4': Decimal('5.161487081026327858663750787'),\n",
- " 'timestamp': '2018-10-01 15:16:32',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 8}"
+ "{'s1': Decimal('2'),\n",
+ " 's2': Decimal('4'),\n",
+ " 's3': Decimal('0'),\n",
+ " 's4': Decimal('0'),\n",
+ " 'timestamp': '2018-10-01 15:16:24',\n",
+ " 'mech_step': 0,\n",
+ " 'time_step': 0}"
]
},
- "execution_count": 9,
+ "execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "states_list = [state_dict]\n",
- "states_list\n",
- "{'s1': 8.742503764992283e+170,\n",
- " 's2': 1.119720780594405e+171,\n",
- " 's3': 4.251811100418906,\n",
- " 's4': 6.92728042985628,\n",
- " 'timestamp': '2018-10-01 15:16:31',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 7}\n",
- "{'s1': Decimal('2.221384236472411425810660220E+330'),\n",
- " 's2': Decimal('2.845096899831187764579913612E+330'),\n",
- " 's3': Decimal('3.622519693611211445932083740'),\n",
- " 's4': Decimal('5.161487081026327858663750787'),\n",
- " 'timestamp': '2018-10-01 15:16:32',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 8}"
+ "states_list[-1]"
]
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 71,
"metadata": {
"collapsed": true
},
@@ -365,443 +334,863 @@
{
"data": {
"text/plain": [
- "([{'s1': Decimal('2'),\n",
- " 's2': Decimal('4'),\n",
- " 's3': Decimal('0'),\n",
- " 's4': Decimal('0'),\n",
- " 'timestamp': '2018-10-01 15:16:24',\n",
- " 'mech_step': 0,\n",
- " 'time_step': 0}],\n",
- " [{'s1': Decimal('14'),\n",
- " 's2': Decimal('15'),\n",
- " 's3': Decimal('1.150'),\n",
- " 's4': Decimal('3.045'),\n",
- " 'timestamp': '2018-10-01 15:16:25',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 1},\n",
- " {'s1': Decimal('28.93'),\n",
- " 's2': Decimal('15'),\n",
- " 's3': Decimal('2.336'),\n",
- " 's4': Decimal('6.033'),\n",
- " 'timestamp': '2018-10-01 15:16:25',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 1},\n",
- " {'s1': Decimal('28.93'),\n",
- " 's2': Decimal('544.9'),\n",
- " 's3': Decimal('2.973'),\n",
- " 's4': Decimal('9.469'),\n",
- " 'timestamp': '2018-10-01 15:16:25',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 1}],\n",
- " [{'s1': Decimal('1.661E+4'),\n",
- " 's2': Decimal('1.632E+4'),\n",
- " 's3': Decimal('3.170'),\n",
- " 's4': Decimal('10.19'),\n",
- " 'timestamp': '2018-10-01 15:16:26',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 2},\n",
- " {'s1': Decimal('3.322E+4'),\n",
- " 's2': Decimal('1.632E+4'),\n",
- " 's3': Decimal('3.402'),\n",
- " 's4': Decimal('11.58'),\n",
- " 'timestamp': '2018-10-01 15:16:26',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 2},\n",
- " {'s1': Decimal('3.322E+4'),\n",
- " 's2': Decimal('5.012E+4'),\n",
- " 's3': Decimal('3.040'),\n",
- " 's4': Decimal('12.90'),\n",
- " 'timestamp': '2018-10-01 15:16:26',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 2}],\n",
- " [{'s1': Decimal('2.767E+9'),\n",
- " 's2': Decimal('1.664E+9'),\n",
- " 's3': Decimal('3.007'),\n",
- " 's4': Decimal('12.75'),\n",
- " 'timestamp': '2018-10-01 15:16:27',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 3},\n",
- " {'s1': Decimal('5.534E+9'),\n",
- " 's2': Decimal('1.664E+9'),\n",
- " 's3': Decimal('2.450'),\n",
- " 's4': Decimal('13.24'),\n",
- " 'timestamp': '2018-10-01 15:16:27',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 3},\n",
- " {'s1': Decimal('5.534E+9'),\n",
- " 's2': Decimal('7.198E+9'),\n",
- " 's3': Decimal('2.530'),\n",
- " 's4': Decimal('12.72'),\n",
- " 'timestamp': '2018-10-01 15:16:27',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 3}],\n",
- " [{'s1': Decimal('7.045E+19'),\n",
- " 's2': Decimal('3.983E+19'),\n",
- " 's3': Decimal('2.450'),\n",
- " 's4': Decimal('11.97'),\n",
- " 'timestamp': '2018-10-01 15:16:28',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 4},\n",
- " {'s1': Decimal('1.409E+20'),\n",
- " 's2': Decimal('3.983E+19'),\n",
- " 's3': Decimal('2.119'),\n",
- " 's4': Decimal('14.25'),\n",
- " 'timestamp': '2018-10-01 15:16:28',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 4},\n",
- " {'s1': Decimal('1.409E+20'),\n",
- " 's2': Decimal('1.807E+20'),\n",
- " 's3': Decimal('1.971'),\n",
- " 's4': Decimal('13.59'),\n",
- " 'timestamp': '2018-10-01 15:16:28',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 4}],\n",
- " [{'s1': Decimal('4.531E+40'),\n",
- " 's2': Decimal('2.546E+40'),\n",
- " 's3': Decimal('2.018'),\n",
- " 's4': Decimal('16.29'),\n",
- " 'timestamp': '2018-10-01 15:16:29',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 5},\n",
- " {'s1': Decimal('9.062E+40'),\n",
- " 's2': Decimal('2.546E+40'),\n",
- " 's3': Decimal('1.906'),\n",
- " 's4': Decimal('15.72'),\n",
- " 'timestamp': '2018-10-01 15:16:29',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 5},\n",
- " {'s1': Decimal('9.062E+40'),\n",
- " 's2': Decimal('1.160E+41'),\n",
- " 's3': Decimal('1.963'),\n",
- " 's4': Decimal('16.11'),\n",
- " 'timestamp': '2018-10-01 15:16:29',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 5}],\n",
- " [{'s1': Decimal('1.872E+82'),\n",
- " 's2': Decimal('1.051E+82'),\n",
- " 's3': Decimal('2.071'),\n",
- " 's4': Decimal('17.86'),\n",
- " 'timestamp': '2018-10-01 15:16:30',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 6},\n",
- " {'s1': Decimal('3.744E+82'),\n",
- " 's2': Decimal('1.051E+82'),\n",
- " 's3': Decimal('1.896'),\n",
- " 's4': Decimal('17.90'),\n",
- " 'timestamp': '2018-10-01 15:16:30',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 6},\n",
- " {'s1': Decimal('3.744E+82'),\n",
- " 's2': Decimal('4.795E+82'),\n",
- " 's3': Decimal('1.836'),\n",
- " 's4': Decimal('18.60'),\n",
- " 'timestamp': '2018-10-01 15:16:30',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 6}],\n",
- " [{'s1': Decimal('3.196E+165'),\n",
- " 's2': Decimal('1.795E+165'),\n",
- " 's3': Decimal('2.229'),\n",
- " 's4': Decimal('18.15'),\n",
- " 'timestamp': '2018-10-01 15:16:31',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 7},\n",
- " {'s1': Decimal('6.392E+165'),\n",
- " 's2': Decimal('1.795E+165'),\n",
- " 's3': Decimal('2.255'),\n",
- " 's4': Decimal('17.28'),\n",
- " 'timestamp': '2018-10-01 15:16:31',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 7},\n",
- " {'s1': Decimal('6.392E+165'),\n",
- " 's2': Decimal('8.187E+165'),\n",
- " 's3': Decimal('2.064'),\n",
- " 's4': Decimal('16.99'),\n",
- " 'timestamp': '2018-10-01 15:16:31',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 7}],\n",
- " [{'s1': Decimal('9.318E+331'),\n",
- " 's2': Decimal('5.233E+331'),\n",
- " 's3': Decimal('2.076'),\n",
- " 's4': Decimal('15.88'),\n",
- " 'timestamp': '2018-10-01 15:16:32',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 8},\n",
- " {'s1': Decimal('1.863E+332'),\n",
- " 's2': Decimal('5.233E+331'),\n",
- " 's3': Decimal('1.798'),\n",
- " 's4': Decimal('18.47'),\n",
- " 'timestamp': '2018-10-01 15:16:32',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 8},\n",
- " {'s1': Decimal('1.863E+332'),\n",
- " 's2': Decimal('2.386E+332'),\n",
- " 's3': Decimal('2.001'),\n",
- " 's4': Decimal('18.16'),\n",
- " 'timestamp': '2018-10-01 15:16:32',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 8}],\n",
- " [{'s1': Decimal('7.915E+664'),\n",
- " 's2': Decimal('4.445E+664'),\n",
- " 's3': Decimal('2.075'),\n",
- " 's4': Decimal('21.28'),\n",
- " 'timestamp': '2018-10-01 15:16:33',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 9},\n",
- " {'s1': Decimal('1.583E+665'),\n",
- " 's2': Decimal('4.445E+664'),\n",
- " 's3': Decimal('2.300'),\n",
- " 's4': Decimal('15.56'),\n",
- " 'timestamp': '2018-10-01 15:16:33',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 9},\n",
- " {'s1': Decimal('1.583E+665'),\n",
- " 's2': Decimal('2.027E+665'),\n",
- " 's3': Decimal('2.507'),\n",
- " 's4': Decimal('15.58'),\n",
- " 'timestamp': '2018-10-01 15:16:33',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 9}],\n",
- " [{'s1': Decimal('5.713E+1330'),\n",
- " 's2': Decimal('3.208E+1330'),\n",
- " 's3': Decimal('2.604'),\n",
- " 's4': Decimal('16.45'),\n",
- " 'timestamp': '2018-10-01 15:16:34',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 10},\n",
- " {'s1': Decimal('1.142E+1331'),\n",
- " 's2': Decimal('3.208E+1330'),\n",
- " 's3': Decimal('2.858'),\n",
- " 's4': Decimal('15.96'),\n",
- " 'timestamp': '2018-10-01 15:16:34',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 10},\n",
- " {'s1': Decimal('1.142E+1331'),\n",
- " 's2': Decimal('1.462E+1331'),\n",
- " 's3': Decimal('2.912'),\n",
- " 's4': Decimal('17.70'),\n",
- " 'timestamp': '2018-10-01 15:16:34',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 10}],\n",
- " [{'s1': Decimal('2.973E+2662'),\n",
- " 's2': Decimal('1.669E+2662'),\n",
- " 's3': Decimal('2.719'),\n",
- " 's4': Decimal('18.83'),\n",
- " 'timestamp': '2018-10-01 15:16:35',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 11},\n",
- " {'s1': Decimal('5.946E+2662'),\n",
- " 's2': Decimal('1.669E+2662'),\n",
- " 's3': Decimal('2.440'),\n",
- " 's4': Decimal('18.31'),\n",
- " 'timestamp': '2018-10-01 15:16:35',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 11},\n",
- " {'s1': Decimal('5.946E+2662'),\n",
- " 's2': Decimal('7.615E+2662'),\n",
- " 's3': Decimal('2.330'),\n",
- " 's4': Decimal('19.10'),\n",
- " 'timestamp': '2018-10-01 15:16:35',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 11}],\n",
- " [{'s1': Decimal('8.062E+5325'),\n",
- " 's2': Decimal('4.527E+5325'),\n",
- " 's3': Decimal('1.746'),\n",
- " 's4': Decimal('24.47'),\n",
- " 'timestamp': '2018-10-01 15:16:36',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 12},\n",
- " {'s1': Decimal('1.612E+5326'),\n",
- " 's2': Decimal('4.527E+5325'),\n",
- " 's3': Decimal('2.064'),\n",
- " 's4': Decimal('25.08'),\n",
- " 'timestamp': '2018-10-01 15:16:36',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 12},\n",
- " {'s1': Decimal('1.612E+5326'),\n",
- " 's2': Decimal('2.064E+5326'),\n",
- " 's3': Decimal('1.710'),\n",
- " 's4': Decimal('25.83'),\n",
- " 'timestamp': '2018-10-01 15:16:36',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 12}],\n",
- " [{'s1': Decimal('5.925E+10652'),\n",
- " 's2': Decimal('3.327E+10652'),\n",
- " 's3': Decimal('1.696'),\n",
- " 's4': Decimal('24.69'),\n",
- " 'timestamp': '2018-10-01 15:16:37',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 13},\n",
- " {'s1': Decimal('1.185E+10653'),\n",
- " 's2': Decimal('3.327E+10652'),\n",
- " 's3': Decimal('1.472'),\n",
- " 's4': Decimal('25.01'),\n",
- " 'timestamp': '2018-10-01 15:16:37',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 13},\n",
- " {'s1': Decimal('1.185E+10653'),\n",
- " 's2': Decimal('1.517E+10653'),\n",
- " 's3': Decimal('1.173'),\n",
- " 's4': Decimal('21.78'),\n",
- " 'timestamp': '2018-10-01 15:16:37',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 13}],\n",
- " [{'s1': Decimal('3.201E+21306'),\n",
- " 's2': Decimal('1.797E+21306'),\n",
- " 's3': Decimal('1.163'),\n",
- " 's4': Decimal('21.34'),\n",
- " 'timestamp': '2018-10-01 15:16:38',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 14},\n",
- " {'s1': Decimal('6.402E+21306'),\n",
- " 's2': Decimal('1.797E+21306'),\n",
- " 's3': Decimal('1.127'),\n",
- " 's4': Decimal('26.58'),\n",
- " 'timestamp': '2018-10-01 15:16:38',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 14},\n",
- " {'s1': Decimal('6.402E+21306'),\n",
- " 's2': Decimal('8.199E+21306'),\n",
- " 's3': Decimal('1.108'),\n",
- " 's4': Decimal('29.41'),\n",
- " 'timestamp': '2018-10-01 15:16:38',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 14}],\n",
- " [{'s1': Decimal('9.346E+42613'),\n",
- " 's2': Decimal('5.248E+42613'),\n",
- " 's3': Decimal('1.168'),\n",
- " 's4': Decimal('31.29'),\n",
- " 'timestamp': '2018-10-01 15:16:39',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 15},\n",
- " {'s1': Decimal('1.869E+42614'),\n",
- " 's2': Decimal('5.248E+42613'),\n",
- " 's3': Decimal('1.095'),\n",
- " 's4': Decimal('34.74'),\n",
- " 'timestamp': '2018-10-01 15:16:39',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 15},\n",
- " {'s1': Decimal('1.869E+42614'),\n",
- " 's2': Decimal('2.393E+42614'),\n",
- " 's3': Decimal('1.136'),\n",
- " 's4': Decimal('41.27'),\n",
- " 'timestamp': '2018-10-01 15:16:39',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 15}],\n",
- " [{'s1': Decimal('7.965E+85228'),\n",
- " 's2': Decimal('4.472E+85228'),\n",
- " 's3': Decimal('1.194'),\n",
- " 's4': Decimal('43.71'),\n",
- " 'timestamp': '2018-10-01 15:16:40',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 16},\n",
- " {'s1': Decimal('1.593E+85229'),\n",
- " 's2': Decimal('4.472E+85228'),\n",
- " 's3': Decimal('1.154'),\n",
- " 's4': Decimal('52.76'),\n",
- " 'timestamp': '2018-10-01 15:16:40',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 16},\n",
- " {'s1': Decimal('1.593E+85229'),\n",
- " 's2': Decimal('2.040E+85229'),\n",
- " 's3': Decimal('1.121'),\n",
- " 's4': Decimal('58.40'),\n",
- " 'timestamp': '2018-10-01 15:16:40',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 16}],\n",
- " [{'s1': Decimal('5.786E+170458'),\n",
- " 's2': Decimal('3.249E+170458'),\n",
- " 's3': Decimal('1.181'),\n",
- " 's4': Decimal('59.37'),\n",
- " 'timestamp': '2018-10-01 15:16:41',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 17},\n",
- " {'s1': Decimal('1.157E+170459'),\n",
- " 's2': Decimal('3.249E+170458'),\n",
- " 's3': Decimal('1.187'),\n",
- " 's4': Decimal('69.57'),\n",
- " 'timestamp': '2018-10-01 15:16:41',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 17},\n",
- " {'s1': Decimal('1.157E+170459'),\n",
- " 's2': Decimal('1.481E+170459'),\n",
- " 's3': Decimal('1.205'),\n",
- " 's4': Decimal('53.15'),\n",
- " 'timestamp': '2018-10-01 15:16:41',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 17}],\n",
- " [{'s1': Decimal('3.051E+340918'),\n",
- " 's2': Decimal('1.713E+340918'),\n",
- " 's3': Decimal('0.9188'),\n",
- " 's4': Decimal('50.11'),\n",
- " 'timestamp': '2018-10-01 15:16:42',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 18},\n",
- " {'s1': Decimal('6.102E+340918'),\n",
- " 's2': Decimal('1.713E+340918'),\n",
- " 's3': Decimal('0.9241'),\n",
- " 's4': Decimal('51.44'),\n",
- " 'timestamp': '2018-10-01 15:16:42',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 18},\n",
- " {'s1': Decimal('6.102E+340918'),\n",
- " 's2': Decimal('7.815E+340918'),\n",
- " 's3': Decimal('0.9588'),\n",
- " 's4': Decimal('46.74'),\n",
- " 'timestamp': '2018-10-01 15:16:42',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 18}],\n",
- " [{'s1': Decimal('8.491E+681837'),\n",
- " 's2': Decimal('4.768E+681837'),\n",
- " 's3': Decimal('0.9458'),\n",
- " 's4': Decimal('46.01'),\n",
- " 'timestamp': '2018-10-01 15:16:43',\n",
- " 'mech_step': 1,\n",
- " 'time_step': 19},\n",
- " {'s1': Decimal('1.698E+681838'),\n",
- " 's2': Decimal('4.768E+681837'),\n",
- " 's3': Decimal('0.9775'),\n",
- " 's4': Decimal('43.07'),\n",
- " 'timestamp': '2018-10-01 15:16:43',\n",
- " 'mech_step': 2,\n",
- " 'time_step': 19},\n",
- " {'s1': Decimal('1.698E+681838'),\n",
- " 's2': Decimal('2.174E+681838'),\n",
- " 's3': Decimal('1.163'),\n",
- " 's4': Decimal('40.25'),\n",
- " 'timestamp': '2018-10-01 15:16:43',\n",
- " 'mech_step': 3,\n",
- " 'time_step': 19}])"
+ "\"[{'s1': Decimal('2'), 's2': Decimal('4'), 's3': Decimal('0'), 's4': Decimal('0'), 'timestamp': '2018-10-01 15:16:24', 'mech_step': 0, 'time_step': 0}, {'s1': Decimal('12'), 's2': Decimal('15'), 's3': Decimal('1.027943375654487123682656602'), 's4': Decimal('2.873162181767157652423350100'), 'timestamp': '2018-10-01 15:16:25', 'mech_step': 1, 'time_step': 1}, {'s1': Decimal('24.8'), 's2': Decimal('15'), 's3': Decimal('1.658405192679980226295085390'), 's4': Decimal('5.350515951995874829597979645'), 'timestamp': '2018-10-01 15:16:25', 'mech_step': 2, 'time_step': 1}, {'s1': Decimal('24.8'), 's2': Decimal('513.8'), 's3': Decimal('2.771923735333028371712141099'), 's4': Decimal('7.030344993582647198055332758'), 'timestamp': '2018-10-01 15:16:25', 'mech_step': 3, 'time_step': 1}, {'s1': Decimal('12791.84'), 's2': Decimal('13281.84'), 's3': Decimal('2.884737635508387705829249992'), 's4': Decimal('6.383750387315317896150130866'), 'timestamp': '2018-10-01 15:16:26', 'mech_step': 1, 'time_step': 2}, {'s1': Decimal('25584.64310752124705613077706'), 's2': Decimal('13281.84'), 's3': Decimal('2.641176859741037975691526862'), 's4': Decimal('7.563409402906505259061057559'), 'timestamp': '2018-10-01 15:16:26', 'mech_step': 2, 'time_step': 2}, {'s1': Decimal('25584.64310752124705613077706'), 's2': Decimal('39578.28310752124705613077706'), 's3': Decimal('2.493318466952763629633252152'), 's4': Decimal('5.891297175440944153224023488'), 'timestamp': '2018-10-01 15:16:26', 'mech_step': 3, 'time_step': 2}, {'s1': Decimal('1012647417.400583119401298502'), 's2': Decimal('1012661412.040583119401298502'), 's3': Decimal('2.343589605293861443271839926'), 's4': Decimal('5.974841965491865064823816188'), 'timestamp': '2018-10-01 15:16:27', 'mech_step': 1, 'time_step': 3}, {'s1': Decimal('2025294835.801152419139051417'), 's2': Decimal('1012661412.040583119401298502'), 's3': Decimal('2.722049618518731799375577601'), 's4': Decimal('6.419153303484813228317291423'), 'timestamp': '2018-10-01 15:16:27', 'mech_step': 2, 'time_step': 3}, {'s1': Decimal('2025294835.801152419139051417'), 's2': Decimal('3037996532.124843059787406050'), 's3': Decimal('2.829557844805450150205458129'), 's4': Decimal('6.506538668695062046307737283'), 'timestamp': '2018-10-01 15:16:27', 'mech_step': 3, 'time_step': 3}, {'s1': Decimal('6152838691744844166.823201459'), 's2': Decimal('6152838692757545864.146892100'), 's3': Decimal('2.488931860190471537369309149'), 's4': Decimal('6.300408321924320755651096195'), 'timestamp': '2018-10-01 15:16:28', 'mech_step': 1, 'time_step': 4}, {'s1': Decimal('12305677383489688334.64640292'), 's2': Decimal('6152838692757545864.146892100'), 's3': Decimal('2.178444472215797343328528750'), 's4': Decimal('6.784326268377325448300165109'), 'timestamp': '2018-10-01 15:16:28', 'mech_step': 2, 'time_step': 4}, {'s1': Decimal('12305677383489688334.64640292'), 's2': Decimal('18458516079285231057.91813808'), 's3': Decimal('2.161551452331358618745550185'), 's4': Decimal('6.035792378762528032341888172'), 'timestamp': '2018-10-01 15:16:28', 'mech_step': 3, 'time_step': 4}, {'s1': Decimal('2.271445438496410226588727850E+38'), 's2': Decimal('2.271445438496410226650256237E+38'), 's3': Decimal('2.158667996440737307324876748'), 's4': Decimal('6.371107803673317814010318446'), 'timestamp': '2018-10-01 15:16:29', 'mech_step': 1, 'time_step': 5}, {'s1': Decimal('4.542890876992820453177455700E+38'), 's2': Decimal('2.271445438496410226650256237E+38'), 's3': Decimal('1.992812515458891464887812476'), 's4': Decimal('7.282620522632285439020785561'), 'timestamp': '2018-10-01 15:16:29', 'mech_step': 2, 'time_step': 5}, {'s1': Decimal('4.542890876992820453177455700E+38'), 's2': Decimal('6.814336315489230680012297098E+38'), 's3': Decimal('2.050849993464547990799409445'), 's4': Decimal('6.524227074744597056029341316'), 'timestamp': '2018-10-01 15:16:29', 'mech_step': 3, 'time_step': 5}, {'s1': Decimal('3.095678628039689600133475180E+77'), 's2': Decimal('3.095678628039689600133475180E+77'), 's3': Decimal('2.010380376097353148038039474'), 's4': Decimal('5.989349144044895224884420424'), 'timestamp': '2018-10-01 15:16:30', 'mech_step': 1, 'time_step': 6}, {'s1': Decimal('6.191357256079379200266950360E+77'), 's2': Decimal('3.095678628039689600133475180E+77'), 's3': Decimal('2.226864095678880891887671486'), 's4': Decimal('6.070768581048944995923972497'), 'timestamp': '2018-10-01 15:16:30', 'mech_step': 2, 'time_step': 6}, {'s1': Decimal('6.191357256079379200266950360E+77'), 's2': Decimal('9.287035884119068800400425540E+77'), 's3': Decimal('2.324269409720218352898828188'), 's4': Decimal('6.671515324796301588344886525'), 'timestamp': '2018-10-01 15:16:30', 'mech_step': 3, 'time_step': 6}, {'s1': Decimal('5.749935700861016926665423233E+155'), 's2': Decimal('5.749935700861016926665423233E+155'), 's3': Decimal('2.302607714744926584899159503'), 's4': Decimal('7.564930163192297989174091445'), 'timestamp': '2018-10-01 15:16:31', 'mech_step': 1, 'time_step': 7}, {'s1': Decimal('1.149987140172203385333084647E+156'), 's2': Decimal('5.749935700861016926665423233E+155'), 's3': Decimal('2.333838309242175687275651869'), 's4': Decimal('8.079819700247225677794342322'), 'timestamp': '2018-10-01 15:16:31', 'mech_step': 2, 'time_step': 7}, {'s1': Decimal('1.149987140172203385333084647E+156'), 's2': Decimal('1.724980710258305077999626970E+156'), 's3': Decimal('2.127828342872591238967325177'), 's4': Decimal('7.538873530077748135396698368'), 'timestamp': '2018-10-01 15:16:31', 'mech_step': 3, 'time_step': 7}, {'s1': Decimal('1.983705633842164435837016890E+312'), 's2': Decimal('1.983705633842164435837016890E+312'), 's3': Decimal('2.316086720133955499001671373'), 's4': Decimal('6.698731880418827259665498103'), 'timestamp': '2018-10-01 15:16:32', 'mech_step': 1, 'time_step': 8}, {'s1': Decimal('3.967411267684328871674033780E+312'), 's2': Decimal('1.983705633842164435837016890E+312'), 's3': Decimal('2.404840197025546934576512657'), 's4': Decimal('6.861496713777041844809717113'), 'timestamp': '2018-10-01 15:16:32', 'mech_step': 2, 'time_step': 8}, {'s1': Decimal('3.967411267684328871674033780E+312'), 's2': Decimal('5.951116901526493307511050670E+312'), 's3': Decimal('2.304559767911563562114836868'), 's4': Decimal('7.134761053609609291468324912'), 'timestamp': '2018-10-01 15:16:32', 'mech_step': 3, 'time_step': 8}, {'s1': Decimal('2.361052825042286016164133532E+625'), 's2': Decimal('2.361052825042286016164133532E+625'), 's3': Decimal('2.331706686848056480258922690'), 's4': Decimal('6.349543276872486350505972604'), 'timestamp': '2018-10-01 15:16:33', 'mech_step': 1, 'time_step': 9}, {'s1': Decimal('4.722105650084572032328267064E+625'), 's2': Decimal('2.361052825042286016164133532E+625'), 's3': Decimal('2.206567414513102300934412097'), 's4': Decimal('6.387507504315002156007687646'), 'timestamp': '2018-10-01 15:16:33', 'mech_step': 2, 'time_step': 9}, {'s1': Decimal('4.722105650084572032328267064E+625'), 's2': Decimal('7.083158475126858048492400596E+625'), 's3': Decimal('2.755381458293744817475387505'), 's4': Decimal('6.599724434632028086026631189'), 'timestamp': '2018-10-01 15:16:33', 'mech_step': 3, 'time_step': 9}, {'s1': Decimal('3.344742265584095796507860632E+1251'), 's2': Decimal('3.344742265584095796507860632E+1251'), 's3': Decimal('2.631014270278374984244193109'), 's4': Decimal('7.289437871820951073267599940'), 'timestamp': '2018-10-01 15:16:34', 'mech_step': 1, 'time_step': 10}, {'s1': Decimal('6.689484531168191593015721264E+1251'), 's2': Decimal('3.344742265584095796507860632E+1251'), 's3': Decimal('2.767520795662379664467196631'), 's4': Decimal('6.567373343213126668766057155'), 'timestamp': '2018-10-01 15:16:34', 'mech_step': 2, 'time_step': 10}, {'s1': Decimal('6.689484531168191593015721264E+1251'), 's2': Decimal('1.003422679675228738952358190E+1252'), 's3': Decimal('2.868382538980392112200644477'), 's4': Decimal('6.933152742813279229430635728'), 'timestamp': '2018-10-01 15:16:34', 'mech_step': 3, 'time_step': 10}]\""
]
},
- "execution_count": 19,
+ "execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "configs = generate_config(mechanisms, exogenous_states)\n",
- "\n",
- "pipeline(states_list, configs, env_processes, range(19))\n",
- "# a = block_gen(states_list, configs, env_processes, 1)\n",
- "# b = block_gen(a, configs, env_processes, 2)"
+ "flatten(pipeline(states_list, configs, env_processes, range(10)))"
]
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 75,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " mech_step | \n",
+ " s1 | \n",
+ " s2 | \n",
+ " s3 | \n",
+ " s4 | \n",
+ " time_step | \n",
+ " timestamp | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 0 | \n",
+ " 2 | \n",
+ " 4 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 2018-10-01 15:16:24 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 1 | \n",
+ " 12 | \n",
+ " 15 | \n",
+ " 0.9134790035783337813768412161 | \n",
+ " 2.502245379381494383430606376 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:25 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 2 | \n",
+ " 24.8 | \n",
+ " 15 | \n",
+ " 2.248685730584553218869219712 | \n",
+ " 5.512870077468841289396533774 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:25 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 3 | \n",
+ " 24.8 | \n",
+ " 548.8 | \n",
+ " 3.431275232953615539312717484 | \n",
+ " 9.152222843429326282106045717 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:25 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 1 | \n",
+ " 13659.84 | \n",
+ " 14184.84 | \n",
+ " 3.322814672054344544572535039 | \n",
+ " 7.708815382252544561603904880 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 2 | \n",
+ " 27320.64298865549417547184177 | \n",
+ " 14184.84 | \n",
+ " 2.897641633315681179441300144 | \n",
+ " 7.871440379399112665270434205 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 3 | \n",
+ " 27320.64298865549417547184177 | \n",
+ " 43033.28298865549417547184177 | \n",
+ " 3.109937351467413775751721194 | \n",
+ " 8.630776907929052893315997214 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 1 | \n",
+ " 1175751602.448815787831625727 | \n",
+ " 1175767316.088815787831625727 | \n",
+ " 3.176228364900735157136598597 | \n",
+ " 9.476875554027664732983490933 | \n",
+ " 3 | \n",
+ " 2018-10-01 15:16:27 | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 2 | \n",
+ " 2351503205.897618211080153268 | \n",
+ " 1175767316.088815787831625727 | \n",
+ " 3.669342085393265738584747393 | \n",
+ " 9.078969322902328500177642109 | \n",
+ " 3 | \n",
+ " 2018-10-01 15:16:27 | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 3 | \n",
+ " 2351503205.897618211080153268 | \n",
+ " 3527313580.269422654405954467 | \n",
+ " 3.349759960987064464357988348 | \n",
+ " 11.17144391140400526366105626 | \n",
+ " 3 | \n",
+ " 2018-10-01 15:16:27 | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 1 | \n",
+ " 8294489196912759452.970615494 | \n",
+ " 8294489198088569828.342419937 | \n",
+ " 3.291621062675780626360283198 | \n",
+ " 11.79158573801193721089527021 | \n",
+ " 4 | \n",
+ " 2018-10-01 15:16:28 | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " 2 | \n",
+ " 16588978393825518906.94123099 | \n",
+ " 8294489198088569828.342419937 | \n",
+ " 3.190260401352364227902370309 | \n",
+ " 10.83521005284223728823800392 | \n",
+ " 4 | \n",
+ " 2018-10-01 15:16:28 | \n",
+ "
\n",
+ " \n",
+ " | 12 | \n",
+ " 3 | \n",
+ " 16588978393825518906.94123099 | \n",
+ " 24883467595441402812.55307358 | \n",
+ " 3.121085581653047084982738199 | \n",
+ " 11.90171862969807780698158412 | \n",
+ " 4 | \n",
+ " 2018-10-01 15:16:28 | \n",
+ "
\n",
+ " \n",
+ " | 13 | \n",
+ " 1 | \n",
+ " 4.127913063042348695585266519E+38 | \n",
+ " 4.127913063042348695668211411E+38 | \n",
+ " 3.451182382495768883556480363 | \n",
+ " 10.56564601562031452828101181 | \n",
+ " 5 | \n",
+ " 2018-10-01 15:16:29 | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 2 | \n",
+ " 8.255826126084697391170533038E+38 | \n",
+ " 4.127913063042348695668211411E+38 | \n",
+ " 3.741899406797318610377156551 | \n",
+ " 11.51155602900725002724979131 | \n",
+ " 5 | \n",
+ " 2018-10-01 15:16:29 | \n",
+ "
\n",
+ " \n",
+ " | 15 | \n",
+ " 3 | \n",
+ " 8.255826126084697391170533038E+38 | \n",
+ " 1.238373918912704608708757912E+39 | \n",
+ " 3.502261092993842545620034035 | \n",
+ " 10.05873509959087676986164634 | \n",
+ " 5 | \n",
+ " 2018-10-01 15:16:29 | \n",
+ "
\n",
+ " \n",
+ " | 16 | \n",
+ " 1 | \n",
+ " 1.022379975362139926212390600E+78 | \n",
+ " 1.022379975362139926212390600E+78 | \n",
+ " 3.469927066535463898981122193 | \n",
+ " 10.85392093270310114268283059 | \n",
+ " 6 | \n",
+ " 2018-10-01 15:16:30 | \n",
+ "
\n",
+ " \n",
+ " | 17 | \n",
+ " 2 | \n",
+ " 2.044759950724279852424781200E+78 | \n",
+ " 1.022379975362139926212390600E+78 | \n",
+ " 3.389836636120093053817568517 | \n",
+ " 10.22052760419210320393222941 | \n",
+ " 6 | \n",
+ " 2018-10-01 15:16:30 | \n",
+ "
\n",
+ " \n",
+ " | 18 | \n",
+ " 3 | \n",
+ " 2.044759950724279852424781200E+78 | \n",
+ " 3.067139926086419778637171800E+78 | \n",
+ " 3.691234576837118749676110598 | \n",
+ " 11.37778574423056181482523150 | \n",
+ " 6 | \n",
+ " 2018-10-01 15:16:30 | \n",
+ "
\n",
+ " \n",
+ " | 19 | \n",
+ " 1 | \n",
+ " 6.271564884128939055277180913E+156 | \n",
+ " 6.271564884128939055277180913E+156 | \n",
+ " 3.626178019358236806863551566 | \n",
+ " 12.22051263705128606140551412 | \n",
+ " 7 | \n",
+ " 2018-10-01 15:16:31 | \n",
+ "
\n",
+ " \n",
+ " | 20 | \n",
+ " 2 | \n",
+ " 1.254312976825787811055436183E+157 | \n",
+ " 6.271564884128939055277180913E+156 | \n",
+ " 3.220785150433332555990604134 | \n",
+ " 12.76702364001153681852439011 | \n",
+ " 7 | \n",
+ " 2018-10-01 15:16:31 | \n",
+ "
\n",
+ " \n",
+ " | 21 | \n",
+ " 3 | \n",
+ " 1.254312976825787811055436183E+157 | \n",
+ " 1.881469465238681716583154274E+157 | \n",
+ " 3.109568780275700333829257981 | \n",
+ " 12.84187980705835257162799234 | \n",
+ " 7 | \n",
+ " 2018-10-01 15:16:31 | \n",
+ "
\n",
+ " \n",
+ " | 22 | \n",
+ " 1 | \n",
+ " 2.359951565750353965511297842E+314 | \n",
+ " 2.359951565750353965511297842E+314 | \n",
+ " 3.094712150387259242879567261 | \n",
+ " 14.23781301925247300696747254 | \n",
+ " 8 | \n",
+ " 2018-10-01 15:16:32 | \n",
+ "
\n",
+ " \n",
+ " | 23 | \n",
+ " 2 | \n",
+ " 4.719903131500707931022595684E+314 | \n",
+ " 2.359951565750353965511297842E+314 | \n",
+ " 3.378565486073127515381700473 | \n",
+ " 11.67024852265485110882840117 | \n",
+ " 8 | \n",
+ " 2018-10-01 15:16:32 | \n",
+ "
\n",
+ " \n",
+ " | 24 | \n",
+ " 3 | \n",
+ " 4.719903131500707931022595684E+314 | \n",
+ " 7.079854697251061896533893526E+314 | \n",
+ " 3.809611959404135920760842724 | \n",
+ " 12.17505018426059517257186215 | \n",
+ " 8 | \n",
+ " 2018-10-01 15:16:32 | \n",
+ "
\n",
+ " \n",
+ " | 25 | \n",
+ " 1 | \n",
+ " 3.341622835612528353592630685E+629 | \n",
+ " 3.341622835612528353592630685E+629 | \n",
+ " 4.301344465829686078698769231 | \n",
+ " 12.67840657289609612005491378 | \n",
+ " 9 | \n",
+ " 2018-10-01 15:16:33 | \n",
+ "
\n",
+ " \n",
+ " | 26 | \n",
+ " 2 | \n",
+ " 6.683245671225056707185261370E+629 | \n",
+ " 3.341622835612528353592630685E+629 | \n",
+ " 4.457960124936451008116824228 | \n",
+ " 13.39112306206467797206188957 | \n",
+ " 9 | \n",
+ " 2018-10-01 15:16:33 | \n",
+ "
\n",
+ " \n",
+ " | 27 | \n",
+ " 3 | \n",
+ " 6.683245671225056707185261370E+629 | \n",
+ " 1.002486850683758506077789206E+630 | \n",
+ " 4.227067068495197251330279996 | \n",
+ " 14.49753624543580349429923643 | \n",
+ " 9 | \n",
+ " 2018-10-01 15:16:33 | \n",
+ "
\n",
+ " \n",
+ " | 28 | \n",
+ " 1 | \n",
+ " 6.699865905292268815365221375E+1259 | \n",
+ " 6.699865905292268815365221375E+1259 | \n",
+ " 4.472780660763391823717436106 | \n",
+ " 14.66684234187518294415503523 | \n",
+ " 10 | \n",
+ " 2018-10-01 15:16:34 | \n",
+ "
\n",
+ " \n",
+ " | 29 | \n",
+ " 2 | \n",
+ " 1.339973181058453763073044275E+1260 | \n",
+ " 6.699865905292268815365221375E+1259 | \n",
+ " 4.387384290717904567103987857 | \n",
+ " 15.84678912512812579758546608 | \n",
+ " 10 | \n",
+ " 2018-10-01 15:16:34 | \n",
+ "
\n",
+ " \n",
+ " | 30 | \n",
+ " 3 | \n",
+ " 1.339973181058453763073044275E+1260 | \n",
+ " 2.009959771587680644609566412E+1260 | \n",
+ " 4.113061544409890922044795202 | \n",
+ " 16.08824426908686380482178405 | \n",
+ " 10 | \n",
+ " 2018-10-01 15:16:34 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " mech_step s1 \\\n",
+ "0 0 2 \n",
+ "1 1 12 \n",
+ "2 2 24.8 \n",
+ "3 3 24.8 \n",
+ "4 1 13659.84 \n",
+ "5 2 27320.64298865549417547184177 \n",
+ "6 3 27320.64298865549417547184177 \n",
+ "7 1 1175751602.448815787831625727 \n",
+ "8 2 2351503205.897618211080153268 \n",
+ "9 3 2351503205.897618211080153268 \n",
+ "10 1 8294489196912759452.970615494 \n",
+ "11 2 16588978393825518906.94123099 \n",
+ "12 3 16588978393825518906.94123099 \n",
+ "13 1 4.127913063042348695585266519E+38 \n",
+ "14 2 8.255826126084697391170533038E+38 \n",
+ "15 3 8.255826126084697391170533038E+38 \n",
+ "16 1 1.022379975362139926212390600E+78 \n",
+ "17 2 2.044759950724279852424781200E+78 \n",
+ "18 3 2.044759950724279852424781200E+78 \n",
+ "19 1 6.271564884128939055277180913E+156 \n",
+ "20 2 1.254312976825787811055436183E+157 \n",
+ "21 3 1.254312976825787811055436183E+157 \n",
+ "22 1 2.359951565750353965511297842E+314 \n",
+ "23 2 4.719903131500707931022595684E+314 \n",
+ "24 3 4.719903131500707931022595684E+314 \n",
+ "25 1 3.341622835612528353592630685E+629 \n",
+ "26 2 6.683245671225056707185261370E+629 \n",
+ "27 3 6.683245671225056707185261370E+629 \n",
+ "28 1 6.699865905292268815365221375E+1259 \n",
+ "29 2 1.339973181058453763073044275E+1260 \n",
+ "30 3 1.339973181058453763073044275E+1260 \n",
+ "\n",
+ " s2 s3 \\\n",
+ "0 4 0 \n",
+ "1 15 0.9134790035783337813768412161 \n",
+ "2 15 2.248685730584553218869219712 \n",
+ "3 548.8 3.431275232953615539312717484 \n",
+ "4 14184.84 3.322814672054344544572535039 \n",
+ "5 14184.84 2.897641633315681179441300144 \n",
+ "6 43033.28298865549417547184177 3.109937351467413775751721194 \n",
+ "7 1175767316.088815787831625727 3.176228364900735157136598597 \n",
+ "8 1175767316.088815787831625727 3.669342085393265738584747393 \n",
+ "9 3527313580.269422654405954467 3.349759960987064464357988348 \n",
+ "10 8294489198088569828.342419937 3.291621062675780626360283198 \n",
+ "11 8294489198088569828.342419937 3.190260401352364227902370309 \n",
+ "12 24883467595441402812.55307358 3.121085581653047084982738199 \n",
+ "13 4.127913063042348695668211411E+38 3.451182382495768883556480363 \n",
+ "14 4.127913063042348695668211411E+38 3.741899406797318610377156551 \n",
+ "15 1.238373918912704608708757912E+39 3.502261092993842545620034035 \n",
+ "16 1.022379975362139926212390600E+78 3.469927066535463898981122193 \n",
+ "17 1.022379975362139926212390600E+78 3.389836636120093053817568517 \n",
+ "18 3.067139926086419778637171800E+78 3.691234576837118749676110598 \n",
+ "19 6.271564884128939055277180913E+156 3.626178019358236806863551566 \n",
+ "20 6.271564884128939055277180913E+156 3.220785150433332555990604134 \n",
+ "21 1.881469465238681716583154274E+157 3.109568780275700333829257981 \n",
+ "22 2.359951565750353965511297842E+314 3.094712150387259242879567261 \n",
+ "23 2.359951565750353965511297842E+314 3.378565486073127515381700473 \n",
+ "24 7.079854697251061896533893526E+314 3.809611959404135920760842724 \n",
+ "25 3.341622835612528353592630685E+629 4.301344465829686078698769231 \n",
+ "26 3.341622835612528353592630685E+629 4.457960124936451008116824228 \n",
+ "27 1.002486850683758506077789206E+630 4.227067068495197251330279996 \n",
+ "28 6.699865905292268815365221375E+1259 4.472780660763391823717436106 \n",
+ "29 6.699865905292268815365221375E+1259 4.387384290717904567103987857 \n",
+ "30 2.009959771587680644609566412E+1260 4.113061544409890922044795202 \n",
+ "\n",
+ " s4 time_step timestamp \n",
+ "0 0 0 2018-10-01 15:16:24 \n",
+ "1 2.502245379381494383430606376 1 2018-10-01 15:16:25 \n",
+ "2 5.512870077468841289396533774 1 2018-10-01 15:16:25 \n",
+ "3 9.152222843429326282106045717 1 2018-10-01 15:16:25 \n",
+ "4 7.708815382252544561603904880 2 2018-10-01 15:16:26 \n",
+ "5 7.871440379399112665270434205 2 2018-10-01 15:16:26 \n",
+ "6 8.630776907929052893315997214 2 2018-10-01 15:16:26 \n",
+ "7 9.476875554027664732983490933 3 2018-10-01 15:16:27 \n",
+ "8 9.078969322902328500177642109 3 2018-10-01 15:16:27 \n",
+ "9 11.17144391140400526366105626 3 2018-10-01 15:16:27 \n",
+ "10 11.79158573801193721089527021 4 2018-10-01 15:16:28 \n",
+ "11 10.83521005284223728823800392 4 2018-10-01 15:16:28 \n",
+ "12 11.90171862969807780698158412 4 2018-10-01 15:16:28 \n",
+ "13 10.56564601562031452828101181 5 2018-10-01 15:16:29 \n",
+ "14 11.51155602900725002724979131 5 2018-10-01 15:16:29 \n",
+ "15 10.05873509959087676986164634 5 2018-10-01 15:16:29 \n",
+ "16 10.85392093270310114268283059 6 2018-10-01 15:16:30 \n",
+ "17 10.22052760419210320393222941 6 2018-10-01 15:16:30 \n",
+ "18 11.37778574423056181482523150 6 2018-10-01 15:16:30 \n",
+ "19 12.22051263705128606140551412 7 2018-10-01 15:16:31 \n",
+ "20 12.76702364001153681852439011 7 2018-10-01 15:16:31 \n",
+ "21 12.84187980705835257162799234 7 2018-10-01 15:16:31 \n",
+ "22 14.23781301925247300696747254 8 2018-10-01 15:16:32 \n",
+ "23 11.67024852265485110882840117 8 2018-10-01 15:16:32 \n",
+ "24 12.17505018426059517257186215 8 2018-10-01 15:16:32 \n",
+ "25 12.67840657289609612005491378 9 2018-10-01 15:16:33 \n",
+ "26 13.39112306206467797206188957 9 2018-10-01 15:16:33 \n",
+ "27 14.49753624543580349429923643 9 2018-10-01 15:16:33 \n",
+ "28 14.66684234187518294415503523 10 2018-10-01 15:16:34 \n",
+ "29 15.84678912512812579758546608 10 2018-10-01 15:16:34 \n",
+ "30 16.08824426908686380482178405 10 2018-10-01 15:16:34 "
+ ]
+ },
+ "execution_count": 75,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "states_list = [state_dict]\n",
+ "configs = generate_config(mechanisms, exogenous_states)\n",
+ "# type(pipeline(states_list, configs, env_processes, range(10)))\n",
+ "pd.DataFrame(flatten(pipeline(states_list, configs, env_processes, range(10))))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0\n",
+ "1\n",
+ "2\n",
+ "3\n",
+ "4\n"
+ ]
+ }
+ ],
+ "source": [
+ "for x in list(range(5)):\n",
+ " print(x)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 61,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def simulation(states_list, configs, env_processes, time_seq, runs):\n",
+ " pipeline_run = []\n",
+ " for run in range(runs):\n",
+ " if run == 0:\n",
+ " pipeline_run += pipeline(states_list, configs, env_processes, time_seq)\n",
+ "# pipeline_run += [run]\n",
+ " else:\n",
+ " pipeline_run += pipeline(pipeline_run[-1], configs, env_processes, time_seq)\n",
+ "# pipeline_run += [run]\n",
+ " return pipeline_run"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 79,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "999999999999999995000000000000000009999999999999999990000000000000000004999999999999999999"
+ "[0, 1]"
]
},
- "execution_count": 11,
+ "execution_count": 79,
"metadata": {},
"output_type": "execute_result"
}
],
+ "source": [
+ "list(range(2))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 77,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " mech_step | \n",
+ " s1 | \n",
+ " s2 | \n",
+ " s3 | \n",
+ " s4 | \n",
+ " time_step | \n",
+ " timestamp | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 0 | \n",
+ " 2 | \n",
+ " 4 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 2018-10-01 15:16:24 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 1 | \n",
+ " 12 | \n",
+ " 15 | \n",
+ " 0.9613374219112287288879770131 | \n",
+ " 3.052627916233361826670034134 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:25 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 2 | \n",
+ " 24.8 | \n",
+ " 15 | \n",
+ " 1.787841886705475247843978831 | \n",
+ " 6.142108075626036207691665842 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:25 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 3 | \n",
+ " 24.8 | \n",
+ " 463.8 | \n",
+ " 2.660351416005110429442387343 | \n",
+ " 9.305727043596993943746695376 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:25 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 1 | \n",
+ " 11551.84 | \n",
+ " 11991.84 | \n",
+ " 2.464645185343364655440715846 | \n",
+ " 9.337777284373435717315011919 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 2 | \n",
+ " 23104.64330838303379631482742 | \n",
+ " 11991.84 | \n",
+ " 2.304639148261938062624317980 | \n",
+ " 10.29602467538929243745549665 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 0 | \n",
+ " 23104.64330838303379631482742 | \n",
+ " 36429.28330838303379631482742 | \n",
+ " 1.745014350171677143026393926 | \n",
+ " 10.79831922713935264930519165 | \n",
+ " 0 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 1 | \n",
+ " 11551.84 | \n",
+ " 11991.84 | \n",
+ " 2.464645185343364655440715846 | \n",
+ " 9.337777284373435717315011919 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 2 | \n",
+ " 23104.64330838303379631482742 | \n",
+ " 11991.84 | \n",
+ " 2.304639148261938062624317980 | \n",
+ " 10.29602467538929243745549665 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 0 | \n",
+ " 23104.64330838303379631482742 | \n",
+ " 36429.28330838303379631482742 | \n",
+ " 1.745014350171677143026393926 | \n",
+ " 10.79831922713935264930519165 | \n",
+ " 0 | \n",
+ " 2018-10-01 15:16:26 | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 1 | \n",
+ " 841731806.1068385748529941713 | \n",
+ " 841745131.7468385748529941713 | \n",
+ " 2.674433177140856389019169996 | \n",
+ " 13.00062365694861937452715049 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:27 | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " 2 | \n",
+ " 1683463613.213661318738279214 | \n",
+ " 841745131.7468385748529941713 | \n",
+ " 3.624101417571331809767198673 | \n",
+ " 16.20642375313349247996903985 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:27 | \n",
+ "
\n",
+ " \n",
+ " | 12 | \n",
+ " 3 | \n",
+ " 1683463613.213661318738279214 | \n",
+ " 2525245934.243808276625069700 | \n",
+ " 5.624045968105207479594054397 | \n",
+ " 19.06052285670926327575992631 | \n",
+ " 1 | \n",
+ " 2018-10-01 15:16:27 | \n",
+ "
\n",
+ " \n",
+ " | 13 | \n",
+ " 1 | \n",
+ " 4251159648082116507.122875915 | \n",
+ " 4251159648923898829.153022873 | \n",
+ " 5.993855811997401802623453850 | \n",
+ " 19.98482856457245487734288629 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:28 | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 2 | \n",
+ " 8502319296164233015.245751830 | \n",
+ " 4251159648923898829.153022873 | \n",
+ " 5.897796745026735991647259941 | \n",
+ " 20.34518830015981490111740668 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:28 | \n",
+ "
\n",
+ " \n",
+ " | 15 | \n",
+ " 3 | \n",
+ " 8502319296164233015.245751830 | \n",
+ " 12753478947613377799.64258298 | \n",
+ " 5.929070686768885727909284389 | \n",
+ " 21.18865492248121317164619034 | \n",
+ " 2 | \n",
+ " 2018-10-01 15:16:28 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " mech_step s1 s2 \\\n",
+ "0 0 2 4 \n",
+ "1 1 12 15 \n",
+ "2 2 24.8 15 \n",
+ "3 3 24.8 463.8 \n",
+ "4 1 11551.84 11991.84 \n",
+ "5 2 23104.64330838303379631482742 11991.84 \n",
+ "6 0 23104.64330838303379631482742 36429.28330838303379631482742 \n",
+ "7 1 11551.84 11991.84 \n",
+ "8 2 23104.64330838303379631482742 11991.84 \n",
+ "9 0 23104.64330838303379631482742 36429.28330838303379631482742 \n",
+ "10 1 841731806.1068385748529941713 841745131.7468385748529941713 \n",
+ "11 2 1683463613.213661318738279214 841745131.7468385748529941713 \n",
+ "12 3 1683463613.213661318738279214 2525245934.243808276625069700 \n",
+ "13 1 4251159648082116507.122875915 4251159648923898829.153022873 \n",
+ "14 2 8502319296164233015.245751830 4251159648923898829.153022873 \n",
+ "15 3 8502319296164233015.245751830 12753478947613377799.64258298 \n",
+ "\n",
+ " s3 s4 time_step \\\n",
+ "0 0 0 0 \n",
+ "1 0.9613374219112287288879770131 3.052627916233361826670034134 1 \n",
+ "2 1.787841886705475247843978831 6.142108075626036207691665842 1 \n",
+ "3 2.660351416005110429442387343 9.305727043596993943746695376 1 \n",
+ "4 2.464645185343364655440715846 9.337777284373435717315011919 2 \n",
+ "5 2.304639148261938062624317980 10.29602467538929243745549665 2 \n",
+ "6 1.745014350171677143026393926 10.79831922713935264930519165 0 \n",
+ "7 2.464645185343364655440715846 9.337777284373435717315011919 2 \n",
+ "8 2.304639148261938062624317980 10.29602467538929243745549665 2 \n",
+ "9 1.745014350171677143026393926 10.79831922713935264930519165 0 \n",
+ "10 2.674433177140856389019169996 13.00062365694861937452715049 1 \n",
+ "11 3.624101417571331809767198673 16.20642375313349247996903985 1 \n",
+ "12 5.624045968105207479594054397 19.06052285670926327575992631 1 \n",
+ "13 5.993855811997401802623453850 19.98482856457245487734288629 2 \n",
+ "14 5.897796745026735991647259941 20.34518830015981490111740668 2 \n",
+ "15 5.929070686768885727909284389 21.18865492248121317164619034 2 \n",
+ "\n",
+ " timestamp \n",
+ "0 2018-10-01 15:16:24 \n",
+ "1 2018-10-01 15:16:25 \n",
+ "2 2018-10-01 15:16:25 \n",
+ "3 2018-10-01 15:16:25 \n",
+ "4 2018-10-01 15:16:26 \n",
+ "5 2018-10-01 15:16:26 \n",
+ "6 2018-10-01 15:16:26 \n",
+ "7 2018-10-01 15:16:26 \n",
+ "8 2018-10-01 15:16:26 \n",
+ "9 2018-10-01 15:16:26 \n",
+ "10 2018-10-01 15:16:27 \n",
+ "11 2018-10-01 15:16:27 \n",
+ "12 2018-10-01 15:16:27 \n",
+ "13 2018-10-01 15:16:28 \n",
+ "14 2018-10-01 15:16:28 \n",
+ "15 2018-10-01 15:16:28 "
+ ]
+ },
+ "execution_count": 77,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "pd.DataFrame(flatten(simulation(states_list, configs, env_processes, range(2), 2)))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "NameError",
+ "evalue": "name 'non_numeric' is not defined",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m--------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
+ "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m's1'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'3323'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's2'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2572'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's3'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2.657'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's4'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'7.914'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'timestamp'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'2018-10-01 15:16:26'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'mech_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'time_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mquantize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mTWOPLACES\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mROUND_DOWN\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnon_numeric\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mNameError\u001b[0m: name 'non_numeric' is not defined"
+ ]
+ }
+ ],
+ "source": [
+ "# Decimal('240.0').quantize(Decimal('0.01'), ROUND_DOWN)\n",
+ "# round(Decimal('240.01'), 2)\n",
+ "state_dict = {'s1': Decimal('3323'), 's2': Decimal('2572'), 's3': Decimal('2.657'), 's4': Decimal('7.914'), 'timestamp': '2018-10-01 15:16:26', 'mech_step': 1, 'time_step': 2}\n",
+ "state_dict = {k: v.quantize(TWOPLACES, ROUND_DOWN) for k, v in state_dict.items() if type(v) == Decimal}\n",
+ "state_dict.update(non_numeric)\n",
+ "state_dict"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "states_list = [state_dict]\n",
+ "states_list\n",
+ "# {'s1': 8.742503764992283e+170,\n",
+ "# 's2': 1.119720780594405e+171,\n",
+ "# 's3': 4.251811100418906,\n",
+ "# 's4': 6.92728042985628,\n",
+ "# 'timestamp': '2018-10-01 15:16:31',\n",
+ "# 'mech_step': 3,\n",
+ "# 'time_step': 7}\n",
+ "# {'s1': Decimal('2.221384236472411425810660220E+330'),\n",
+ "# 's2': Decimal('2.845096899831187764579913612E+330'),\n",
+ "# 's3': Decimal('3.622519693611211445932083740'),\n",
+ "# 's4': Decimal('5.161487081026327858663750787'),\n",
+ "# 'timestamp': '2018-10-01 15:16:32',\n",
+ "# 'mech_step': 3,\n",
+ "# 'time_step': 8}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"from decimal import Decimal, MAX_EMAX\n",
"# Decimal(2.5347751615574597e+167)**2\n",
@@ -810,42 +1199,22 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": null,
"metadata": {
"scrolled": true
},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "1000000"
- ]
- },
- "execution_count": 12,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"1000 * 1000"
]
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": null,
"metadata": {
"scrolled": true
},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "2018-10-02 12:37:06.309267\n",
- "2018-10-02 12:38:06.309267\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"from datetime import datetime, timedelta\n",
"# from datetime import timedelta \n",
@@ -858,20 +1227,9 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "datetime.datetime(2018, 10, 2, 12, 37, 6)"
- ]
- },
- "execution_count": 14,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"s = datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n",
"datetime_object = datetime.strptime(s, '%Y-%m-%d %H:%M:%S')\n",
@@ -880,21 +1238,9 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "ename": "TypeError",
- "evalue": "Required argument 'timestamp' (pos 1) not found",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m--------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdatetime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfromtimestamp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;31mTypeError\u001b[0m: Required argument 'timestamp' (pos 1) not found"
- ]
- }
- ],
+ "outputs": [],
"source": [
"datetime.fromtimestamp()"
]