-
Notifications
You must be signed in to change notification settings - Fork 31
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
Restore the standard behaviour of reversed(Lattice) #589
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.
I don't understand why you have systematically changed the docstrings of the keyword argument copy
Parameters: | ||
idx (SupportsIndex): index at which the lement is inserted | ||
elem (Element): AT element to be inserted in the lattice | ||
copy_elements(bool): Default :py:obj:`True`. |
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.
Isn't copy_elements a keyword argument?
Parameters: | ||
elems (Iterable[Element]): Sequence of AT elements to be | ||
appended to the lattice | ||
copy_elements(bool): Default :py:obj:`True`. |
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.
Same comment
@@ -359,8 +352,6 @@ def append(self, elem: Element, copy_elements=False): | |||
|
|||
Parameters: | |||
elem (Element): AT element to be appended to the lattice | |||
|
|||
Keyword Arguments: |
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.
Same comment
lattice are used for the repetition | ||
Parameters: | ||
n (int): number of repetition | ||
copy_elements(bool): Default :py:obj:`True`. |
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.
Same comment
@@ -427,8 +416,6 @@ def concatenate(self, *lattices: Iterable[Element], | |||
lattices: :py:obj:`Iterables[Element]` to be concatenanted | |||
to the Lattice, several lattices are allowed | |||
(see example) | |||
|
|||
Keyword Arguments: | |||
copy_elements(bool): Default :py:obj:`False`. If :py:obj:`True` |
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.
Same comment for these 2
>>> newring = ring.reverse(copy=True) | ||
|
||
Keyword Arguments: | ||
Parameters: | ||
copy(bool): Default :py:obj:`False`. If :py:obj:`True` |
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.
Same comment
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'd like to keep them as keywords, but I get lots of warnings in PyCharm about arguments missing in docstrings: apparently for Sphinx, every argument mentioned in he parameter list must be mentioned in the "Args:" section, "Keyword Args:" is reserved for those in kwargs
…
I can live with warnings, but they may hide important ones… I like to keep the "Problems" tab empty.
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.
By the way, I got a similar problem with the "Usage:" section: "Usage:" is not a valid section for sphinx, and it was not formatted properly as python code in the output. That's why I converted it to an "Example:" section…
return Lattice(elem_generator, elems, iterator=self.attrs_filter) | ||
else: | ||
reversed_list = list(reversed(self)) | ||
reversed_list = list(elems) |
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.
Doing this you copy the elements. Is it possible and would it make sense to return the elements themselves by using copy=copy in the elems generator?
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.
No copy is a problem: if the same element is used twice in the ring, it will be swapped twice, and the second one in the reversed lattice will be wrong.
Ok thanks for the clarification, all good for me! |
This PR restores the standard behaviour of the
reversed()
iterator forLattice
objects: the behaviour introduced in #573 could be confusing, since it was iterating on copies of the elements instead of element themselves.As a consequence, the only way to build reversed lattices by swapping entrance and exit faces is to use the
Lattice.reversed()
method.