Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Fix typo and type in docstring, and format too long string #3530

Merged
merged 3 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions python/taichi/lang/kernel_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ def extract_arg(arg, anno):
shape = tuple(arg.shape)
if len(shape) < element_dim:
raise ValueError(
f"Invalid argument into ti.any_arr() - required element_dim={element_dim}, but the argument has only {len(shape)} dimensions"
)
f"Invalid argument into ti.any_arr() - required element_dim={element_dim}, "
f"but the argument has only {len(shape)} dimensions")
element_shape = (
) if element_dim == 0 else shape[:
element_dim] if layout == Layout.SOA else shape[
-element_dim:]
return to_taichi_type(arg.dtype), len(shape), element_shape, layout
return (type(arg).__name__, )
return type(arg).__name__,

def extract(self, args):
extracted = []
Expand Down Expand Up @@ -451,8 +451,10 @@ def taichi_ast_generator():
_taichi_skip_traceback = 1
if self.runtime.inside_kernel:
raise TaichiSyntaxError(
"Kernels cannot call other kernels. I.e., nested kernels are not allowed. Please check if you have direct/indirect invocation of kernels within kernels. Note that some methods provided by the Taichi standard library may invoke kernels, and please move their invocations to Python-scope."
)
"Kernels cannot call other kernels. I.e., nested kernels are not allowed. "
"Please check if you have direct/indirect invocation of kernels within kernels. "
"Note that some methods provided by the Taichi standard library may invoke kernels, "
"and please move their invocations to Python-scope.")
self.runtime.inside_kernel = True
self.runtime.current_kernel = self
try:
Expand Down
18 changes: 9 additions & 9 deletions python/taichi/lang/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class Matrix(TaichiOperations):
"""The matrix class.

Args:
n (int): the first dimension of a matrix.
n (Union[int, list, tuple], np.ndarray): the first dimension of a matrix.
m (int): the second dimension of a matrix.
dt (DataType): the elmement data type.
dt (DataType): the element data type.
keep_raw (Bool, optional): Keep the contents in `n` as is.
"""
is_taichi_class = True
Expand Down Expand Up @@ -145,8 +145,8 @@ def __init__(self,
self.m = m
else:
raise ValueError(
"Declaring matrix fields using `ti.Matrix(n, m, dt, shape)` is no longer supported. Use `ti.Matrix.field(n, m, dtype, shape)` instead."
)
"Declaring matrix fields using `ti.Matrix(n, m, dt, shape)` is no longer supported. "
"Use `ti.Matrix.field(n, m, dtype, shape)` instead.")

if self.n * self.m > 32 and not suppress_warning:
warning(
Expand Down Expand Up @@ -611,7 +611,7 @@ def diag(dim, val):

Args:
dim (int): the dimension of a square matrix.
val (TypeVar): the diagonal elment value.
val (TypeVar): the diagonal element value.

Returns:
The constructed diagonal square matrix.
Expand Down Expand Up @@ -678,7 +678,7 @@ def max(self):

@kern_mod.pyfunc
def min(self):
"""Return the minumum element value."""
"""Return the minimum element value."""
return ops_mod.ti_min(*self.entries)

def any(self):
Expand Down Expand Up @@ -994,7 +994,7 @@ def _Vector_ndarray(cls, n, dtype, shape, layout=Layout.AOS):

@staticmethod
def rows(rows):
"""Construct a Matrix instance by concactinating Vectors/lists row by row.
"""Construct a Matrix instance by concatenating Vectors/lists row by row.

Args:
rows (List): A list of Vector (1-D Matrix) or a list of list.
Expand Down Expand Up @@ -1027,7 +1027,7 @@ def rows(rows):

@staticmethod
def cols(cols):
"""Construct a Matrix instance by concactinating Vectors/lists column by column.
"""Construct a Matrix instance by concatenating Vectors/lists column by column.

Args:
cols (List): A list of Vector (1-D Matrix) or a list of list.
Expand Down Expand Up @@ -1148,7 +1148,7 @@ def Vector(n, dt=None, **kwargs):
"""Construct a `Vector` instance i.e. 1-D Matrix.

Args:
n (int): The desired number of entries of the Vector.
n (Union[int, list, tuple], np.ndarray): The desired number of entries of the Vector.
dt (DataType, optional): The desired data type of the Vector.

Returns:
Expand Down
3 changes: 2 additions & 1 deletion python/taichi/misc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def core_vec(*args):
assert False, type(args[0])


class Tee():
class Tee:
def __init__(self, name):
with open(name, 'w') as self.file:
self.stdout = sys.stdout
Expand Down Expand Up @@ -256,6 +256,7 @@ def print_async_stats(include_kernel_profiler=False):
'core_vec',
'core_veci',
'deprecated',
'warning',
'dump_dot',
'dot_to_pdf',
'obsolete',
Expand Down