How to use hyperspy - 10 common examples

To help you get started, we’ve selected a few hyperspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyxem / pyxem / tests / test_diffraction_signal.py View on Github external
def test_get_direct_beam_mask(self, diffraction_pattern, center, mask_expected):
        mask_calculated = diffraction_pattern.get_direct_beam_mask(2, center=center)
        assert isinstance(mask_calculated, Signal2D)
        assert np.equal(mask_calculated, mask_expected)
github hyperspy / hyperspy / hyperspy / link_traits / test_link_traits.py View on Github external
a = A(value=9)
        b = B(count=8)

        # Register callbacks that count.
        callback_count = []

        def a_callback(name, old, new):
            callback_count.append('a')
        a.on_trait_change(a_callback, 'value')

        def b_callback(name, old, new):
            callback_count.append('b')
        b.on_trait_change(b_callback, 'count')

        # Connect the two classes.
        c = link((a, 'value'), (b, 'count'))

        # Make sure b's count was set to a's value once.
        assert ''.join(callback_count) == 'b'
        del callback_count[:]

        # Make sure a's value was set to b's count once.
        b.count = 5
        assert ''.join(callback_count) == 'ba'
        del callback_count[:]

        # Make sure b's count was set to a's value once.
        a.value = 4
        assert ''.join(callback_count) == 'ab'
        del callback_count[:]
github hyperspy / hyperspy / test_model.py View on Github external
def test_access_component_by_index(self):
        m = self.model
        g1 = Gaussian()
        g2 = Gaussian()
        g2.name = "test"
        m.extend((g1, g2))
        nose.tools.assert_is(m[1], g2)
github hyperspy / hyperspy / test_model.py View on Github external
    @nose.tools.raises(ValueError)
    def test_get_component_wrong(self):
        m = self.model
        g1 = Gaussian()
        g2 = Gaussian()
        g2.name = "test"
        m.extend((g1, g2))
        m._get_component(1.2)
github hyperspy / hyperspy / test_model.py View on Github external
def test_component_name_when_append(self):
        m = self.model
        gs = [Gaussian(), Gaussian(), Gaussian()]
        m.extend(gs)
        nose.tools.assert_is(m['Gaussian'], gs[0])
        nose.tools.assert_is(m['Gaussian_0'], gs[1])
        nose.tools.assert_is(m['Gaussian_1'], gs[2])
github hyperspy / hyperspy / test_model.py View on Github external
def test_several_component_with_same_name(self):
        m = self.model
        gs = [Gaussian(), Gaussian(), Gaussian()]
        m.extend(gs)
        m[0]._name = "Gaussian"
        m[1]._name = "Gaussian"
        m[2]._name = "Gaussian"
        m['Gaussian']
github hyperspy / hyperspy / test_model.py View on Github external
def test_get_component_by_index(self):
        m = self.model
        g1 = Gaussian()
        g2 = Gaussian()
        g2.name = "test"
        m.extend((g1, g2))
        nose.tools.assert_is(m._get_component(1), g2)
github hyperspy / hyperspy / test_model.py View on Github external
def test_component_already_in_model(self):
        m = self.model
        g1 = Gaussian()
        m.extend((g1, g1))
github hyperspy / hyperspy / test_model.py View on Github external
def test_access_component_by_name(self):
        m = self.model
        g1 = Gaussian()
        g2 = Gaussian()
        g2.name = "test"
        m.extend((g1, g2))
        nose.tools.assert_is(m["test"], g2)
github hyperspy / hyperspy / test_model.py View on Github external
def test_get_component_by_component(self):
        m = self.model
        g1 = Gaussian()
        g2 = Gaussian()
        g2.name = "test"
        m.extend((g1, g2))
        nose.tools.assert_is(m._get_component(g2), g2)