-
Notifications
You must be signed in to change notification settings - Fork 11
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
add space_idx_formatter
and einsum_str_formatter
#3
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making these additions! I'm happy to accept the changes if these comments (just minor code style stuff) are addressed.
PYTHON_FILE_TAB = " " | ||
|
||
|
||
def space_idx_formatter(name, space_list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function can be done in one line, something like: return name + str([space + "_idx" for space in space_list])
function_str += PYTHON_FILE_TAB + "t2 = t2oovv.transpose(2, 3, 0, 1)\n\n" | ||
|
||
einsum_str = final._print_einsum(return_str, exprs_with_space=[H], | ||
space_idx_formatter=space_idx_formatter, einsum_str_formatter=einsum_str_formatter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long
space_idx_formatter=space_idx_formatter, einsum_str_formatter=einsum_str_formatter) | ||
einsum_str = einsum_str.split("\n") | ||
|
||
for i, line in enumerate(einsum_str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the index is unnecessary, you can just do for line in einsum_str:
@@ -495,19 +495,43 @@ def _print_str(self, with_scalar=True): | |||
out += tt._print_str(imap) | |||
return out | |||
|
|||
def _einsum_str(self): | |||
def _einsum_str(self, exprs_with_space = None, names_with_space = None, space_idx_formatter = None, einsum_str_formatter = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long, there shouldn't be spaces around the =
signs in the function definition.
|
||
if einsum_str_formatter is not None: | ||
return einsum_str_formatter(sstr, istr, fstr, tstr) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This else
is unnecessary, you can just have an unintended return after the the if
statement
@@ -839,13 +863,24 @@ def _print_str(self): | |||
out += sign + str(num) + t._print_str(with_scalar=False) + "\n" | |||
return out[:-1] | |||
|
|||
def _print_einsum(self, lhs=None): | |||
def _print_einsum(self, lhs=None, exprs_with_space = None, names_with_space = None, space_idx_formatter = None, einsum_str_formatter = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line is too long and there shouldn't be spaces around the =
in the function definition
X = lhs if lhs is not None else str() | ||
out = str() | ||
for t in self.terms[:-1]: | ||
out += X + " += " + t._einsum_str() + "\n" | ||
out += X + " += " + t._einsum_str( | ||
exprs_with_space = exprs_with_space, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra spaces used to align the =
here are unnecessary
No description provided.