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


Python MutableDenseNDimArray._get_tuple_index方法代码示例

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


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

示例1: test_higher_dimenions

# 需要导入模块: from sympy.tensor.array.dense_ndim_array import MutableDenseNDimArray [as 别名]
# 或者: from sympy.tensor.array.dense_ndim_array.MutableDenseNDimArray import _get_tuple_index [as 别名]
def test_higher_dimenions():
    m3 = MutableDenseNDimArray(range(10, 34), (2, 3, 4))

    assert m3.tolist() == [
        [[10, 11, 12, 13], [14, 15, 16, 17], [18, 19, 20, 21]],
        [[22, 23, 24, 25], [26, 27, 28, 29], [30, 31, 32, 33]],
    ]

    assert m3._get_tuple_index(0) == (0, 0, 0)
    assert m3._get_tuple_index(1) == (0, 0, 1)
    assert m3._get_tuple_index(4) == (0, 1, 0)
    assert m3._get_tuple_index(12) == (1, 0, 0)

    assert (
        str(m3)
        == "[[[10, 11, 12, 13], [14, 15, 16, 17], [18, 19, 20, 21]], [[22, 23, 24, 25], [26, 27, 28, 29], [30, 31, 32, 33]]]"
    )

    m3_rebuilt = MutableDenseNDimArray(
        [[[10, 11, 12, 13], [14, 15, 16, 17], [18, 19, 20, 21]], [[22, 23, 24, 25], [26, 27, 28, 29], [30, 31, 32, 33]]]
    )
    assert m3 == m3_rebuilt

    m3_other = MutableDenseNDimArray(
        [
            [[10, 11, 12, 13], [14, 15, 16, 17], [18, 19, 20, 21]],
            [[22, 23, 24, 25], [26, 27, 28, 29], [30, 31, 32, 33]],
        ],
        (2, 3, 4),
    )

    assert m3 == m3_other
开发者ID:scopatz,项目名称:sympy,代码行数:34,代码来源:test_mutable_ndim_array.py


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