當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。