-
-
Notifications
You must be signed in to change notification settings - Fork 72
Improved ArrayPartition #18
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
Improved ArrayPartition #18
Conversation
|
One thing to note is that SciML/DifferentialEquations.jl#147 Heterogeneity due to units in second order ODEs is one common area where this is used and I'd like it to still work. The goal of course is the indexing and everything is type stable when there's no units, but in the units case it's fine if just broadcasting is type stable. I'll be keeping this in mind as I review. |
|
Wow, this looks fantastic. I'm surprised you got everything to infer so well. Impressive. Did you test it a second order ODE with units? |
|
No, so far I just did inference tests on |
Codecov Report
@@ Coverage Diff @@
## master #18 +/- ##
==========================================
+ Coverage 42.93% 61.13% +18.2%
==========================================
Files 3 3
Lines 184 211 +27
==========================================
+ Hits 79 129 +50
+ Misses 105 82 -23
Continue to review full report at Codecov.
|
|
I tried to solve the example at SciML/DifferentialEquations.jl#147 (comment). After defining |
When I tried to use
ArrayPartitionsI discovered #11 and the closed issue #8 about type instabilities. However, there are still many type instabilities left - e.g. results ofzeros(x),last(x), and all vector space operations such as multiplication and addition can not be inferred. Moreover, not in-place broadcasting does only work if the types are not changed by the applied function, as noted in #11.Hence I tried to improve
ArrayPartitionand fix most of these things. This PR should fix #11 (all broadcasts should work in a type-stable fashion) and #17 (ArrayPartitionis now a subtype ofAbstractVector{T}). Often types could not be inferred since generators were used, hence I replaced these implementations with a call to a generated function that acts as a simple unrolled generator ofArrayPartition. Furthermore, I tried to get rid of most type instabilities. Since I could not achieve a type-stable version of e.g.similar(x, (Int64, Float64))I changed this non-standard method ofsimilartosimilar(x, Int64, Float64)since then it can be made type-stable (the problem isi.e. the type signature of the definition with a tuple contains less information).
I was wondering about the (unchanged) behaviour of
ones(x): in particular it also works for units (which is good, I guess), althoughonesusually does not work for arrays of units - this leads towhich seems a bit surprising. Moreover, I do not know whether it is reasonable to define
recursive_oneforArrayPartitions by only considering the first partition. Maybe it should not be defined?