(scene)
return scene_json
Serialize a scene.
Serialize a scene.
Serialize a scene .
def serialize(scene):
    """Serialize a scene."""
    
    # HACK: force all attributes to float32
    # for visual in scene.get('visuals', []):
        # if isinstance(visual.get('bounds', None), np.ndarray):
            # visual['bounds'] = encode_data(visual['bounds'])
        # for variable in visual.get('variables', []):
            # if isinstance(variable.get('data', None), np.ndarray):
                # # vartype = variable.get('vartype', 'float')
                # # if vartype == 'int':
                    # # dtype = np.int32
                # # elif vartype == 'float':
                    # # dtype = np.float32
                # variable['data'] = encode_data(np.array(variable['data'], dtype=np.float32))
    
    scene_json = json.dumps(scene, cls=ArrayEncoder, ensure_ascii=True)
    # scene_json = scene_json.replace('\\n', '\\\\n')
    return scene_json
def serialize ( scene ) : # HACK: force all attributes to float32 # for visual in scene.get('visuals', []): # if isinstance(visual.get('bounds', None), np.ndarray): # visual['bounds'] = encode_data(visual['bounds']) # for variable in visual.get('variables', []): # if isinstance(variable.get('data', None), np.ndarray): # # vartype = variable.get('vartype', 'float') # # if vartype == 'int': # # dtype = np.int32 # # elif vartype == 'float': # # dtype = np.float32 # variable['data'] = encode_data(np.array(variable['data'], dtype=np.float32)) scene_json = json . dumps ( scene , cls = ArrayEncoder , ensure_ascii = True ) # scene_json = scene_json.replace('\\n', '\\\\n') return scene_json