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


Python tools.assert_sequence_equal函数代码示例

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


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

示例1: test_manual_add_line

 def test_manual_add_line(self):
     s = self.signal
     s.add_xray_lines_markers(["Zn_La"])
     nt.assert_sequence_equal(list(s._xray_markers.keys()), ["Zn_La"])
     nt.assert_equal(len(s._xray_markers), 1)
     # Check that the line has both a vertical line marker and text marker:
     nt.assert_equal(len(s._xray_markers["Zn_La"]), 2)
开发者ID:k8macarthur,项目名称:hyperspy,代码行数:7,代码来源:test_eds_tem.py

示例2: test_plot_auto_add

 def test_plot_auto_add(self):
     s = self.signal
     s.plot(xray_lines=True)
     # Should contain 6 lines
     nt.assert_sequence_equal(
         sorted(s._xray_markers.keys()),
         ['Al_Ka', 'Al_Kb', 'Zn_Ka', 'Zn_Kb', 'Zn_La', 'Zn_Lb1'])
开发者ID:jhemmelg,项目名称:hyperspy,代码行数:7,代码来源:test_eds_tem.py

示例3: test_group_name_multiple_ports

 def test_group_name_multiple_ports(self):
     expected = [
         Rule(protocol="tcp", from_port=22,   to_port=22,   security_group_name="default"),
         Rule(protocol="tcp", from_port=2812, to_port=2812, security_group_name="default"),
         Rule(protocol="tcp", from_port=4001, to_port=4001, security_group_name="default"),
     ]
     assert_sequence_equal(expected, RuleParser.parse("tcp port 22, 2812, 4001 default"))
开发者ID:richchang0,项目名称:dalton,代码行数:7,代码来源:test_rule_parser.py

示例4: test_manual_remove_element

 def test_manual_remove_element(self):
     s = self.signal
     s.add_xray_lines_markers(['Zn_Ka', 'Zn_Kb', 'Zn_La'])
     s.remove_xray_lines_markers(['Zn_Kb'])
     nt.assert_sequence_equal(
         sorted(s._xray_markers.keys()),
         ['Zn_Ka', 'Zn_La'])
开发者ID:jhemmelg,项目名称:hyperspy,代码行数:7,代码来源:test_eds_tem.py

示例5: test_NMF_complex

def test_NMF_complex():
    n_samples = 10
    n_features = 20
    n_components = 3

    W = randn_complex(n_samples, n_components)
    H = np.random.rand(n_components, n_features) + 0j

    # Normalise H
    Hnorm = np.linalg.norm(H, axis=1)
    H /= Hnorm[:, None]

    # Normalise W then order
    Wnorm = np.linalg.norm(W, axis=0)
    W *= np.arange(n_components, 0, -1) / Wnorm

    X = np.dot(W, H)

    p = nmf.PinvNMF(n_components, nmf.ComplexMFConstraint(), max_iter=1000,
                    initialiser=nmf.NMR_svd_initialise)
    Wcalc = p.fit_transform(X)
    Hcalc = p.components_
    Xcalc = np.dot(Wcalc, Hcalc)

    # Check properties of Hcalc and Wcalc
    assert_sequence_equal(Wcalc.shape, (n_samples, n_components))
    assert_sequence_equal(Hcalc.shape, (n_components, n_features))
    assert_array_less(MAX_NEGATIVE_FLOAT, Hcalc.real)  # Hcalc >= 0
    assert_array_equal(0, Hcalc.imag)  # Hcalc >= 0
    # Check that Hcalc is normalised
    assert_array_almost_equal(np.linalg.norm(Hcalc, axis=1), 1)
    # N.B. Hcalc is not orthogonal so can't assert H.H' == I

    assert_array_almost_equal(X, Xcalc, decimal=3)
开发者ID:chatcannon,项目名称:nmrpca,代码行数:34,代码来源:test_nmf.py

示例6: test_NMF_real_normalised

def test_NMF_real_normalised():
    n_samples = 10
    n_features = 20
    n_components = 3

    W = np.random.rand(n_samples, n_components)
    H = np.random.rand(n_components, n_features)

    # Normalise H
    Hnorm = np.linalg.norm(H, axis=1)
    H /= Hnorm[:, None]

    # Normalise U then order
    Wnorm = np.linalg.norm(W, axis=0)
    W *= np.arange(n_components, 0, -1) / Wnorm

    X = np.dot(W, H)
    assert_array_less(0, X)  # X is strictly greater than 0

    p = nmf.ProjectedGradientNMF(n_components, nmf.NMFConstraint_NormaliseH(),
                                 max_iter=1000)
    Wcalc = p.fit_transform(X)
    Hcalc = p.components_
    Xcalc = np.dot(Wcalc, Hcalc)

    # Check properties of Hcalc and Wcalc
    assert_sequence_equal(Wcalc.shape, (n_samples, n_components))
    assert_sequence_equal(Hcalc.shape, (n_components, n_features))
    assert_array_less(MAX_NEGATIVE_FLOAT, Wcalc)  # Wcalc >= 0
    assert_array_less(MAX_NEGATIVE_FLOAT, Hcalc)  # Hcalc >= 0
    # Check that Hcalc is normalised
    assert_array_almost_equal(np.linalg.norm(Hcalc, axis=1), 1)
    # N.B. Hcalc is not orthogonal so can't assert H.H' == I

    assert_array_almost_equal(X, Xcalc, decimal=3)
开发者ID:chatcannon,项目名称:nmrpca,代码行数:35,代码来源:test_nmf.py

示例7: test_NMF_real

def test_NMF_real():
    n_samples = 10
    n_features = 20
    n_components = 3

    W = np.random.rand(n_samples, n_components)
    H = np.random.rand(n_components, n_features)

    # Normalise H
    Hnorm = np.linalg.norm(H, axis=1)
    H /= Hnorm[:, None]

    # Normalise U then order
    Wnorm = np.linalg.norm(W, axis=0)
    W *= np.arange(n_components, 0, -1) / Wnorm

    X = np.dot(W, H)
    assert_array_less(0, X)  # X is strictly greater than 0

    p = nmf.NMF(n_components, tol=1e-5, max_iter=1000)
    Wcalc = p.fit_transform(X)
    Hcalc = p.components_
    Xcalc = np.dot(Wcalc, Hcalc)

    # Check properties of Hcalc and Wcalc
    assert_sequence_equal(Wcalc.shape, (n_samples, n_components))
    assert_sequence_equal(Hcalc.shape, (n_components, n_features))
    assert_array_less(MAX_NEGATIVE_FLOAT, Wcalc)  # Wcalc >= 0
    assert_array_less(MAX_NEGATIVE_FLOAT, Hcalc)  # Hcalc >= 0

    assert_array_almost_equal(X, Xcalc, decimal=3)
开发者ID:chatcannon,项目名称:nmrpca,代码行数:31,代码来源:test_nmf.py

示例8: test_icmp

 def test_icmp(self):
     expected = [
         Rule(protocol="icmp", from_port=0,  to_port=0,  security_group_name="default"),
         Rule(protocol="icmp", from_port=3,  to_port=5,  security_group_name="default"),
         Rule(protocol="icmp", from_port=8,  to_port=14, security_group_name="default"),
         Rule(protocol="icmp", from_port=40, to_port=40, security_group_name="default")
     ]
     assert_sequence_equal(expected, RuleParser.parse("icmp port 0, 3-5, 8-14, 40 default"))
开发者ID:richchang0,项目名称:dalton,代码行数:8,代码来源:test_rule_parser.py

示例9: check_signal

def check_signal(data, signal):
    assert_equals(signal.units, data.units)
    assert_sequence_equal(signal.shape, data.shape)
    assert_true(np.all(np.asarray(signal) == np.asarray(data)))
    try:
        assert_equals(signal.sampling_rate, data.sampling_rates[0])
    except AttributeError:
        pass
开发者ID:physion,项目名称:ovation-neo-importer,代码行数:8,代码来源:test_axon_mapping.py

示例10: testEventsList

def testEventsList():
    assert_sequence_equal(
            map(lambda x: (x['name'], x['status']), form.Event.get_events_list()),
            [('testEventsList2', 1), ('testEventsList1', 0),
                ('testEventsList0', -1)])

    assert_sequence_equal(
            map(lambda x: x['name'], form.Event.get_events_list(2, 1)),
            ['testEventsList0'])
开发者ID:wodesuck,项目名称:mstcweb,代码行数:9,代码来源:test_form.py

示例11: check_correct

def check_correct(expected, actual):
    assert expected.viewkeys() <= actual.viewkeys(), 'Different keys\nexpected\t{}\nactual\t{}'.format(sorted(expected.keys()), sorted(actual.keys()))
    for k in expected:
        exp = expected[k]
        act = actual[k]
        if hasattr(exp, '__iter__') and not hasattr(exp, 'items'):
            assert_sequence_equal(exp, act, 'Different on key "{}".\nexpected\t{}\nactual\t{}'.format(k, exp, act))
        else:
            assert exp == act, 'Different on key "{}".\nexpected\t{}\nactual\t{}'.format(k, exp, act)
    return True
开发者ID:IsaacHaze,项目名称:neleval,代码行数:10,代码来源:test.py

示例12: test_geolocate_pass

def test_geolocate_pass():
    with open(os.path.join(os.path.dirname(__file__), 'fixtures', 'random_coordinate_pairs.yaml')) as fixtures_file:
        fixtures = yaml.load(fixtures_file)
        for fixture in fixtures:
            test_name = fixture['start_nom']
            test_location = fixture.pop('start_loc')
            return_geocoder = [geopy.Location(test_name, test_location)]
            with mock.patch('geopy.geocoders.GoogleV3.geocode') as mock_geocoder:
                mock_geocoder.return_value = return_geocoder
                given_loc = Greengraph('first', 'second').geolocate(test_name)
                mock_geocoder.assert_any_call(test_name, exactly_one=False)
                assert_sequence_equal(test_location, given_loc)
开发者ID:jdfoster,项目名称:greengraph,代码行数:12,代码来源:test_greengraph.py

示例13: test_stdin_nonicks

    def test_stdin_nonicks(self):
        command = loadscores.Command()
        command.stdin = StringIO(INPUT)
        self.execute(command, include_nicknames=False)

        tools.eq_(command.stdout.read(), "Header is:\n\t{}\n".format(HEADER))
        tools.eq_(command.stderr.read(), "")

        tools.assert_sequence_equal(sorted(fulldocs(StateNameVoter.items.all())), [
            {'state_lname_fname': 'NH_BULLWINKLE_BORIS',
             'gotv_score': Decimal('-0.009')},
            {'state_lname_fname': 'NH_BEARINGTON_JAMES',
             'gotv_score': Decimal('-0.1'),
             'persuasion_score': Decimal('4.8')},
            {'state_lname_fname': 'NH_BEARINGTON_JOHN',
             'gotv_score': Decimal('-0.007'),
             'persuasion_score': Decimal('4.61')},
            {'state_lname_fname': 'NH_ZIP_JOE',
             'persuasion_score': Decimal('0'),
             'gotv_score': Decimal('0')},
            {'state_lname_fname': 'MN_STANTON_JANE',
             'gotv_score': Decimal('0.003'),
             'persuasion_score': Decimal('4.1')},
            {'state_lname_fname': 'NH_ZIP_JOSEPH',
             'persuasion_score': Decimal('3.1'),
             'gotv_score': Decimal('0.2')},
        ])

        tools.assert_sequence_equal(sorted(fulldocs(StateCityNameVoter.items.all())), [
            {'state_city_lname_fname': 'NH_SEABROOK_BULLWINKLE_BORIS',
             'gotv_score': Decimal('-0.009')},
            {'state_city_lname_fname': 'NH_ST-PAUL_BEARINGTON_JAMES',
             'gotv_score': Decimal('-0.1'),
             'persuasion_score': Decimal('4.8')},
            {'state_city_lname_fname': 'NH_MILTON_BEARINGTON_JOHN',
             'gotv_score': Decimal('-0.007'),
             'persuasion_score': Decimal('4.61')},
            {'state_city_lname_fname': 'NH_LEBANON_ZIP_JOE',
             'persuasion_score': Decimal('0'),
             'gotv_score': Decimal('0')},
            {'state_city_lname_fname': 'MN_ST-PAUL_STANTON_JANE',
             'gotv_score': Decimal('0.003'),
             'persuasion_score': Decimal('4.88')},
            {'state_city_lname_fname': 'MN_BLAINE_STANTON_JANE',
             'gotv_score': Decimal('0.005'),
             'persuasion_score': Decimal('4.1')},
            {'state_city_lname_fname': 'NH_LEBANON_ZIP_JOSEPH',
             'persuasion_score': Decimal('3.1'),
             'gotv_score': Decimal('0.2')},
        ])
开发者ID:edgeflip,项目名称:edgeflip,代码行数:50,代码来源:test_loadscores.py

示例14: test_pandas_iterable

def test_pandas_iterable():
    try:
        import pandas as pd
    except ImportError:
        raise SkipTest("Pandas not installed")

    # Using a list or series yields equivalent
    # color maps, i.e the series isn't seen as
    # a single color
    lst = ['red', 'blue', 'green']
    s = pd.Series(lst)
    cm1 = mcolors.ListedColormap(lst, N=5)
    cm2 = mcolors.ListedColormap(s, N=5)
    assert_sequence_equal(cm1.colors, cm2.colors)
开发者ID:ChenchenYo,项目名称:matplotlib,代码行数:14,代码来源:test_colors.py

示例15: test_PCA_complex

def test_PCA_complex():
    n_samples = 10
    n_features = 20
    n_components = 3

    U = randn_complex(n_samples, n_components)
    V = randn_complex(n_components, n_features)

    # Make V orthonormal
    for i in range(n_components):
        for j in range(i):
            i_dot_j = np.dot(V[i, :], V[j, :])
            # N.B. V_j is already normalised
            V[i, :] -= i_dot_j * V[j, :]
        Vmean = np.mean(V[i, :])
        V[i, :] -= Vmean
        Vnorm = np.linalg.norm(V[i, :])
        V[i, :] /= Vnorm

    # Make U orthonormal, then multiply to get ordering of components
    for i in range(n_components):
        for j in range(i):
            i_dot_j = np.dot(U[:, i], U[:, j])
            # N.B. U_j is already normalised
            U[:, i] -= i_dot_j * U[:, j]
        Umean = np.mean(U[:, i])
        U[:, i] -= Umean
        Unorm = np.linalg.norm(U[:, i])
        U[:, i] /= Unorm
        # ensure ordering
        U[:, i] *= (n_components - i)

    X = np.dot(U, V)
    assert_almost_equal(0, np.mean(X))

    p = pca.PCA(n_components)
    Ucalc = p.fit_transform(X)
    Vcalc = p.components_
    Xcalc = np.dot(Ucalc, Vcalc)

    # Check properties of Vcalc and Ucalc
    assert_sequence_equal(Ucalc.shape, U.shape)
    assert_sequence_equal(Vcalc.shape, V.shape)
    assert_array_almost_equal(np.eye(n_components),
                              np.dot(Vcalc, np.conj(Vcalc.T)))
    assert_almost_diagonal(np.dot(np.conj(Ucalc.T), Ucalc), assert_real=True)
#    assert_array_almost_equal(np.diag(np.arange(n_components, 0, -1) ** 2),
#                              np.dot(Ucalc.T, Ucalc))

    assert_array_almost_equal(X, Xcalc)
开发者ID:chatcannon,项目名称:nmrpca,代码行数:50,代码来源:test_pca.py


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