@@ -78,16 +78,13 @@ def __init__(self, *args, **kwargs):
78
78
super ().__init__ (* args , ** kwargs )
79
79
self ._ymeta = self ._ydoc .get_map ("meta" )
80
80
self ._ycells = self ._ydoc .get_array ("cells" )
81
- self ._ymetadata = self ._ydoc .get_map ("metadata" )
82
81
83
82
@property
84
83
def source (self ):
85
84
meta = self ._ymeta .to_json ()
86
85
cells = self ._ycells .to_json ()
87
- metadata = self ._ymetadata .to_json ()
88
86
cast_all (meta , float , int )
89
87
cast_all (cells , float , int )
90
- cast_all (metadata , float , int )
91
88
for cell in cells :
92
89
if "id" in cell and meta ["nbformat" ] == 4 and meta ["nbformat_minor" ] <= 4 :
93
90
# strip cell IDs if we have notebook format 4.0-4.4
@@ -97,7 +94,7 @@ def source(self):
97
94
98
95
return dict (
99
96
cells = cells ,
100
- metadata = metadata ,
97
+ metadata = meta [ " metadata" ] ,
101
98
nbformat = int (meta ["nbformat" ]),
102
99
nbformat_minor = int (meta ["nbformat_minor" ]),
103
100
)
@@ -125,8 +122,6 @@ def source(self, value):
125
122
self ._ymeta .pop (t , key )
126
123
if cells_len :
127
124
self ._ycells .delete_range (t , 0 , cells_len )
128
- for key in self ._ymetadata :
129
- self ._ymetadata .pop (t , key )
130
125
for key in [k for k in self ._ystate if k != "dirty" ]:
131
126
self ._ystate .pop (t , key )
132
127
@@ -154,8 +149,7 @@ def source(self, value):
154
149
155
150
if ycells :
156
151
self ._ycells .extend (t , ycells )
157
- for k , v in nb ["metadata" ].items ():
158
- self ._ymetadata .set (t , k , v )
152
+ self ._ymeta .set (t , "metadata" , nb ["metadata" ])
159
153
self ._ymeta .set (t , "nbformat" , nb ["nbformat" ])
160
154
self ._ymeta .set (t , "nbformat_minor" , nb ["nbformat_minor" ])
161
155
@@ -164,4 +158,3 @@ def observe(self, callback):
164
158
self ._subscriptions [self ._ystate ] = self ._ystate .observe (callback )
165
159
self ._subscriptions [self ._ymeta ] = self ._ymeta .observe (callback )
166
160
self ._subscriptions [self ._ycells ] = self ._ycells .observe_deep (callback )
167
- self ._subscriptions [self ._ymetadata ] = self ._ymetadata .observe (callback )
0 commit comments