test.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:fastmat 作者: EMS-TU-Ilmenau 项目源码 文件源码
def testGram(test):
    instance, reference=test[TEST.INSTANCE], test[TEST.REFERENCE]

    # usually expect the normalized matrix to be promoted in type complexity
    # due to division by column-norm during the process. However there exist
    # matrices that treat the problem differently. Exclude the expected pro-
    # motion for them.
    query=({} if isinstance(instance, (Diag, Eye, Zero))
           else {TEST.TYPE_PROMOTION: np.float32})

    # account for "extra computation stage" in gram
    query[TEST.TOL_POWER]=test.get(TEST.TOL_POWER, 1.) * 2

    query[TEST.RESULT_OUTPUT]=instance.gram.array
    query[TEST.RESULT_REF]=reference.astype(
        np.promote_types(np.float32, reference.dtype)).T.conj().dot(reference)

    # ignore actual type of generated gram:
    query[TEST.CHECK_DATATYPE]=False

    return compareResults(test, query)


################################################## test: T (property)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号