-
Notifications
You must be signed in to change notification settings - Fork 664
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
Behaviour of .collect()
and .toList()
#3105
Comments
I discovered the same thing recently. What I found was that However I think the two operators are otherwise the same. They both emit a single list item. Every operator returns one or more channels due to their asynchronous nature. By the way, thank you for raising these issues about language semantics. I tend to agree with you about the various inconsistencies in Nextflow. I think the language just developed organically and is in need of some cleanup. DSL2 was a huge step in that direction, but operators in particular need to be reviewed. In this case, I think we should keep either |
I noted similar behaviour previously with other operators: #2437 (comment) This was originally and issue then got moved to a discussion for reasons unknown. |
I guess discussions have better longevity because they don't get reaped by the stalebot. Better for threads that don't have specific action items from the start. I also find these three operators confusing. It seems like we could have a single operator with an option like |
To me It's also not clear from the docs what is the difference between Anyways, we're off topic. I'll end by saying that the situation is so bad that my group had contemplated writing our own library of operators with more rational names and semantics! |
Well Anyway, I don't mind veering off because it's part of the same problem. And I'm not surprised! I'm thinking about documenting these inconsistencies in one place, so that we can find a holistic solution that considers the full library of operators. |
The example given for I can see from the example what the description is getting at but it's just kinda weird the way the the I think I've tried using it in the past and found it very clumsy to use in practice. |
Okay I've added my thoughts on all of these operators to the mega-discussion (#3107). We'll see if someone shows up with a use case for |
and break 400 pipelines https://github.com/search?q=transpose+extension%3Anf |
To give a bit more insight about the transpose, it was motivated by the need to have an operation in some extent opposite to the name was taken from the corresponding groovy method for list. See here Regarding I agree it this difference should be highlighted (actually I was convinced it was) |
Thanks for clearing that up with transpose. As for collect and toList, I don't see this difference noted in the docs, but I was able to reproduce the behavior you said. Still, it's the same issue as Or, deprecate |
This strikes at what is possibly a source of confusion, many of the operator are compound operators which could be split into more atomic parts. The one-level flattening of After a further 20 minutes thought I can at least describe the transpose operator:
The problem is, theres a far simpler alternative:
Which for the 2D case in the documentation example would give:
and a simple 1D case we go from a 1xn list to a nx1 list. When viewed this way, transpose as implemented is a compound operator, it transposes the values, and spreads the result across a key. A simple inverse of Incidentally in the search you performed theres a number of examples where a transpose is immediately followed by a groupTuple, which (I think) results in my example above. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing since we clarified the docs for collect and toList in #3276 . |
Bug report
The semantics of these two operators are poorly documented and counter intuitive. From the documentation its not clear what the different between
.collect()
and.toList()
, as the examples given are identical..toList()
does no in fact return a list.Expected behavior and actual behavior
.collect()
s behaviour is to flatten a single level of structure in the input items. This is undocumented and seems arbitrary.The reasonably expected behaviour would be simply to return a value channel with all items from the input queue channel as a single emission.
.toList()
returns a channel where it might reasonably be expected to return a... um, well, list.Steps to reproduce the problem
Program output
Expected output would be:
which is what
.toList()
returns.Environment
Additional context
(Add any other context about the problem here)
The text was updated successfully, but these errors were encountered: