def hist_matrix(dataset_id):
   d = dataset_getter(dataset_id, 'matrix')
   r = asrange(flask.request.args.get('range',None))
   data = d.asnumpy(r)
   import numpy as np
   hist, bin_edges = np.histogram(data, bins=int(flask.request.args.get('bins',np.sqrt(len(data)))), range=d.range)
   return jsonify(hist)
 def col_table(dataset_id, column):
   d = dataset_getter(dataset_id, 'table')
   r = asrange(flask.request.args.get('range',None))
   for col in d.columns:
     if col.name == column:
       return jsonify(col.aslist(r), allow_nan=False)
   flask.abort(404)
示例#3
0
  def list_items(datasetid):
    d = dataset_getter(datasetid, 'graph')
    if flask.request.method == 'GET':
      r = asrange(flask.request.args.get('range',None))
      return jsonify([n.asjson() for n in getattr(d,name+'s')(r[0] if r is not None else None)])

    if flask.request.method == 'DELETE':
      if d.clear():
        return jsonify(d.to_description(),indent=1)
      flask.abort(400)

    #post
    n = _to_desc()
    if getattr(d,'add_'+name)(n):
      return jsonify(d.to_description(),indent=1)
    #invalid upload
    flask.abort(400)
示例#4
0
  def handle_item(datasetid, itemid):
    d = dataset_getter(datasetid, 'graph')
    if flask.request.method == 'GET':
      n = getattr(d,'get_'+name)(itemid)
      return jsonify(n.asjson())

    if flask.request.method == 'DELETE':
      if getattr(d,'remove_'+name)(itemid):
        return jsonify(d.to_description(),indent=1)
      flask.abort(400)

    #put
    n = _to_desc()
    n['id'] = itemid
    if getattr(d,'update_'+name)(n):
      return jsonify(d.to_description(),indent=1)
    #invalid upload
    flask.abort(400)
示例#5
0
文件: mds.py 项目: Caleydo/mini_mds
def create(dataset, range, args):
  """
  a special method to 'format' a dataset into an mds format
  :param dataset: the dataset to convert
  :param range: a subrange of the data
  :param args: additional request arguments
  :return:
  """
  #get the data as numpy
  data = np.array(dataset.asnumpy(range))
  #get the row ids aka samples
  samples = dataset.rows(range[0] if range is not None else None)

  #TODO compute MDS and prepare the result set
  r = {}

  #convert to json
  return jsonify(r)
示例#6
0
 def list_graphs(datasetid):
   d = dataset_getter(datasetid, 'graph')
   return jsonify(d.to_description())
 def view_raw_table(dataset_id, view_name):
   view, args = find_view(dataset_id, view_name)
   return jsonify(view.aslist(args), allow_nan=False)
 def desc_gen(dataset_id):
   d = dataset_getter(dataset_id, type)
   return jsonify(d.to_description())
 def rowids_gen(dataset_id):
   d = dataset_getter(dataset_id, type)
   r = asrange(flask.request.args.get('range',None))
   ids = d.rowids(r[0] if r is not None else None)
   return jsonify(str(ranges.from_list(list(ids))))
示例#10
0
def _list_types_api():
  return jsonify(list_types())
示例#11
0
def _map_ids_api(source, target):
  return jsonify(map_ids(source, target, flask.request.args.getlist('ids[]')))
示例#12
0
def _map_id_api(source, target, sid):
  return jsonify(map_id(source, target, sid))
示例#13
0
def _list_ids_api(source):
  return jsonify(list_ids(source))
示例#14
0
 def view_rowids_table(dataset_id, view_name):
   view, args = find_view(dataset_id, view_name)
   ids = view.rowids(args)
   return jsonify(str(ranges.from_list(list(ids))))
示例#15
0
 def view_rows_table(dataset_id, view_name):
   view, args = find_view(dataset_id, view_name)
   return jsonify(view.rows(args))
def format_json(dataset, range, args):
  d = dataset.asjson(range)
  if bool(args.get('f_pretty_print', False)):
    return jsonify(d, indent=' ')
  return jsonify(d)
 def colids_matrix(dataset_id):
   d = dataset_getter(dataset_id, 'matrix')
   r = asrange(flask.request.args.get('range',None))
   return jsonify(d.colids(r[0] if r is not None else None))
 def raw_gen(dataset_id):
   d = dataset_getter(dataset_id, type)
   r = asrange(flask.request.args.get('range',None))
   return jsonify(d.asnumpy(r), allow_nan=False)
 def rowids_gen(dataset_id):
   d = dataset_getter(dataset_id, type)
   r = asrange(flask.request.args.get('range',None))
   return jsonify(d.rowids(r[0] if r is not None else None))
 def colids_matrix(dataset_id):
   d = dataset_getter(dataset_id, 'matrix')
   r = asrange(flask.request.args.get('range',None))
   ids = d.colids(r[0] if r is not None else None)
   return jsonify(str(ranges.from_list(list(ids))))