forked from jupyter/enhancement-proposals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_model_example.py
36 lines (31 loc) · 1.49 KB
/
data_model_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# This file contains an example for the proposed data model implemented
# as Python data structures.
import hashlib
def sha1(s):
return hashlib.sha1(s.encode('utf-8')).hexdigest()
layer1 = {'language': 'python3',
'code': ["import math",
"x = math.pi\nmath.cos(x)"]}
layer2 = {'code': layer1,
'environment': "Python 3.4.3 (default, Apr 15 2015, 21:03:06)\n[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)] on darwin",
'log': [{'hash': sha1(layer1['code'][0]),
'outputs': {'console': {'data': "",
'hash': sha1("")}}},
{'hash': sha1(layer1['code'][1]),
'outputs': {'console': {'data': "-1.0",
'hash': sha1("-1.0")}}}]}
layer3 = {'language': 'python3',
'execution': [layer2],
'cells': [{'type': 'documentation',
'format': 'markdown',
'data': "# The cosine function\n"},
{'type': 'documentation',
'format': 'markdown',
'data': "First we import the math module:\n"},
{'type': 'execution_record',
'data': (0, 0)},
{'type': 'documentation',
'format': 'markdown',
'data': "Now we can compute the cosine:\n"},
{'type': 'execution_record',
'data': (0, 1)},]}