Skip to content
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

Fix fcollect to respect object identity instead of ==; document order #25

Merged
merged 5 commits into from
Oct 5, 2021

Conversation

ericphanson
Copy link
Contributor

Fixes #16. I checked the test I added failed on master:

julia> m1 = [1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> m2 = [1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> m3 = Foo(m1, m2)
Foo([1, 2, 3], [1, 2, 3])

julia> fcollect(m3)
2-element Vector{Any}:
 Foo([1, 2, 3], [1, 2, 3])
 [1, 2, 3]

julia> @test all(fcollect(m3) .=== [m3, m1, m2])
Error During Test at REPL[8]:1
  Test threw exception
  Expression: all(fcollect(m3) .=== [m3, m1, m2])
  DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 2 and 3")

Copy link
Member

@darsnack darsnack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me!

@DhairyaLGandhi
Copy link
Member

If we intend to preserve the order, its worth a mention in the docs.

@ericphanson
Copy link
Contributor Author

Ok, I wrote up the order defined by the implementation in the docstring. We could also not say exactly what the order is but just say it won't change for any inputs in a non-breaking release-- would that be preferred?

@ericphanson ericphanson changed the title Fix fcollect Fix fcollect to respect object identity instead of ==; document order Oct 5, 2021
@darsnack
Copy link
Member

darsnack commented Oct 5, 2021

I think the current explanation is more precise and understandable.

@darsnack darsnack merged commit ccdc063 into FluxML:master Oct 5, 2021
@ericphanson ericphanson deleted the eph/fcollect branch October 5, 2021 15:35
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.

fcollect won't keep repeated arrays that are == but distinct
3 participants