当前位置: 首页>>代码示例>>Python>>正文


Python Observation.encoding方法代码示例

本文整理汇总了Python中bamboo.models.observation.Observation.encoding方法的典型用法代码示例。如果您正苦于以下问题:Python Observation.encoding方法的具体用法?Python Observation.encoding怎么用?Python Observation.encoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bamboo.models.observation.Observation的用法示例。


在下文中一共展示了Observation.encoding方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delete_encoding

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import encoding [as 别名]
    def test_delete_encoding(self):
        self.__save_records()
        encoding = Observation.encoding(self.dataset)

        self.assertTrue(isinstance(encoding, dict))

        Observation.delete_encoding(self.dataset)
        encoding = Observation.encoding(self.dataset)

        self.assertEqual(encoding, None)
开发者ID:EmOne,项目名称:bamboo,代码行数:12,代码来源:test_observation.py

示例2: test_delete

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import encoding [as 别名]
    def test_delete(self):
        for dataset_name in self.TEST_DATASETS:
            dataset = Dataset.create(self.test_dataset_ids[dataset_name])
            records = Dataset.find(self.test_dataset_ids[dataset_name])
            self.assertNotEqual(records, [])
            dataset.delete()
            records = Dataset.find(self.test_dataset_ids[dataset_name])

            self.assertEqual(records, [])
            self.assertEqual(Observation.encoding(dataset), None)
开发者ID:4sp1r3,项目名称:bamboo,代码行数:12,代码来源:test_dataset.py

示例3: test_encoding

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import encoding [as 别名]
    def test_encoding(self):
        self.__save_records()
        encoding = Observation.encoding(self.dataset)

        for column in self.dataset.dframe().columns:
            if column == MONGO_ID:
                column = MONGO_ID_ENCODED

            self.assertTrue(column in encoding.keys())

        for v in encoding.values():
            self.assertTrue(isinstance(int(v), int))
开发者ID:EmOne,项目名称:bamboo,代码行数:14,代码来源:test_observation.py

示例4: get_value

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import encoding [as 别名]
 def get_value(self, period):
     value = None
     if self.dataset:
         fields = Observation.encoding(self.dataset)
         fields["dataset"] = self.dataset
         fields['dataset_id_field'] = fields[DATASET_ID]
         fields['period'] = period
         query = json.loads(Template(self.final_str).render(fields))
         form_meta_timeend = '%(form_meta_timeend)s' % fields
         query[0]['$match'][form_meta_timeend]['$gte'] = period.start
         query[0]['$match'][form_meta_timeend]['$lte'] = period.end
         aggregate_value = self._db.observations.aggregate(query)
         if not aggregate_value['result']:
             return 0
         value = aggregate_value['result'][0]['total_num']
     return value
开发者ID:SEL-Columbia,项目名称:mvpqa,代码行数:18,代码来源:num_u5_slept_last_night.py

示例5: get_value

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import encoding [as 别名]
 def get_value(self, period):
     value = None
     if self.dataset:
         fields = Observation.encoding(self.dataset)
         fields["dataset"] = self.dataset
         fields['dataset_id_field'] = fields[DATASET_ID]
         fields['period'] = period
         mapper = Code(Template(self.mapper_str).render(fields))
         reducer = Code(Template(self.reducer_str).render(fields))
         query = json.loads(Template(self.query_str).render(fields))
         query['%(form_meta_timeend)s' % fields]['$gte'] = period.start
         query['%(form_meta_timeend)s' % fields]['$lte'] = period.end
         aggregate = json.loads(Template(self.aggregate_str).render(fields))
         results = self._db.observations.map_reduce(
             mapper, reducer, 'myresults_malaria', query=query)
         value = None
         if results.count():
             aggregate_value = results.aggregate(aggregate)
             value = aggregate_value['result'][0]['total']
         self._db.myresults_malaria.drop()
     return value
开发者ID:SEL-Columbia,项目名称:mvpqa,代码行数:23,代码来源:num_other_positive.py

示例6: Code

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import encoding [as 别名]
{"{{dataset_id_field}}": "{{dataset.dataset_id}}",
"{{form_meta_timeend}}": {
              "$gte": "{{period.start}}", 
              "$lte": "{{period.end}}"
            }
}
"""
aggregate_str = """
{"$group": {"_id": 0, "total": {"$sum": "$value.{{num_using_fp}}"}}}
"""
dataset_id = "5791793ac29b4d77b20cf1a04d8e7161"
dataset = Dataset.find_one(dataset_id)
period = Period.month_period(2013, 3)

if dataset:
    fields = Observation.encoding(dataset)
    fields["dataset"] = dataset
    fields['dataset_id_field'] = fields[DATASET_ID]
    fields['period'] = Period.month_period(2013, 3)
    mapper = Code(Template(mapper_str).render(fields))
    reducer = Code(Template(reducer_str).render(fields))
    query = json.loads(Template(query_str).render(fields))
    query['%(form_meta_timeend)s' % fields]['$gte'] = period.start
    query['%(form_meta_timeend)s' % fields]['$lte'] = period.end
    aggregate = json.loads(Template(aggregate_str).render(fields))
    results = db.observations.map_reduce(mapper, reducer, 'myresults_fp', query=query)
    if results.count():
        value = results.aggregate(aggregate)
        print  value['result'][0]['total']
        assert value['result'][0]['total'] == 1641
    db.myresults_fp.drop()
开发者ID:SEL-Columbia,项目名称:mvpqa,代码行数:33,代码来源:mapreduce.py


注:本文中的bamboo.models.observation.Observation.encoding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。