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


Python Observation.find方法代码示例

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


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

示例1: test_delete

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
 def test_delete(self):
     self._save_observations()
     records = Observation.find(self.dataset)
     self.assertNotEqual(records, [])
     Observation.delete_all(self.dataset)
     records = [x for x in Observation.find(self.dataset)]
     self.assertEqual(records, [])
开发者ID:j,项目名称:bamboo,代码行数:9,代码来源:test_observation.py

示例2: test_delete_all

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
    def test_delete_all(self):
        self.__save_records()
        records = Observation.find(self.dataset)
        self.assertNotEqual(records, [])
        Observation.delete_all(self.dataset)
        records = Observation.find(self.dataset)

        self.assertEqual(records, [])
开发者ID:EmOne,项目名称:bamboo,代码行数:10,代码来源:test_observation.py

示例3: test_delete_one

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

        row = self.__decode(records[0])

        Observation.delete(self.dataset, row[INDEX])
        new_records = Observation.find(self.dataset)

        # Dump to avoid problems with nan != nan.
        self.assertEqual(dump_mongo_json(records[1:]),
                         dump_mongo_json(new_records))
开发者ID:EmOne,项目名称:bamboo,代码行数:15,代码来源:test_observation.py

示例4: _save_records

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
 def _save_records(self):
     Observation.save(self.get_data('good_eats.csv'),
                      self.dataset)
     records = Observation.find(self.dataset)
     self.assertTrue(isinstance(records, list))
     self.assertTrue(isinstance(records[0], dict))
     self.assertTrue('_id' in records[0].keys())
     return records
开发者ID:j,项目名称:bamboo,代码行数:10,代码来源:test_observation.py

示例5: observations

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
    def observations(self, query_args=None, as_cursor=False):
        """Return observations for this dataset.

        :param query_args: An optional QueryArgs to hold the query arguments.
        :param as_cursor: Return the observations as a cursor.
        """
        return Observation.find(self, query_args or QueryArgs(),
                                as_cursor=as_cursor)
开发者ID:zbyufei,项目名称:bamboo,代码行数:10,代码来源:dataset.py

示例6: test_find_with_select_and_query

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
    def test_find_with_select_and_query(self):
        self.__save_records()
        self.query_args.select = {"rating": 1}
        rows = Observation.find(self.dataset, self.query_args)
        self.assertTrue(isinstance(rows, list))

        row = self.__decode(rows[0])

        self.assertEquals(sorted(row.keys()), ['_id', 'rating'])
开发者ID:EmOne,项目名称:bamboo,代码行数:11,代码来源:test_observation.py

示例7: observations

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
    def observations(self, query=None, select=None, limit=0, order_by=None,
                     as_cursor=False):
        """Return observations for this dataset.

        :param query: Optional query for MongoDB to limit rows returned.
        :param select: Optional select for MongoDB to limit columns.
        :param limit: If greater than 0, limit number of observations returned
            to this maximum.
        :param order_by: Order the returned observations.
        """
        return Observation.find(self, query, select, limit=limit,
                                order_by=order_by, as_cursor=as_cursor)
开发者ID:helioid,项目名称:bamboo,代码行数:14,代码来源:dataset.py

示例8: observations

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
    def observations(self, query_args=QueryArgs(), as_cursor=False):
        """Return observations for this dataset.

        :param query_args: An optional QueryArgs to hold the query arguments.
        :param as_cursor: Return the observations as a cursor.
        """
        if query_args.distinct:
            as_cursor = True

        observations = Observation.find(self, query_args, as_cursor=as_cursor)

        if query_args.distinct:
            observations = observations.distinct(query_args.distinct)

        return observations
开发者ID:j,项目名称:bamboo,代码行数:17,代码来源:dataset.py

示例9: test_dframe

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
    def test_dframe(self):
        dataset = Dataset.create(self.test_dataset_ids['good_eats.csv'])
        dataset.save_observations(
            recognize_dates(self.get_data('good_eats.csv')))
        records = [x for x in Observation.find(dataset)]
        dframe = dataset.dframe()

        self.assertTrue(isinstance(dframe, DataFrame))
        self.assertTrue(all(self.get_data('good_eats.csv').reindex(
                        columns=dframe.columns).eq(dframe)))
        columns = dframe.columns
        # ensure no reserved keys
        for key in MONGO_RESERVED_KEY_STRS:
            self.assertFalse(key in columns)
        # ensure date is converted
        self.assertTrue(isinstance(dframe.submit_date[0], datetime))
开发者ID:j,项目名称:bamboo,代码行数:18,代码来源:test_dataset.py

示例10: test_edit_row

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
    def test_edit_row(self):
        dataset_id = self._post_file()
        index = 0
        update = {'amount': 10, 'food_type': 'breakfast'}
        expected_dframe = Dataset.find_one(dataset_id).dframe()
        expected_row = expected_dframe.ix[0].to_dict()
        expected_row.update(update)
        expected_dframe.ix[0] = Series(expected_row)

        results = json.loads(self.controller.row_update(dataset_id, index,
                                                        json.dumps(update)))
        self.assertTrue(Datasets.SUCCESS in results.keys())

        dataset = Dataset.find_one(dataset_id)
        dframe = dataset.dframe()
        self.assertEqual(self.NUM_ROWS, len(dframe))
        self._check_dframes_are_equal(expected_dframe, dframe)

        # check that previous row exists
        all_observations = Observation.find(dataset, include_deleted=True)
        self.assertEqual(self.NUM_ROWS + 1, len(all_observations))
开发者ID:4sp1r3,项目名称:bamboo,代码行数:23,代码来源:test_datasets_edit.py

示例11: test_delete_row

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
    def test_delete_row(self):
        dataset_id = self._post_file()
        dataset = Dataset.find_one(dataset_id)
        index = 0
        expected_dframe = Dataset.find_one(
            dataset_id).dframe()[index + 1:].reset_index()
        del expected_dframe['index']

        results = json.loads(self.controller.row_delete(dataset_id, index))
        self.assertTrue(Datasets.SUCCESS in results.keys())

        dataset = Dataset.find_one(dataset_id)
        dframe = dataset.dframe()
        self.assertEqual(self.NUM_ROWS - 1, len(dframe))
        self._check_dframes_are_equal(expected_dframe, dframe)

        # check info updated
        info = dataset.info()
        self.assertEqual(self.NUM_ROWS - 1, info[Dataset.NUM_ROWS])

        # check that row is softly deleted
        all_observations = Observation.find(dataset, include_deleted=True)
        self.assertEqual(self.NUM_ROWS, len(all_observations))
开发者ID:4sp1r3,项目名称:bamboo,代码行数:25,代码来源:test_datasets_edit.py

示例12: test_find_with_select

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
 def test_find_with_select(self):
     self._save_observations()
     query_args = QueryArgs(select={"rating": 1})
     rows = Observation.find(self.dataset, query_args)
     self.assertTrue(isinstance(rows, list))
     self.assertEquals(sorted(rows[0].keys()), ['_id', 'rating'])
开发者ID:j,项目名称:bamboo,代码行数:8,代码来源:test_observation.py

示例13: test_find_with_query

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
 def test_find_with_query(self):
     self._save_observations()
     rows = Observation.find(self.dataset, self.query_args)
     self.assertTrue(isinstance(rows, list))
开发者ID:j,项目名称:bamboo,代码行数:6,代码来源:test_observation.py

示例14: test_find

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
 def test_find(self):
     self._save_observations()
     rows = Observation.find(self.dataset)
     self.assertTrue(isinstance(rows, list))
开发者ID:j,项目名称:bamboo,代码行数:6,代码来源:test_observation.py

示例15: test_save_over_bulk

# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import find [as 别名]
 def test_save_over_bulk(self):
     Observation.save(self.get_data('good_eats_large.csv'),
                      self.dataset)
     records = Observation.find(self.dataset)
     self.assertEqual(len(records), 1001)
开发者ID:j,项目名称:bamboo,代码行数:7,代码来源:test_observation.py


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