-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
442a3f1
commit baf3370
Showing
5 changed files
with
61 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Utilities for miscellaneous tasks. | ||
""" | ||
|
||
|
||
def indent(s, nspace): | ||
"""Gives indentation of the second line and next lines. | ||
It is used to format the string representation of an object. | ||
Which might be containing multiples objects in it. | ||
Usage: LinearOperator | ||
Parameters | ||
---------- | ||
s: str | ||
The string to be indented. | ||
nspace: int | ||
The number of spaces to be indented. | ||
Returns | ||
------- | ||
str | ||
The indented string. | ||
""" | ||
spaces = " " * nspace | ||
lines = [spaces + c if i > 0 else c for i, c in enumerate(s.split("\n"))] | ||
return "\n".join(lines) | ||
|
||
|
||
def shape2str(shape): | ||
"""Convert the shape to string representation. | ||
It also nicely formats the shape to be readable. | ||
Parameters | ||
---------- | ||
shape: Sequence[int] | ||
The shape to be converted to string representation. | ||
Returns | ||
------- | ||
str | ||
The string representation of the shape. | ||
""" | ||
return "(%s)" % (", ".join([str(s) for s in shape])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters