• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tools.assert_sequence_equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_pandas_iterable

def test_pandas_iterable():
    try:
        import pandas as pd
    except ImportError:
        raise SkipTest("Pandas not installed")
    if assert_sequence_equal is None:
        raise SkipTest("nose lacks required function")
    # 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:zaherabdulazeez,项目名称:matplotlib,代码行数:15,代码来源:test_colors.py


示例17: test_compiling_variable_length

    def test_compiling_variable_length(self):
        pulse = Pulse(kind='Logical', def_1='0.1', def_2='0.5',
                      channel='Ch1_M1')
        self.root.items = [pulse]
        self.context.sampling_frequency = 1e8

        res, arrays = self.root.compile_sequence()
        assert_true(res)
        assert_in(1, arrays)

        sequence = np.zeros(100, dtype=np.uint8)
        sequence[1::2] = 2**5
        sequence[21:101:2] += 2**6
        assert_sequence_equal(arrays[1],
                              bytearray(sequence))
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:15,代码来源:test_awg_context.py


示例18: test_compiling_M1_pulse

    def test_compiling_M1_pulse(self):
        self.root.time_constrained = True
        self.root.sequence_duration = '1'
        pulse = Pulse(kind='Logical', def_1='0.1', def_2='0.5',
                      channel='Ch1_M1')
        self.root.items = [pulse]

        res, arrays = self.root.compile_sequence()
        assert_true(res)
        assert_in(1, arrays)

        sequence = np.zeros(2000, dtype=np.uint8)
        sequence[1::2] = 2**5
        sequence[201:1001:2] += 2**6
        assert_sequence_equal(arrays[1],
                              bytearray(sequence))
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:16,代码来源:test_awg_context.py


示例19: test_rowset_asDataFrame__with_ROW_ETAG_column

def test_rowset_asDataFrame__with_ROW_ETAG_column():
    query_result = {
                   'concreteType': 'org.sagebionetworks.repo.model.table.QueryResultBundle',
                   'maxRowsPerPage': 6990,
                   'selectColumns': [
                       {'id': '61770', 'columnType': 'STRING', 'name': 'annotationColumn1'},
                       {'id': '61771', 'columnType': 'STRING', 'name': 'annotationColumn2'}
                   ],
                   'queryCount': 1,
                   'queryResult': {
                       'concreteType': 'org.sagebionetworks.repo.model.table.QueryResult',
                       'nextPageToken': 'sometoken',
                       'queryResults': {
                           'headers': [
                               {'id': '61770', 'columnType': 'STRING', 'name': 'annotationColumn1'},
                               {'id': '61771', 'columnType': 'STRING', 'name': 'annotationColumn2'}],
                           'concreteType': 'org.sagebionetworks.repo.model.table.RowSet',
                           'etag': 'DEFAULT',
                           'tableId': 'syn11363411',
                           'rows': [{'values': ['initial_value1', 'initial_value2'],
                                     'etag': '7de0f326-9ef7-4fde-9e4a-ac0babca73f6',
                                     'rowId': 123,
                                     'versionNumber':456}]
                       }
                   }
                }
    query_result_next_page = {'concreteType': 'org.sagebionetworks.repo.model.table.QueryResult',
                              'queryResults': {
                                  'etag': 'DEFAULT',
                                  'headers': [
                                      {'id': '61770', 'columnType': 'STRING', 'name': 'annotationColumn1'},
                                      {'id': '61771', 'columnType': 'STRING', 'name': 'annotationColumn2'}],
                                  'rows': [{'values': ['initial_value3', 'initial_value4'],
                                            'etag': '7de0f326-9ef7-4fde-9e4a-ac0babca73f7',
                                            'rowId': 789,
                                            'versionNumber': 101112}],
                                  'tableId': 'syn11363411'}}

    with patch.object(syn, "_queryTable", return_value=query_result),\
         patch.object(syn, "_queryTableNext", return_value=query_result_next_page):
        table = syn.tableQuery("select something from syn123", resultsAs='rowset')
        dataframe = table.asDataFrame()
        assert_not_in("ROW_ETAG", dataframe.columns)
        expected_indicies = ['123_456_7de0f326-9ef7-4fde-9e4a-ac0babca73f6',
                             '789_101112_7de0f326-9ef7-4fde-9e4a-ac0babca73f7']
        assert_sequence_equal(expected_indicies, dataframe.index.values.tolist())
开发者ID:Sage-Bionetworks,项目名称:synapsePythonClient,代码行数:46,代码来源:unit_test_tables.py


示例20: test_compiling_A_pulse

    def test_compiling_A_pulse(self):
        self.root.time_constrained = True
        self.root.sequence_duration = '1'
        pulse = Pulse(kind='Analogical', shape=SquareShape(amplitude='1.0'),
                      def_1='0.1', def_2='0.5', channel='Ch1_A')
        self.root.items = [pulse]

        res, arrays = self.root.compile_sequence()
        assert_true(res)
        assert_in(1, arrays)
        assert_equal(len(arrays), 1)

        sequence = np.zeros(2000, dtype=np.uint8)
        sequence[1::2] = 2**5
        sequence[201:1001:2] += 2**4 + 2**3 + 4 + 2 + 1
        sequence[200:1000:2] += 255
        assert_sequence_equal(arrays[1],
                              bytearray(sequence))
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:18,代码来源:test_awg_context.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tools.assert_set_equal函数代码示例发布时间:2022-05-27
下一篇:
Python tools.assert_regexp_matches函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap