示例#1
0
 def create_data_instance(self, name, typename):
     json = dict(typename=typename, dataname=name)
     url = self.url_prefix + "repo/" + str(
         self.root_uuid) + "/" + "instance"
     res = dvid_requester.post(url=url, json=json)
     if not res.ok: warnings.warn(res.text)
     data_instance = DVIDDataInstance(self.hostname, self.port,
                                      self.root_uuid, name)
     return data_instance
示例#2
0
 def create_data_instance(self, name, typename):
     json = dict(typename=typename, dataname=name)
     url = self.url_prefix + "repo/" + str(self.root_uuid) + "/" + "instance"
     res = dvid_requester.post(
         url=url,
         json=json
     )
     if not res.ok: warnings.warn(res.text)
     data_instance = DVIDDataInstance(self.hostname, self.port, self.root_uuid, name)
     return data_instance
示例#3
0
 def __setitem__(self, slices, array):
     shape_of_slices = tuple([s.stop - s.start for s in slices])
     assert array.shape == shape_of_slices, (array.shape, shape_of_slices)
     n_spatial_dims = len(slices)
     axes_str = '_'.join([str(a) for a in range(n_spatial_dims)])
     shape = [s.stop - s.start for s in slices]
     shape_str = '_'.join(str(s) for s in shape)
     offset = [s.start for s in slices]
     offset_str = '_'.join([str(o) for o in offset])
     #  <api URL>/node/<UUID>/<data name>/raw/0_1_2/<size>/<offset>[?queryopts]
     url = self.url_prefix + 'raw/' + axes_str + '/' + shape_str + '/' + offset_str
     array_np = np.array(array, dtype=self.dtype)
     array_as_string = array_np.tostring()
     response = dvid_requester.post(url, data=array_as_string)
     assert response.ok, response.content
     return
示例#4
0
 def __setitem__(self, slices, array):
     shape_of_slices = tuple([s.stop - s.start for s in slices])
     assert array.shape == shape_of_slices, (array.shape, shape_of_slices)
     n_spatial_dims = len(slices)
     axes_str = '_'.join([str(a) for a in range(n_spatial_dims)])
     shape = [s.stop - s.start for s in slices]
     shape = tuple(reversed(shape))
     shape_str = '_'.join(str(s) for s in shape)
     offset = [s.start for s in slices]
     offset = tuple(reversed(offset))
     offset_str = '_'.join([str(o) for o in offset])
     #  <api URL>/node/<UUID>/<data name>/raw/0_1_2/<size>/<offset>[?queryopts]
     url = self.url_prefix + 'raw/' + axes_str + '/' + shape_str + '/' + offset_str
     array_np = np.array(array, dtype=self.dtype)
     array_as_string = array_np.tostring()
     response = dvid_requester.post(url, data=array_as_string)
     assert response.ok, response.content
     return