Skip to content

Commit

Permalink
Fix casting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wesselb committed Dec 18, 2021
1 parent 27c5655 commit a5b58ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions matrix/ops/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def cast(dtype: B.DType, a: LowerTriangular):
return LowerTriangular(B.cast(dtype, a.mat))


@B.dispatch
def cast(dtype: B.DType, a: UpperTriangular):
return UpperTriangular(B.cast(dtype, a.mat))

Expand Down
20 changes: 10 additions & 10 deletions tests/ops/test_cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,41 @@ def check_casting(x, asserted_type):
check_un_op(lambda x: B.cast(complex, x), x, asserted_type=asserted_type)


def test_dtype_zero(zero1):
def test_cast_zero(zero1):
check_casting(zero1, asserted_type=Zero)


def test_dtype_dense(dense1):
def test_cast_dense(dense1):
check_casting(dense1, asserted_type=Dense)


def test_dtype_diag(diag1):
def test_cast_diag(diag1):
check_casting(diag1, asserted_type=Diagonal)


def test_dtype_const(const1):
def test_cast_const(const1):
check_casting(const1, asserted_type=Constant)


def test_dtype_lt1(lt1):
def test_cast_lt1(lt1):
check_casting(lt1, asserted_type=LowerTriangular)


def test_dtype_ut1(ut1):
def test_cast_ut1(ut1):
check_casting(ut1, asserted_type=UpperTriangular)


def test_dtype_lr(lr1):
def test_cast_lr(lr1):
check_casting(lr1, asserted_type=LowRank)


def test_dtype_wb(wb1):
def test_cast_wb(wb1):
check_casting(wb1, asserted_type=Woodbury)


def test_dtype_kron(kron1):
def test_cast_kron(kron1):
check_casting(kron1, asserted_type=Kronecker)


def test_dtype_tb(tb1):
def test_cast_tb(tb1):
check_casting(tb1, asserted_type=TiledBlocks)

0 comments on commit a5b58ff

Please sign in to comment.