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


Python Quantity._collect_factor_and_dimension方法代码示例

本文整理汇总了Python中sympy.physics.units.quantities.Quantity._collect_factor_and_dimension方法的典型用法代码示例。如果您正苦于以下问题:Python Quantity._collect_factor_and_dimension方法的具体用法?Python Quantity._collect_factor_and_dimension怎么用?Python Quantity._collect_factor_and_dimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.physics.units.quantities.Quantity的用法示例。


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

示例1: test_factor_and_dimension

# 需要导入模块: from sympy.physics.units.quantities import Quantity [as 别名]
# 或者: from sympy.physics.units.quantities.Quantity import _collect_factor_and_dimension [as 别名]
def test_factor_and_dimension():
    assert (3000, Dimension(1)) == Quantity._collect_factor_and_dimension(3000)
    assert (1001, length) == Quantity._collect_factor_and_dimension(meter + km)
    assert (2, length/time) == Quantity._collect_factor_and_dimension(
        meter/second + 36*km/(10*hour))

    x, y = symbols('x y')
    assert (x + y/100, length) == Quantity._collect_factor_and_dimension(
        x*m + y*centimeter)

    cH = Quantity('cH', amount_of_substance/volume)
    pH = -log(cH)

    assert (1, volume/amount_of_substance) == Quantity._collect_factor_and_dimension(
        exp(pH))

    v_w1 = Quantity('v_w1', length/time, S(3)/2*meter/second)
    v_w2 = Quantity('v_w2', length/time, 2*meter/second)
    expr = Abs(v_w1/2 - v_w2)
    assert (S(5)/4, length/time) == \
        Quantity._collect_factor_and_dimension(expr)

    expr = S(5)/2*second/meter*v_w1 - 3000
    assert (-(2996 + S(1)/4), Dimension(1)) == \
        Quantity._collect_factor_and_dimension(expr)

    expr = v_w1**(v_w2/v_w1)
    assert ((S(3)/2)**(S(4)/3), (length/time)**(S(4)/3)) == \
        Quantity._collect_factor_and_dimension(expr)
开发者ID:josephwillard,项目名称:sympy,代码行数:31,代码来源:test_quantities.py

示例2: test_dimensional_expr_of_derivative

# 需要导入模块: from sympy.physics.units.quantities import Quantity [as 别名]
# 或者: from sympy.physics.units.quantities.Quantity import _collect_factor_and_dimension [as 别名]
def test_dimensional_expr_of_derivative():
    l = Quantity('l', length, 36 * km)
    t = Quantity('t', time, hour)
    t1 = Quantity('t1', time, second)
    x = Symbol('x')
    y = Symbol('y')
    f = Function('f')
    dfdx = f(x, y).diff(x, y)
    dl_dt = dfdx.subs({f(x, y): l, x: t, y: t1})
    assert Quantity.get_dimensional_expr(dl_dt) ==\
        Quantity.get_dimensional_expr(l / t / t1) ==\
        Symbol("length")/Symbol("time")**2
    assert Quantity._collect_factor_and_dimension(dl_dt) ==\
        Quantity._collect_factor_and_dimension(l / t / t1) ==\
        (10, length/time**2)
开发者ID:josephwillard,项目名称:sympy,代码行数:17,代码来源:test_quantities.py

示例3: dim_simplify

# 需要导入模块: from sympy.physics.units.quantities import Quantity [as 别名]
# 或者: from sympy.physics.units.quantities.Quantity import _collect_factor_and_dimension [as 别名]
def dim_simplify(expr):
    """
    NOTE: this function could be deprecated in the future.

    Simplify expression by recursively evaluating the dimension arguments.

    This function proceeds to a very rough dimensional analysis. It tries to
    simplify expression with dimensions, and it deletes all what multiplies a
    dimension without being a dimension. This is necessary to avoid strange
    behavior when Add(L, L) be transformed into Mul(2, L).
    """
    _, expr = Quantity._collect_factor_and_dimension(expr)
    return expr
开发者ID:sixpearls,项目名称:sympy,代码行数:15,代码来源:util.py

示例4: dim_simplify

# 需要导入模块: from sympy.physics.units.quantities import Quantity [as 别名]
# 或者: from sympy.physics.units.quantities.Quantity import _collect_factor_and_dimension [as 别名]
def dim_simplify(expr):
    """
    NOTE: this function could be deprecated in the future.

    Simplify expression by recursively evaluating the dimension arguments.

    This function proceeds to a very rough dimensional analysis. It tries to
    simplify expression with dimensions, and it deletes all what multiplies a
    dimension without being a dimension. This is necessary to avoid strange
    behavior when Add(L, L) be transformed into Mul(2, L).
    """
    SymPyDeprecationWarning(
        deprecated_since_version="1.2",
        feature="dimensional simplification function",
        issue=13336,
        useinstead="don't use",
    ).warn()
    _, expr = Quantity._collect_factor_and_dimension(expr)
    return expr
开发者ID:bjodah,项目名称:sympy,代码行数:21,代码来源:util.py

示例5: test_factor_and_dimension_with_Abs

# 需要导入模块: from sympy.physics.units.quantities import Quantity [as 别名]
# 或者: from sympy.physics.units.quantities.Quantity import _collect_factor_and_dimension [as 别名]
def test_factor_and_dimension_with_Abs():
    v_w1 = Quantity('v_w1', length/time, S(3)/2*meter/second)
    expr = v_w1 - Abs(v_w1)
    assert (0, lenth/time) == Quantity._collect_factor_and_dimension(expr)
开发者ID:josephwillard,项目名称:sympy,代码行数:6,代码来源:test_quantities.py


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