-
Notifications
You must be signed in to change notification settings - Fork 8
Re-add composition with ∘
and new compose
function
#41
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #41 +/- ##
==========================================
+ Coverage 85.89% 88.65% +2.76%
==========================================
Files 1 1
Lines 78 97 +19
==========================================
+ Hits 67 86 +19
Misses 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
My problem with this is that we are not preserving the dictionary types. Remember that a = Bijection{U,V,F_a,Finv_a}(...)
b = Bijection{V,W,F_b,Finv_b}(...)
c = compose(a, b) What should be the type of This was trivial before when they weren't parameterized (i.e. they would be Also, the functionality introduced here is not critical and it can still be done in a couple of lines: # we define the dictionary types of `c` how we would like
c = Bijection{U,W,F_c,Finv_c}()
for (u, v) in a
c[u] = b[v]
end
# or even in one line
c = Bijection{U,W,F_c,Finv_c}([u => b[v] for (u,v) in a]) In summary, I see this as something that can give us more problems than advantages so I would refrain from adding it to the v1.0 release. It can be thought for the v1.1 release if we find a way to circunvent the issue stated above. PS: It seems like the one-liner above doesn't work with |
Ah! Now I finally understand the problem! :-) This is quite tricky indeed. I've been playing around with some ideas, and added a potential way to handle this in the latest commit. Fundamentally, this adds a However, to take this further, it's not really clear that there is an obvious correct answer for all possible combinations of The behavior currently implemented is well-defined, but arbitrary. I'd be okay with keeping the feature out and simply noting in the changelog that composition was removed because the type of the internal forward and inverse mapping is ill-defined. This works as probably the simplest replacement for the feature: Bijection((x => a[b[x]] for x in keys(b))...) |
So, yeah, I think my vote to agree with @mofeing and to drop this. We can keep this PR around for if we ever want to get back to it post-1.0. Preferably after someone opens an issue demonstrating a specific use case, so that we can make sure that whatever implementation we use meets that use case, as opposed to just me speculating what "correct" behavior should be. |
No. This is just some code we can keep around for some indefinite future. If someone ever comes around with a specific use case for composition, we could look at whether the code in this PR might be a useful starting point. |
This would be my suggestion to close #30
It partially reverts #39, re-adding the functionality, documentation, and tests, but renaming
*
to∘
and implementing it in terms of a new (public)compose
function.I'm not strongly tied to this, so it's fine to close if you prefer to remove composition entirely.
This is missing an entry in the CHANGELOG, but since this is all very much up in the air, I'd add that separately after a merge.
We should also make sure the code snippets in
docs/src/operations.md
are automatically verified as doctests, but I'll also address that separately in #42