예제 #1
0
 def __init__(self, name='DynFilterSrv', condition_srv_name='ConditionSrv'):
     '''
     @param name: The unique name of the service
     '''
     self._dfilters = Case().tag(name).tag(DynFilter.__name__)
     self._conditions = Showcase.instance().get_case(condition_srv_name)
     INamed.__init__(self, name)
예제 #2
0
파일: app.py 프로젝트: crispamares/memcover
 def clear_dselects(self):
         #dselect = Showcase.instance().get('morpho_dselect')
         #dselect.clear()
         #dselect = Showcase.instance().get('clinic_dselect')
         #dselect.clear()
         dselect = Showcase.instance().get('joined_dselect')
         dselect.clear()
예제 #3
0
def describe_stats(dselect_name, dataset_name, attr_name):
    dselect = Showcase.instance().get(dselect_name)
    dataset = Showcase.instance().get(dataset_name)
    description = None

    project = {attr_name: True}
    query = dselect.query if dselect.get_conditions() else {}

    data = dataset.find(query, project).get_data('c_list')

    attr_scheme = dataset.schema.attributes[attr_name]
    if data and attr_scheme.attribute_type == "QUANTITATIVE":
        desc = [d if pd.np.isreal(d) else None for d in data[attr_name]]
        description = pd.Series(desc).describe().to_dict()

    return description
예제 #4
0
def export_dselect(dselect_name, dataset_name, name):
    dselect = Showcase.instance().get(dselect_name)
    dataset = Showcase.instance().get(dataset_name)

    download_name = name.replace(" ", "_") + '.xlsx'

    project = dselect.projection

    # Multidimensial attributes are not exported in tables
    for name, attr in dataset.schema.attributes.items():
        if attr.is_multidimensional():
            project[name] = False

    data = dataset.find(dselect.query, project).get_data('rows')
    df = pd.DataFrame(data)
    df.to_excel(os.path.join(ASSETSPATH, 'exports', download_name))

    return os.path.join('assets', 'exports', download_name)
예제 #5
0
    def build(self, grammar, objects=None):
        showcase = Showcase.instance()
        if objects:
            objects = {o:showcase.get(o) for o in objects}
        instances = Root.build(grammar, objects)
        print '////', instances
        for name, instance in instances.items():
            case = showcase.get_case(instance.__class__.__name__)
            case[name] = instance

        return instances.values()
예제 #6
0
    def new_condition(self, kind, data, *args, **kwargs):
        dataset = Showcase.instance().get(data)
        if kind == 'categorical':
            new_condition = CategoricalCondition(dataset, *args, **kwargs)
        if kind == 'attribute':
            new_condition = AttributeCondition(dataset, *args, **kwargs)
        if kind == 'range':
            new_condition = RangeCondition(dataset, *args, **kwargs)
        if kind == 'query':
            new_condition = QueryCondition(dataset, *args, **kwargs)

        self._conditions[new_condition.oid] = new_condition
        return new_condition
예제 #7
0
 def new_dfilter(self, name, data, setop='AND', prefix=''):
     dataset = Showcase.instance().get(data)
     new_dfilter = DynFilter(name, dataset, setop, prefix=prefix)
     self._dfilters[new_dfilter.oid] = new_dfilter
     return new_dfilter
예제 #8
0
 def new_dselect(self, name, data, setop='OR', prefix=''):
     dataset = Showcase.instance().get(data)
     new_dselect = DynSelect(name, dataset, setop, prefix=prefix)
     self._dselects[new_dselect.oid] = new_dselect
     return new_dselect
예제 #9
0
 def _proxy_instanciator(self, method, root_oid, object_or_objects):
     showcase = Showcase.instance()
     names = object_or_objects if isinstance(object_or_objects, list) else [object_or_objects]
     objects = [showcase.get(n) for n in names]
     return self._proxy(method, root_oid, objects)
예제 #10
0
 def write_csv(self, table_name, filepath, schema=None, *args, **kwargs):
     case = Showcase.instance().get_case(self._table_srv_name)
     table = case[table_name]
     schema = schema if schema is not None else table.schema
     return write_csv(table, filepath, schema, *args, **kwargs)
예제 #11
0
 def read_csv(self, table_name, filepath, schema=None, *args, **kwargs):
     table = read_csv(table_name, filepath, schema, *args, **kwargs)
     case = Showcase.instance().get_case(self._table_srv_name)
     case[table.oid] = table
     return table