Skip to content

Commit

Permalink
Auto Format
Browse files Browse the repository at this point in the history
  • Loading branch information
taichi-gardener committed Mar 7, 2022
1 parent 67c167a commit 95209a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions python/taichi/lang/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def make_constant_expr(val, dtype):
constant_dtype = impl.get_runtime(
).default_ip if dtype is None else dtype
if constant_dtype not in integer_types:
raise TaichiTypeError('Integer literals must be annotated with a integer type. For type casting, use `ti.cast`.')
raise TaichiTypeError(
'Integer literals must be annotated with a integer type. For type casting, use `ti.cast`.'
)
_check_in_range(to_numpy_type(constant_dtype), val)
return Expr(
_ti_core.make_const_expr_int(
Expand All @@ -83,7 +85,9 @@ def make_constant_expr(val, dtype):
constant_dtype = impl.get_runtime(
).default_fp if dtype is None else dtype
if constant_dtype not in real_types:
raise TaichiTypeError('Floating-point literals must be annotated with a floating-point type. For type casting, use `ti.cast`.')
raise TaichiTypeError(
'Floating-point literals must be annotated with a floating-point type. For type casting, use `ti.cast`.'
)
return Expr(_ti_core.make_const_expr_fp(constant_dtype, val))
raise TaichiTypeError(f'Invalid constant scalar data type: {type(val)}')

Expand Down
8 changes: 6 additions & 2 deletions tests/python/test_literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def int_annotation_error():

with pytest.raises(
ti.TaichiTypeError,
match="Integer literals must be annotated with a integer type. For type casting, use `ti.cast`."):
match=
"Integer literals must be annotated with a integer type. For type casting, use `ti.cast`."
):
int_annotation_error()


Expand All @@ -74,5 +76,7 @@ def float_annotation_error():

with pytest.raises(
ti.TaichiTypeError,
match="Floating-point literals must be annotated with a floating-point type. For type casting, use `ti.cast`."):
match=
"Floating-point literals must be annotated with a floating-point type. For type casting, use `ti.cast`."
):
float_annotation_error()

0 comments on commit 95209a5

Please sign in to comment.