tensor-sensor

Форк
0
/
test_nested.py 
27 строк · 674.0 Байт
1
# Test for https://github.com/parrt/tensor-sensor/issues/18
2
# Nested clarify's and all catch exception
3

4
import tsensor
5
import numpy as np
6

7
def f():
8
    np.ones(1) @ np.ones(2)
9

10
def A():
11
    with tsensor.clarify():
12
        f()
13

14
def B():
15
    with tsensor.clarify():
16
        A()
17

18
def test_nested():
19
    msg = ""
20
    try:
21
        B()
22
    except BaseException as e:
23
        msg = e.args[0]
24

25
    expected = "matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 1)\n"+\
26
               "Cause: @ on tensor operand np.ones(1) w/shape (1,) and operand np.ones(2) w/shape (2,)"
27
    assert msg==expected
28

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.