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


Python Signal.unfold方法代码示例

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


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

示例1: setUp

# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import unfold [as 别名]
class TestSignalFolding:
    def setUp(self):
        self.s = Signal(np.empty((2, 3, 4, 5)))
        self.s.axes_manager.set_signal_dimension(2)

    def test_unfold_navigation(self):
        s = self.s.deepcopy()
        s.unfold_navigation_space()
        nose.tools.assert_equal(s.axes_manager.navigation_shape, (self.s.axes_manager.navigation_size,))

    def test_unfold_signal(self):
        s = self.s.deepcopy()
        s.unfold_signal_space()
        nose.tools.assert_equal(s.axes_manager.signal_shape, (self.s.axes_manager.signal_size,))

    def test_unfolded_repr(self):
        self.s.unfold()
        nose.tools.assert_true("unfolded" in repr(self.s))
开发者ID:lu-chi,项目名称:hyperspy,代码行数:20,代码来源:test_folding.py

示例2: setUp

# 需要导入模块: from hyperspy.signal import Signal [as 别名]
# 或者: from hyperspy.signal.Signal import unfold [as 别名]
class TestSignalFolding:

    def setUp(self):
        self.s = Signal(np.empty((2, 3, 4, 5)))
        self.s.axes_manager.set_signal_dimension(2)

    def test_unfold_navigation(self):
        s = self.s.deepcopy()
        s.unfold_navigation_space()
        nt.assert_equal(s.axes_manager.navigation_shape,
                        (self.s.axes_manager.navigation_size,))

    def test_unfold_signal(self):
        s = self.s.deepcopy()
        s.unfold_signal_space()
        nt.assert_equal(s.axes_manager.signal_shape,
                        (self.s.axes_manager.signal_size,))

    def test_unfolded_repr(self):
        self.s.unfold()
        nt.assert_true("unfolded" in repr(self.s))

    def test_unfold_navigation_by_keyword(self):
        s = self.s.deepcopy()
        s.unfold(unfold_navigation=True, unfold_signal=False)
        nt.assert_equal(s.axes_manager.navigation_shape,
                        (self.s.axes_manager.navigation_size,))

    def test_unfold_signal_by_keyword(self):
        s = self.s.deepcopy()
        s.unfold(unfold_navigation=False, unfold_signal=True)
        nt.assert_equal(s.axes_manager.signal_shape,
                        (self.s.axes_manager.signal_size,))

    def test_unfold_nothing_by_keyword(self):
        s = self.s.deepcopy()
        s.unfold(unfold_navigation=False, unfold_signal=False)
        nt.assert_equal(s.data.shape, self.s.data.shape)

    def test_unfold_full_by_keyword(self):
        s = self.s.deepcopy()
        s.unfold(unfold_navigation=True, unfold_signal=True)
        nt.assert_equal(s.axes_manager.signal_shape,
                        (self.s.axes_manager.signal_size,))
        nt.assert_equal(s.axes_manager.navigation_shape,
                        (self.s.axes_manager.navigation_size,))

    def test_unfolded_context_manager(self):
        s = self.s.deepcopy()
        with s.unfolded():
            # Check that both spaces unfold as expected
            nt.assert_equal(s.axes_manager.navigation_shape,
                            (self.s.axes_manager.navigation_size,))
            nt.assert_equal(s.axes_manager.signal_shape,
                            (self.s.axes_manager.signal_size,))
        # Check that it folds back as expected
        nt.assert_equal(s.axes_manager.navigation_shape,
                        self.s.axes_manager.navigation_shape)
        nt.assert_equal(s.axes_manager.signal_shape,
                        self.s.axes_manager.signal_shape)

    def test_unfolded_full_by_keywords(self):
        s = self.s.deepcopy()
        with s.unfolded(unfold_navigation=True, unfold_signal=True) as folded:
            nt.assert_true(folded)
            # Check that both spaces unfold as expected
            nt.assert_equal(s.axes_manager.navigation_shape,
                            (self.s.axes_manager.navigation_size,))
            nt.assert_equal(s.axes_manager.signal_shape,
                            (self.s.axes_manager.signal_size,))
        # Check that it folds back as expected
        nt.assert_equal(s.axes_manager.navigation_shape,
                        self.s.axes_manager.navigation_shape)
        nt.assert_equal(s.axes_manager.signal_shape,
                        self.s.axes_manager.signal_shape)

    def test_unfolded_navigation_by_keyword(self):
        s = self.s.deepcopy()
        with s.unfolded(unfold_navigation=True, unfold_signal=False) as folded:
            nt.assert_true(folded)
            # Check that only navigation space unfolded
            nt.assert_equal(s.axes_manager.navigation_shape,
                            (self.s.axes_manager.navigation_size,))
            nt.assert_equal(s.axes_manager.signal_shape,
                            self.s.axes_manager.signal_shape)
        # Check that it folds back as expected
        nt.assert_equal(s.axes_manager.navigation_shape,
                        self.s.axes_manager.navigation_shape)
        nt.assert_equal(s.axes_manager.signal_shape,
                        self.s.axes_manager.signal_shape)

    def test_unfolded_signal_by_keyword(self):
        s = self.s.deepcopy()
        with s.unfolded(unfold_navigation=False, unfold_signal=True) as folded:
            nt.assert_true(folded)
            # Check that only signal space unfolded
            nt.assert_equal(s.axes_manager.navigation_shape,
                            self.s.axes_manager.navigation_shape)
            nt.assert_equal(s.axes_manager.signal_shape,
                            (self.s.axes_manager.signal_size,))
#.........这里部分代码省略.........
开发者ID:jerevon,项目名称:hyperspy,代码行数:103,代码来源:test_folding.py


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