-
Notifications
You must be signed in to change notification settings - Fork 17
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
Reading of c-arrays + more customstructs #167
Conversation
julia> a = @SMatrix [1 2 3; 4 5 6]
2×3 SMatrix{2, 3, Int64, 6} with indices SOneTo(2)×SOneTo(3):
1 2 3
4 5 6
julia> sizeof(a)
48
julia> sizeof(typeof(a))
48 it should work? |
I forgot why we can't use Line 116 in 7d37122
and of course the StaticArray doesn't have constructor. But we can work around this by defining our own: _initialize(::Type{T}) = T()
_initialize(::Type{T<:SArray}) = zero(T) this way we don't have to wrap them? |
Indeed in this case it works. But this is due to the fact, that the actual type of your SMatrix is |
I am not sure this would work? |
I've added now also the possibility to allwo the customstructs dict to allow for special types simply by branchnames. This enables a bit more customizability if someone needs special interpretation of some branches. |
To be honest I just realised that the last addition is everything that I need for any of my "special branches". So if you think that the other parts of this PR (and what has been in added in #166) adds too much overhead/unnecessary stuff I would be totally fine with removing all of that. As long as defining "customstructs" also via fTitle (or fName which is probably more intuitive) remains in this PR I am happy 😊 |
Btw. why are tests failing? |
https://github.com/JuliaHEP/UnROOT.jl/runs/6309779626?check_suite_focus=true is log somehow not visible? |
does test pass for you locally? |
Will try it tomorrow. |
Tried now the tests locally. The failing one is this: Lines 733 to 738 in 7d37122
It seems that this file has a Fixed it by simply leaving it as |
Codecov Report
@@ Coverage Diff @@
## master #167 +/- ##
==========================================
- Coverage 90.71% 90.29% -0.42%
==========================================
Files 11 11
Lines 1561 1566 +5
==========================================
- Hits 1416 1414 -2
- Misses 145 152 +7
Continue to review full report at Codecov.
|
looks like it's passing for >=1.6, I will give it a read later and see if we can manage without so much custom type |
this is partly addressed in #188 |
Sadly it appears I'll never find time to finish this and (probably) won't need it any time in the near future. |
After prior discussion in #165 and #166 respectively I decided to put a little bit of effort into extending it to fix #9 finally.
For that I simply enhanced the customstruct to an arbitrary dimensional
FixSizeArray
and parse the fLeaf.fTitle for the decomposition. Everything else works as expected.Two caveats:
StaticArrays.SArray
struct nicely we are also limited to there specifications. With the current implementation of the structBase.sizeof()
does not work out of the box due to a missing 4.th parameter in the SArray-type. (see: https://github.com/briederer/UnROOT.jl/blob/3785a042a9cd9855e5f0b9ee18e3b89448bb15d3/src/custom.jl#L49-L53). This means we either add an (for this purpose) unnecessary parameter to the struct or we simply overwrite theBase.sizeof
method as is done here.FixSizeVector
andFixSizeMatrix
to improve readability in the output. However due to some restrictions (see Type aliases are not printed as aliases if the aliased type is imported from a different module JuliaLang/julia#40448) the aliases would only be seen for the User if the additional types are exported. But this is not my choice 😉Closes #9