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


Python Data.compute_fixed_resolution_buffer方法代码示例

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


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

示例1: test_indexed

# 需要导入模块: from glue.core.data import Data [as 别名]
# 或者: from glue.core.data.Data import compute_fixed_resolution_buffer [as 别名]
    def test_indexed(self):

        # Here we slice two of the dimensions and then compare the results to a
        # manually sliced dataset.

        derived = IndexedData(self.data, (None, 2, None, 4, None))
        manual = Data()
        manual.add_component(self.data[self.x_id][:, 2, :, 4, :], label=self.x_id)
        manual.add_component(self.data[self.y_id][:, 2, :, 4, :], label=self.y_id)

        assert derived.label == 'Test data[:,2,:,4,:]'
        assert derived.shape == manual.shape
        assert [str(c) for c in derived.main_components] == [str(c) for c in manual.main_components]
        assert derived.get_kind(self.x_id) == manual.get_kind(self.x_id)

        for view in [None, (1, slice(None), slice(1, 4))]:

            assert_equal(derived.get_data(self.x_id, view=view),
                         manual.get_data(self.x_id, view=view))

            assert_equal(derived.get_mask(self.subset_state, view=view),
                         manual.get_mask(self.subset_state, view=view))

        bounds = [2, (-5, 5, 10), (-3, 3, 10)]
        assert_equal(derived.compute_fixed_resolution_buffer(bounds=bounds, target_cid=self.x_id),
                     manual.compute_fixed_resolution_buffer(bounds=bounds, target_cid=self.x_id))

        assert_equal(derived.compute_statistic('mean', self.x_id),
                     manual.compute_statistic('mean', self.x_id))

        assert_equal(derived.compute_statistic('mean', self.x_id, axis=2),
                     manual.compute_statistic('mean', self.x_id, axis=2))

        assert_equal(derived.compute_statistic('mean', self.x_id, subset_state=self.subset_state),
                     manual.compute_statistic('mean', self.x_id, subset_state=self.subset_state))

        assert_equal(derived.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30]),
                     manual.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30]))

        assert_equal(derived.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30], subset_state=self.subset_state),
                     manual.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30], subset_state=self.subset_state))
开发者ID:glue-viz,项目名称:glue,代码行数:43,代码来源:test_data_derived.py

示例2: setup_class

# 需要导入模块: from glue.core.data import Data [as 别名]
# 或者: from glue.core.data.Data import compute_fixed_resolution_buffer [as 别名]
class TestIndexedData:

    def setup_class(self):

        x = +np.arange(2520).reshape((3, 4, 5, 6, 7))
        y = -np.arange(2520).reshape((3, 4, 5, 6, 7))

        self.data = Data(x=x, y=y, label='Test data')
        self.x_id, self.y_id = self.data.main_components

        self.subset_state = self.x_id >= 1200

    def test_identity(self):

        # In this test, we don't actually slice any dimensions

        derived = IndexedData(self.data, (None,) * 5)

        assert derived.label == 'Test data[:,:,:,:,:]'
        assert derived.shape == self.data.shape
        assert [str(c) for c in derived.main_components] == [str(c) for c in self.data.main_components]
        assert derived.get_kind(self.x_id) == self.data.get_kind(self.x_id)

        for view in [None, (1, slice(None), slice(None), slice(1, 4), slice(0, 7, 2))]:

            assert_equal(derived.get_data(self.x_id, view=view),
                         self.data.get_data(self.x_id, view=view))

            assert_equal(derived.get_mask(self.subset_state, view=view),
                         self.data.get_mask(self.subset_state, view=view))

        bounds = [2, (-5, 5, 10), 3, 4, (-3, 3, 10)]
        assert_equal(derived.compute_fixed_resolution_buffer(bounds=bounds, target_cid=self.x_id),
                     self.data.compute_fixed_resolution_buffer(bounds=bounds, target_cid=self.x_id))

        assert_equal(derived.compute_statistic('mean', self.x_id),
                     self.data.compute_statistic('mean', self.x_id))

        assert_equal(derived.compute_statistic('mean', self.x_id, axis=2),
                     self.data.compute_statistic('mean', self.x_id, axis=2))

        assert_equal(derived.compute_statistic('mean', self.x_id, subset_state=self.subset_state),
                     self.data.compute_statistic('mean', self.x_id, subset_state=self.subset_state))

        assert_equal(derived.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30]),
                     self.data.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30]))

        assert_equal(derived.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30], subset_state=self.subset_state),
                     self.data.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30], subset_state=self.subset_state))

    def test_indexed(self):

        # Here we slice two of the dimensions and then compare the results to a
        # manually sliced dataset.

        derived = IndexedData(self.data, (None, 2, None, 4, None))
        manual = Data()
        manual.add_component(self.data[self.x_id][:, 2, :, 4, :], label=self.x_id)
        manual.add_component(self.data[self.y_id][:, 2, :, 4, :], label=self.y_id)

        assert derived.label == 'Test data[:,2,:,4,:]'
        assert derived.shape == manual.shape
        assert [str(c) for c in derived.main_components] == [str(c) for c in manual.main_components]
        assert derived.get_kind(self.x_id) == manual.get_kind(self.x_id)

        for view in [None, (1, slice(None), slice(1, 4))]:

            assert_equal(derived.get_data(self.x_id, view=view),
                         manual.get_data(self.x_id, view=view))

            assert_equal(derived.get_mask(self.subset_state, view=view),
                         manual.get_mask(self.subset_state, view=view))

        bounds = [2, (-5, 5, 10), (-3, 3, 10)]
        assert_equal(derived.compute_fixed_resolution_buffer(bounds=bounds, target_cid=self.x_id),
                     manual.compute_fixed_resolution_buffer(bounds=bounds, target_cid=self.x_id))

        assert_equal(derived.compute_statistic('mean', self.x_id),
                     manual.compute_statistic('mean', self.x_id))

        assert_equal(derived.compute_statistic('mean', self.x_id, axis=2),
                     manual.compute_statistic('mean', self.x_id, axis=2))

        assert_equal(derived.compute_statistic('mean', self.x_id, subset_state=self.subset_state),
                     manual.compute_statistic('mean', self.x_id, subset_state=self.subset_state))

        assert_equal(derived.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30]),
                     manual.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30]))

        assert_equal(derived.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30], subset_state=self.subset_state),
                     manual.compute_histogram([self.x_id], range=[(0, 1000)], bins=[30], subset_state=self.subset_state))

    def test_numerical_values_changed(self):

        # Here we slice two of the dimensions and then compare the results to a
        # manually sliced dataset.

        derived = IndexedData(self.data, (None, 2, None, 4, None))
        data_collection = DataCollection([self.data, derived])

#.........这里部分代码省略.........
开发者ID:glue-viz,项目名称:glue,代码行数:103,代码来源:test_data_derived.py


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