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


Python observation.Observation类代码示例

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


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

示例1: test_delete

 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,代码行数:7,代码来源:test_observation.py

示例2: remove_parent_observations

    def remove_parent_observations(self, parent_id):
        """Remove obervations for this dataset with the passed `parent_id`.

        :param parent_id: Remove observations with this ID as their parent
            dataset ID.
        """
        Observation.delete_all(self, {PARENT_DATASET_ID: parent_id})
开发者ID:j,项目名称:bamboo,代码行数:7,代码来源:dataset.py

示例3: action

        def action(dataset, data=data):
            data = safe_json_loads(data)
            Observation.update(dataset, int(index), data)

            return {
                self.SUCCESS: 'Updated row with index "%s".' % index,
                Dataset.ID: dataset_id}
开发者ID:sparkplug,项目名称:bamboo,代码行数:7,代码来源:datasets.py

示例4: delete_task

def delete_task(dataset, query=None):
    """Background task to delete dataset and its associated observations."""
    Observation.delete_all(dataset, query=query)

    if query is None:
        super(dataset.__class__, dataset).delete(
            {DATASET_ID: dataset.dataset_id})
        Observation.delete_encoding(dataset)
开发者ID:zbyufei,项目名称:bamboo,代码行数:8,代码来源:dataset.py

示例5: append_observations

    def append_observations(self, dframe):
        Observation.append(dframe, self)
        self.update({self.NUM_ROWS: self.num_rows + len(dframe)})

        # to update cardinalities here we need to refetch the full DataFrame.
        dframe = self.dframe(keep_parent_ids=True)
        self.build_schema(dframe)
        self.update_stats(dframe)
开发者ID:zbyufei,项目名称:bamboo,代码行数:8,代码来源:dataset.py

示例6: _save_records

 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,代码行数:8,代码来源:test_observation.py

示例7: test_delete_all

    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,代码行数:8,代码来源:test_observation.py

示例8: delete_observation

    def delete_observation(self, index):
        """Delete observation at index.

        :params index: The index of an observation to delete.
        """
        Observation.delete(self, index)

        dframe = self.dframe()
        self.update({self.NUM_ROWS: len(dframe)})
        self.build_schema(dframe, overwrite=True)
开发者ID:j,项目名称:bamboo,代码行数:10,代码来源:dataset.py

示例9: test_delete_encoding

    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,代码行数:10,代码来源:test_observation.py

示例10: test_delete_one

    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,代码行数:13,代码来源:test_observation.py

示例11: replace_observations

    def replace_observations(self, dframe, overwrite=False,
                             set_num_columns=True):
        """Remove all rows for this dataset and save the rows in `dframe`.

        :param dframe: Replace rows in this dataset with this DataFrame's rows.

        :returns: BambooFrame equivalent to the passed in `dframe`.
        """
        self.build_schema(dframe, overwrite=overwrite,
                          set_num_columns=set_num_columns)
        dframe = self.add_id_column_to_dframe(dframe)
        Observation.delete_all(self)

        return self.save_observations(dframe)
开发者ID:helioid,项目名称:bamboo,代码行数:14,代码来源:dataset.py

示例12: replace_observations

    def replace_observations(self, dframe, overwrite=False,
                             set_num_columns=True):
        """Remove all rows for this dataset and save the rows in `dframe`.

        :param dframe: Replace rows in this dataset with this DataFrame's rows.
        :param overwrite: If true replace the schema, otherwise update it.
            Default False.
        :param set_num_columns: If true update the dataset stored number of
            columns.  Default True.

        :returns: DataFrame equivalent to the passed in `dframe`.
        """
        self.build_schema(dframe, overwrite=overwrite,
                          set_num_columns=set_num_columns)
        Observation.delete_all(self)

        return self.save_observations(dframe)
开发者ID:zbyufei,项目名称:bamboo,代码行数:17,代码来源:dataset.py

示例13: observations

    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,代码行数:8,代码来源:dataset.py

示例14: delete_columns

    def delete_columns(self, columns):
        """Delete column `column` from this dataset.

        :param column: The column to delete.
        """
        columns = set(self.schema.keys()).intersection(set(to_list(columns)))

        if not len(columns):
            raise ArgumentError("Columns: %s not in dataset.")

        Observation.delete_columns(self, columns)
        new_schema = self.schema

        [new_schema.pop(c) for c in columns]

        self.set_schema(new_schema, set_num_columns=True)

        return columns
开发者ID:zbyufei,项目名称:bamboo,代码行数:18,代码来源:dataset.py

示例15: test_find_with_select_and_query

    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,代码行数:9,代码来源:test_observation.py


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