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

Python base.runmodule函数代码示例

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

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



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

示例1: xrange

        for g in self.grids:
            for d in xrange(g.dim):
                os, ps = g.reference_element(d).quadrature_info()
                for t in os.keys():
                    for o, p in izip(os[t], ps[t]):
                        self.assertEqual(
                            g.quadrature_points(d, order=o, quadrature_type=t).shape, (g.size(d), p, g.dim_outer)
                        )
                        self.assertEqual(
                            g.quadrature_points(d, npoints=p, quadrature_type=t).shape, (g.size(d), p, g.dim_outer)
                        )

    def test_quadrature_points_values(self):
        for g in self.grids:
            for d in xrange(g.dim):
                A, B = g.embeddings(d)
                os, ps = g.reference_element(d).quadrature_info()
                for t in os.keys():
                    for o, p in izip(os[t], ps[t]):
                        Q = g.quadrature_points(d, order=o, quadrature_type=t)
                        q, _ = g.reference_element(d).quadrature(order=o, quadrature_type=t)
                        np.testing.assert_allclose(Q, g.quadrature_points(d, npoints=p, quadrature_type=t))
                        np.testing.assert_allclose(Q, B[:, np.newaxis, :] + np.einsum("eij,qj->eqi", A, q))


# this needs to go into every module that wants to use dynamically generated types, ie. testcases, below the test code
from pymor.core.dynamic import *

if __name__ == "__main__":
    runmodule(name="pymortests.grid")
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:30,代码来源:grid.py


示例2: project

# This file is part of the pyMOR project (http://www.pymor.org).
# Copyright 2013-2019 pyMOR developers and contributors. All rights reserved.
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
from pymortests.base import runmodule
from pymortests.fixtures.analyticalproblem import analytical_problem, picklable_analytical_problem
from pymortests.pickling import assert_picklable, assert_picklable_without_dumps_function


def test_pickle(analytical_problem):
    assert_picklable(analytical_problem)


def test_pickle_without_dumps_function(picklable_analytical_problem):
    assert_picklable_without_dumps_function(picklable_analytical_problem)

if __name__ == "__main__":
    runmodule(filename=__file__)
开发者ID:pymor,项目名称:pymor,代码行数:17,代码来源:analyticalproblem.py


示例3: project

# This file is part of the pyMor project (http://www.pymor.org).
# Copyright Holders: Felix Albrecht, Rene Milk, Stephan Rave
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

from __future__ import absolute_import, division, print_function

from pymor.core import defaults
from pymortests.base import TestBase, runmodule


class DefaultsTest(TestBase):

    def testStr(self):
        rep = str(defaults)
        self.assertGreater(len(rep), 0)

if __name__ == "__main__":
    runmodule(name='pymortests.core.defaults')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:18,代码来源:defaults.py


示例4: import

from pymortests.base import (TestBase, runmodule, SubclassForImplemetorsOf)
from pymor import core


@SubclassForImplemetorsOf(BasicInterface)
class PickleMeInterface(TestBase):

    def testDump(self):
        try:
            obj = self.Type()
            self.assertIsInstance(obj, self.Type)
            if issubclass(self.Type, core.Unpicklable):
                return
        except TypeError as e:
            self.logger.debug('PicklingError: Not testing {} because its init failed: {}'.format(self.Type, str(e)))
            return

        with tempfile.NamedTemporaryFile(mode='wb', delete=False) as dump_file:
            core.dump(obj, dump_file)
            dump_file.close()
            f = open(dump_file.name, 'rb')
            unpickled = core.load(f)
            self.assertEqual(obj.__class__, unpickled.__class__)
            os.unlink(dump_file.name)

# this needs to go into every module that wants to use dynamically generated types, ie. testcases, below the test code
from pymor.core.dynamic import *

if __name__ == "__main__":
    runmodule(name='pymortests.core.pickling')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:30,代码来源:pickling.py


示例5: open

                dump_file.close()
                f = open(dump_file.name, 'rb')
                unpickled = pymor.core.load(f)
                self.assert_(getattr(obj, attribute_name) == getattr(unpickled, attribute_name))
                os.unlink(dump_file.name)
        picklme(AverageImplementer(), 'some_attribute')
        picklme(CacheImplementer(), 'some_attribute')
        picklme(RectGrid(num_intervals=(4, 4)), 'num_intervals')

    def testDeprecated(self):
        @decorators.Deprecated('use other stuff instead')
        def deprecated_function():
            pass
        # Cause all warnings to always be triggered.
        import warnings
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            # Trigger a warning.
            deprecated_function()
            # Verify some things
            self.assertEqual(len(w), 1)
            self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
            self.assertTrue("DeprecationWarning" in str(w[-1].message))

    def testVersion(self):
        self.assertGreater(pymor.version, pymor.NO_VERSION)
        self.assertIsInstance(pymor.version, tuple)

if __name__ == "__main__":
    runmodule(name='pymortests.core.interface')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:30,代码来源:interface.py


示例6: TestCubicParameterspace

from __future__ import absolute_import, division, print_function

from pymor import parameters
from pymortests.base import TestBase, runmodule


class TestCubicParameterspace(TestBase):

    def setUp(self):
        TestBase.setUp(self)
        self.space = parameters.CubicParameterSpace({'diffusionl': 1}, 0.1, 1)
        self.samples = 100

    def _check_values(self, values):
        self.assertEqual(len(values), self.samples)
        for value in values:
            self.assertTrue(self.space.contains(value))

    def test_uniform(self):
        values = list(self.space.sample_uniformly(self.samples))
        self._check_values(values)

    def test_randomly(self):
        values = list(self.space.sample_randomly(self.samples))
        self._check_values(values)


if __name__ == "__main__":
    runmodule(name='pymortests.parameters')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:29,代码来源:parameters.py


示例7: test_disabled_contracts

            grid = mock.Mock()
            inst.validate_interface(object(), pymor.grids.boundaryinfos.AllDirichletBoundaryInfo(grid))

    def test_disabled_contracts(self):
        contracts.disable_all()

        @contract
        def disabled(phrase):
            '''
            :type phrase: str
            '''
            return phrase
        # this should not throw w/ contracts disabled
        disabled(int(8))
        contracts.enable_all()
        # this will still not throw because the disabled value is checked at decoration time only
        disabled(int(8))

        @contract
        def enabled(phrase):
            '''
            :type phrase: str
            '''
            return phrase
        # a newly decorated function will throw
        with self.assertRaises(exceptions.ContractNotRespected):
            enabled(int(8))

if __name__ == "__main__":
    runmodule(name='pymortests.core.contract')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:30,代码来源:contract.py


示例8: project

# This file is part of the pyMor project (http://www.pymor.org).
# Copyright Holders: Felix Albrecht, Rene Milk, Stephan Rave
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

from __future__ import absolute_import, division, print_function

import numpy as np
import random
from math import sin, exp

from pymortests.base import TestBase, runmodule
from pymor.playground.expression_function import ExpressionFunction

FUNCTIONS = [(ExpressionFunction(['x**2'], 'x'), lambda x: np.array([x ** 2])),
             (ExpressionFunction(['x**2', 'sin(x)'], 'x'), lambda x: np.array([x ** 2, sin(x)])),
             (ExpressionFunction(['exp(xp)'], 'xp'), lambda x: np.array([exp(x)]))]


class TestExpressionFunction(TestBase):

    def test_eval(self):
        for (fn, fe) in FUNCTIONS:
            for x in (random.uniform(0, 1) for _ in xrange(9000)):
                np.testing.assert_array_almost_equal(fn([x]), fe(x))


if __name__ == "__main__":
    random.seed()
    runmodule(name='pymortests.playground')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:29,代码来源:playground.py


示例9: test_limit

                self.logger.info(int1 - int0)

    def test_limit(self):
        for c in [IamLimitedCached(cache.SMALL_MEMORY_CONFIG),
                  IamLimitedCached(cache.SMALL_DISK_CONFIG)]:
            for i in range(25):
                c.cache_region.backend.print_limit()
                _ = c.me_takey_no_time(i)
                c.cache_region.backend.print_limit()

    def test_copy(self):
        from copy import copy
        x = IWillBeCopied()
        x_id = x.my_id(1)
        y = copy(x)
        y_id = y.my_id(1)
        self.assertNotEqual(x_id, y_id)

    def test_backend_api(self):
        for backend_cls in [cache.LimitedFileBackend, cache.LimitedMemoryBackend, cache.DummyBackend]:
            backend = backend_cls({})
            self.assertEqual(backend.get('mykey'), cache.NO_VALUE)
            backend.set('mykey', 1)
            self.assertEqual(backend.get('mykey'), 1 if backend_cls != cache.DummyBackend else cache.NO_VALUE)
            backend.delete('mykey')
            self.assertEqual(backend.get('mykey'), cache.NO_VALUE)


if __name__ == "__main__":
    runmodule(name='pymortests.core.cache')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:30,代码来源:cache.py


示例10: exercise_logger

    exercise_logger(logger)


def logclass(cls):
    logger = cls.logger
    exercise_logger(logger)


def test_logger():
    import pymor

    fails = []
    for importer, pack_name, _ in pkgutil.walk_packages(
        pymor.__path__, pymor.__name__ + ".", lambda n: fails.append(n)
    ):
        yield logmodule, pack_name
        try:
            importer.find_module(pack_name).load_module(pack_name)
        except TypeError, e:
            fails.append(pack_name)
    import pprint

    if len(fails):
        core.getLogger(__name__).error("Failed imports: {}".format(pprint.pformat(set(fails))))
    for cls in pymor.core.interfaces.BasicInterface.implementors(True):
        yield logclass, cls


if __name__ == "__main__":
    runmodule(name="pymortests.core.logger")
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:30,代码来源:logger.py


示例11: CmpTest

        self.assertFalse(True, "test is missing")


class CmpTest(TestBase):

    def test_props(self):
        tol_range = [None, 0.0, 1]
        nan = float('nan')
        inf = float('inf')
        for (rtol, atol) in itertools.product(tol_range, tol_range):
            msg = 'rtol: {} | atol {}'.format(rtol, atol)
            self.assertTrue(float_cmp(0, 0, rtol, atol), msg)
            self.assertTrue(float_cmp(-0, -0, rtol, atol), msg)
            self.assertTrue(float_cmp(-1, -1, rtol, atol), msg)
            self.assertTrue(float_cmp(0, -0, rtol, atol), msg)
            self.assertFalse(float_cmp(2, -2, rtol, atol), msg)

            self.assertFalse(float_cmp(nan, nan, rtol, atol), msg)
            self.assertTrue(nan != nan)
            self.assertFalse(nan == nan)
            self.assertFalse(float_cmp(-nan, nan, rtol, atol), msg)

            self.assertFalse(float_cmp(inf, inf, rtol, atol), msg)
            self.assertFalse(inf != inf)
            self.assertTrue(inf == inf)
            self.assertTrue(float_cmp(-inf, inf, rtol, atol), msg)


if __name__ == "__main__":
    runmodule(name='pymortests.tools')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:30,代码来源:tools.py


示例12: test_quadrature_points_shape

                        g.quadrature_points(d, npoints=max(ps[t]) + 1, quadrature_type=t)

    def test_quadrature_points_shape(self):
        for g in self.grids:
            for d in xrange(g.dim):
                os, ps = g.reference_element(d).quadrature_info()
                for t in os.keys():
                    for o, p in izip(os[t], ps[t]):
                        self.assertEqual(g.quadrature_points(d, order=o, quadrature_type=t).shape,
                                         (g.size(d), p, g.dim_outer))
                        self.assertEqual(g.quadrature_points(d, npoints=p, quadrature_type=t).shape,
                                         (g.size(d), p, g.dim_outer))

    def test_quadrature_points_values(self):
        for g in self.grids:
            for d in xrange(g.dim):
                A, B = g.embeddings(d)
                os, ps = g.reference_element(d).quadrature_info()
                for t in os.keys():
                    for o, p in izip(os[t], ps[t]):
                        Q = g.quadrature_points(d, order=o, quadrature_type=t)
                        q, _ = g.reference_element(d).quadrature(order=o, quadrature_type=t)
                        np.testing.assert_allclose(Q, g.quadrature_points(d, npoints=p, quadrature_type=t))
                        np.testing.assert_allclose(Q, B[:, np.newaxis, :] + np.einsum('eij,qj->eqi', A, q))

# this needs to go into every module that wants to use dynamically generated types, ie. testcases, below the test code
from pymor.core.dynamic import *

if __name__ == "__main__":
    runmodule(name='pymortests.grid')
开发者ID:maltedschumacher,项目名称:pyMor,代码行数:30,代码来源:grid.py


示例13: project

# This file is part of the pyMor project (http://www.pymor.org).
# Copyright Holders: Felix Albrecht, Rene Milk, Stephan Rave
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

from __future__ import absolute_import, division, print_function

from pymortests.base import runmodule


if __name__ == "__main__":
    runmodule(name='pymortests.benchmarks')
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:11,代码来源:benchmarks.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pymouse.PyMouse类代码示例发布时间:2022-05-27
下一篇:
Python pymorphy.get_morph函数代码示例发布时间: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