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


Python tools.assert_items_equal函数代码示例

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


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

示例1: test_update

    def test_update(self):
        """
        Tests whether update works.
            - candidate exists in the list
            - result is equal
            - the status message incorrect error works
            - the candidate instance check works
        """
        optimizer = "RandomSearch"
        name = "test_init_experiment"
        param_defs = {
            "x": MinMaxNumericParamDef(0, 1),
            "name": NominalParamDef(["A", "B", "C"])
        }
        minimization = True

        EAss = PrettyExperimentAssistant(name, optimizer, param_defs, minimization=minimization)
        cand = EAss.get_next_candidate()
        cand.result = 1
        EAss.update(cand)
        assert_items_equal(EAss.experiment.candidates_finished, [cand])
        assert_equal(EAss.experiment.candidates_finished[0].result, 1)

        EAss.update(cand, "pausing")
        EAss.update(cand, "working")
        with assert_raises(ValueError):
            EAss.update(cand, status="No status.")

        with assert_raises(ValueError):
            EAss.update(False)
开发者ID:vinodrajendran001,项目名称:apsis,代码行数:30,代码来源:test_experiment_assistant.py

示例2: test_tv_denoise

def test_tv_denoise():
    problem = compiler.compile_problem(cvxpy_expr.convert_problem(
        tv_denoise.create(n=10, lam=1)))
    assert_items_equal(
        prox_ops(problem.objective),
        3*[Prox.SUM_SQUARE] + [Prox.AFFINE] + [Prox.SECOND_ORDER_CONE])
    assert_equal(2, len(problem.constraint))
开发者ID:JeroenSoeters,项目名称:epsilon,代码行数:7,代码来源:compiler_test.py

示例3: test_getslice_lazy

 def test_getslice_lazy(self):
     seq = self.get_sequence([1, 2, 3])
     sliced = seq[:2]
     tools.assert_is_not(sliced, seq)
     tools.assert_items_equal(sliced, [1, 2])
     tools.assert_true(seq.iterable)
     tools.eq_(list(seq._results.__iter__()), [1, 2])
开发者ID:edgeflip,项目名称:faraday,代码行数:7,代码来源:test_structs.py

示例4: test_basis_pursuit

def test_basis_pursuit():
    problem = compiler.compile_problem(cvxpy_expr.convert_problem(
        basis_pursuit.create(m=10, n=30)))
    assert_items_equal(
        prox_ops(problem.objective),
        [Prox.CONSTANT, Prox.NORM_1])
    assert_equal(2, len(problem.constraint))
开发者ID:JeroenSoeters,项目名称:epsilon,代码行数:7,代码来源:compiler_test.py

示例5: check_items_equal

def check_items_equal(actual_value, expected_value, msg=""):
    """
    :param actual_value:
    :param expected_value:
    :param msg:
    :return:

    """
    if isinstance(actual_value, (list, dict, tuple)):
        msg = "\n" + msg + "\n\nDiffering items :\nFirst Argument(Usually Actual) marked with (-)," \
                           "Second Argument(Usually Expected) marked with (+)"
    else:
        msg = "\n" + msg + "\nFirst Argument(Usually Actual), Second Argument(Usually Expected)"

    if not actual_value or not expected_value:
        assert_equal(actual_value, expected_value, u"{}\n{} != {}".format(msg, actual_value, expected_value))

    elif isinstance(actual_value, (list, tuple)):
        assert_items_equal(sorted(actual_value), sorted(expected_value),
                           u"{}\n{}".format(msg, unicode(diff(sorted(actual_value),
                                                          sorted(expected_value)))))
    elif isinstance(actual_value, dict):
        assert_dict_equal(actual_value, expected_value,
                     u"{}\n{}".format(msg, unicode(diff(actual_value, dict(expected_value)))))
    elif isinstance(actual_value, (str, bool)):
        assert_equal(actual_value, expected_value,
                     u"{}\n{} != {}".format(msg, unicode(actual_value), unicode(expected_value)))
    else:
        assert_equal(actual_value, expected_value,
                     u"{}\n{} != {}".format(msg, actual_value, expected_value))
开发者ID:dudycooly,项目名称:python_helpers,代码行数:30,代码来源:asserter.py

示例6: test_mul

 def test_mul(self):
     seq = self.get_sequence([1, 2])
     result = seq * 2
     tools.assert_true(result.iterable)
     tools.assert_true(seq.iterable)
     tools.assert_items_equal(result, [1, 2, 1, 2])
     tools.assert_items_equal(seq, [1, 2])
开发者ID:edgeflip,项目名称:faraday,代码行数:7,代码来源:test_structs.py

示例7: test_load_configuration

 def test_load_configuration(self):
     configuration = self.sim.configuration
     assert_items_equal(configuration.coordinates[0],
                        self.sim.positions)
     assert_equal(configuration.potential_energy,
                  self.sim.pes.V(self.sim))
     assert_equal(configuration.box_vectors, None)
开发者ID:JM-YE,项目名称:openpathsampling,代码行数:7,代码来源:test_toy_dynamics.py

示例8: test_getting_all_contacts_by_last_update

def test_getting_all_contacts_by_last_update():
    with _get_portal_connection() as connection:
        all_contacts = get_all_contacts_by_last_update(connection)
        first_contact = next(all_contacts)
        assert_in('lastmodifieddate', first_contact.properties)

        requested_property_names = ('email',)
        all_contacts = get_all_contacts_by_last_update(
            connection,
            property_names=requested_property_names,
            )
        first_contact = next(all_contacts)
        expected_property_names = \
            ('lastmodifieddate',) + requested_property_names
        assert_items_equal(
            expected_property_names,
            first_contact.properties.keys(),
            )

        contacts_from_future = get_all_contacts_by_last_update(
            connection,
            property_names=requested_property_names,
            cutoff_datetime=datetime.now() + timedelta(days=100),
            )
        eq_([], list(contacts_from_future))
开发者ID:brightinteractive,项目名称:hubspot-contacts,代码行数:25,代码来源:smoke_tests.py

示例9: test_aliases_biblio

 def test_aliases_biblio(self):
     # at the moment this item 
     alias = (u'biblio', {u'title': u'Altmetrics in the wild: Using social media to explore scholarly impact', u'first_author': u'Priem', u'journal': u'arXiv preprint arXiv:1203.4745', u'authors': u'Priem, Piwowar, Hemminger', u'number': u'', u'volume': u'', u'first_page': u'', u'year': u'2012'})
     new_aliases = self.provider.aliases([alias])
     print new_aliases
     expected = [(u'scopus', u'2-s2.0-84904019573'), (u'arxiv', u'1203.4745'), ('url', u'http://www.mendeley.com/research/altmetrics-wild-using-social-media-explore-scholarly-impact'), ('mendeley_uuid', u'dd1ca434-0c00-3d11-8b1f-0226b1d6938c')]
     assert_items_equal(new_aliases, expected)
开发者ID:Impactstory,项目名称:total-impact-webapp,代码行数:7,代码来源:test_mendeley.py

示例10: test_configuration_setter

 def test_configuration_setter(self):
     raise SkipTest()
     # This should not work anymore
     self.sim.configuration = Configuration(
         coordinates=np.array([[1, 2, 3]])
     )
     assert_items_equal(self.sim.positions, [1, 2])
开发者ID:JM-YE,项目名称:openpathsampling,代码行数:7,代码来源:test_toy_dynamics.py

示例11: test_additem_itemexists

 def test_additem_itemexists(self):
     # exact sample is already there
     testset2 = SampleSet([self.s0A, self.s1A, self.s2B])
     self.testset.append(self.s2B)
     self.testset.consistency_check()
     assert_equal(len(self.testset), 3)
     assert_items_equal(self.testset, testset2)
开发者ID:JM-YE,项目名称:openpathsampling,代码行数:7,代码来源:testsample.py

示例12: test_additem

 def test_additem(self):
     testset2 = SampleSet([self.s0A, self.s1A, self.s2B, self.s2B_])
     self.testset.append(self.s2B_)
     assert_equal(self.s2B_ in self.testset, True)
     assert_equal(len(self.testset), 4)
     self.testset.consistency_check()
     assert_items_equal(self.testset, testset2)
开发者ID:JM-YE,项目名称:openpathsampling,代码行数:7,代码来源:testsample.py

示例13: test_setitem_itemexists_replica

 def test_setitem_itemexists_replica(self):
     testset = SampleSet([self.s0A, self.s1A, self.s2B, self.s2B_])
     testset2 = SampleSet([self.s0A, self.s1A, self.s2B, self.s2B_])
     testset[2] = self.s2B
     testset.consistency_check()
     assert_equal(len(testset), 4)
     assert_items_equal(testset, testset2)
开发者ID:JM-YE,项目名称:openpathsampling,代码行数:7,代码来源:testsample.py

示例14: test_collection_post_new_collection

    def test_collection_post_new_collection(self):
        response = self.client.post(
            '/v1/collection' + "?key=validkey",
            data=json.dumps({"aliases": self.aliases, "title":"My Title"}),
            content_type="application/json")

        print response
        print response.data
        assert_equals(response.status_code, 201)  #Created
        assert_equals(response.mimetype, "application/json")
        response_loaded = json.loads(response.data)
        assert_equals(
                set(response_loaded.keys()),
                set(["collection"])
        )
        coll = response_loaded["collection"]
        assert_equals(len(coll["_id"]), 6)
        assert_equals(
            set(coll["alias_tiids"].keys()),
            set([":".join(alias) for alias in self.aliases])
        )

        collection_object = collection.Collection.query.filter_by(cid=coll["_id"]).first()
        assert_items_equal(collection_object.tiids, coll["alias_tiids"].values())
        assert_items_equal([added_item.alias_tuple for added_item in collection_object.added_items], [(unicode(a), unicode(b)) for (a, b) in self.aliases])
开发者ID:dbeucke,项目名称:total-impact-core,代码行数:25,代码来源:test_views.py

示例15: test_read

    def test_read(self):
        _expected_chunk = 10000
        _expected_target = None

        csv_datasource = CSVStreamDataSource(self.in_path, _expected_chunk)
        csv_dataset = csv_datasource.read()

        _expected_header = ['a1', 'a2', 'a3', 'a4', 'target']
        _expected_rows = [[0, 0, 0, 0, 1], [1, 1, 0, 1, 0], [1, 0, 0, 1, 0]]

        _pandas_reader = csv_dataset.reader

        _pandas_df = _pandas_reader.next()

        _header = list(_pandas_df.columns)

        _rows = []
        for index, row in _pandas_df.iterrows():
            _rows.append(list(row))

        assert_equals(csv_datasource.chunk, _expected_chunk)
        assert_equals(csv_datasource.target, _expected_target)

        assert_items_equal(_header, _expected_header)
        assert_items_equal(_rows, _expected_rows)
开发者ID:rsk-mind,项目名称:rsk-mind-framework,代码行数:25,代码来源:test_csv_stream_datasource.py


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