Skip to content

add space_idx_formatter and einsum_str_formatter#3

Open
yangjunjie0320 wants to merge 7 commits intoawhite862:masterfrom
yangjunjie0320:dev
Open

add space_idx_formatter and einsum_str_formatter#3
yangjunjie0320 wants to merge 7 commits intoawhite862:masterfrom
yangjunjie0320:dev

Conversation

@yangjunjie0320
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Owner

@awhite862 awhite862 left a 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):
Copy link
Copy Markdown
Owner

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)
Copy link
Copy Markdown
Owner

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):
Copy link
Copy Markdown
Owner

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:

Comment thread wick/expression.py
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):
Copy link
Copy Markdown
Owner

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.

Comment thread wick/expression.py

if einsum_str_formatter is not None:
return einsum_str_formatter(sstr, istr, fstr, tstr)
else:
Copy link
Copy Markdown
Owner

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

Comment thread wick/expression.py
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):
Copy link
Copy Markdown
Owner

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

Comment thread wick/expression.py
for t in self.terms[:-1]:
out += X + " += " + t._einsum_str() + "\n"
out += X + " += " + t._einsum_str(
exprs_with_space = exprs_with_space,
Copy link
Copy Markdown
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants