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

StackOverflowError when using At #4

Closed
alecloudenback opened this issue Sep 28, 2019 · 3 comments
Closed

StackOverflowError when using At #4

alecloudenback opened this issue Sep 28, 2019 · 3 comments

Comments

@alecloudenback
Copy link
Contributor

Using Julia 1.2.0 with DimensionalData v0.1.0 I encounter an issue. Perhaps I'm doing something wrong with the constructor or indexing?

julia> d = DimensionalArray(rand(12,10),Dim{:Age}(0:11),Dim{:Duration}(1:10))
12×10 DimensionalArray{Float64,2,Dim{:Age,UnitRange{Int64},Nothing,DimensionalData.Forward},Dim{:Duration,UnitRange{Int64},Nothing,DimensionalData.Forward},Array{Float64,2}}:
 0.778748   0.495674   0.972396  0.0743772  0.160006   0.364009    0.802004   0.315814  0.516349   0.25529
 0.428088   0.595999   0.333938  0.500439   0.885373   0.623493    0.711443   0.265025  0.0625082  0.745435
 0.703649   0.369344   0.394719  0.45761    0.290267   0.364453    0.613593   0.387107  0.628519   0.819933
 0.977845   0.0794241  0.531902  0.280992   0.402047   0.756775    0.13164    0.062591  0.694477   0.416015
 0.0556876  0.49882    0.672613  0.212836   0.743249   0.424285    0.913358   0.460033  0.0345535  0.0104587
 0.599711   0.563205   0.107054  0.999652   0.0670963  0.00359502  0.0169267  0.344555  0.747658   0.554389
 0.448329   0.939001   0.640038  0.921711   0.915994   0.939289    0.837513   0.868865  0.66771    0.783397
 0.782341   0.857793   0.135598  0.765034   0.520911   0.378882    0.482239   0.22485   0.770335   0.479799
 0.6601     0.51877    0.397913  0.916057   0.391102   0.245188    0.222499   0.814934  0.375634   0.401231
 0.284916   0.169768   0.620476  0.250912   0.64616    0.206558    0.0312784  0.178456  0.766275   0.950708
 0.445494   0.609898   0.85941   0.503771   0.378988   0.568289    0.116531   0.88722   0.0570116  0.372341
 0.591082   0.890146   0.976019  0.410203   0.925599   0.9378      0.129331   0.523501  0.982223   0.846347

When I try to index with At:

julia> d[At(1),At(1)]
ERROR: StackOverflowError:
Stacktrace:
 [1] sel2indices(::Dim{:Age,UnitRange{Int64},Nothing,DimensionalData.Forward}, ::Tuple{At{Int64},At{Int64}}) at C:\Users\user\.julia\packages\DimensionalData\7xUVM\src\selector.jl:42 (repeats 80000 times)

Also when using the named dimension:

julia> d[Dim{:Age}(1)]
ERROR: StackOverflowError:
Stacktrace:
 [1] dims2indices(::Dim{:Age,UnitRange{Int64},Nothing,DimensionalData.Forward}, ::Tuple{Dim{:Age,Int64,Nothing,DimensionalData.Forward}}, ::Function) at C:\Users\alecl\.julia\packages\DimensionalData\7xUVM\src\primitives.jl:44 (repeats 80000 times)
@rafaqz
Copy link
Owner

rafaqz commented Sep 29, 2019

No that looks like it should work. Im currently on the road but I'll try to fix it in the next few days.

@rafaqz
Copy link
Owner

rafaqz commented Oct 2, 2019

Ok so the issue is dims should be a tuple! sorry I didn't see that straight away. You are passing single dimensions for the dims field and the second for the refdims field.

I'll make the constructor force you to pass in a tuple for both.

julia> d = DimensionalArray(rand(12,10), (X(0:11), Y(1:10)))
12×10 DimensionalArray{Float64,2,Tuple{X{LinRange{Float64},Nothing,DimensionalData.Forward},Y{LinRange{Float64},Nothing,DimensionalData.Forward}},Tuple{},Array{Float64,2}}:
 0.65014    0.451515   0.858925  0.801924  0.319277  0.261568   0.380133   0.827168  0.906281   0.830167
 0.514241   0.681027   0.674725  0.994872  0.302602  0.315485   0.641938   0.364782  0.0624274  0.610432
 0.592915   0.629713   0.184351  0.405917  0.122486  0.0131507  0.91589    0.740307  0.109258   0.77165 
 0.488762   0.573304   0.231533  0.351711  0.647384  0.16866    0.824338   0.776865  0.34958    0.101667
 0.1157     0.810775   0.533961  0.40543   0.850627  0.754541   0.0443777  0.138219  0.364477   0.361786
 0.531991   0.626329   0.605021  0.104082  0.997339  0.738728   0.84304    0.9079    0.228457   0.853585
 0.659272   0.281332   0.358277  0.626901  0.248435  0.94595    0.743765   0.621516  0.763135   0.372894
 0.440714   0.300856   0.804684  0.103844  0.650912  0.0509243  0.0909063  0.270426  0.250058   0.332711
 0.76212    0.730735   0.871606  0.739727  0.824078  0.173855   0.90869    0.452509  0.962995   0.896341
 0.634562   0.305028   0.538881  0.752957  0.530875  0.281745   0.748889   0.916087  0.240868   0.690209
 0.0833073  0.211305   0.934384  0.597245  0.629211  0.256024   0.972005   0.790384  0.721913   0.412681
 0.646667   0.0659739  0.55635   0.624643  0.721276  0.391332   0.0152408  0.687425  0.416697   0.187871

julia> dims(d)
(
X: X{LinRange{Float64},Nothing,DimensionalData.Forward}
val: range(0.0, stop=11.0, length=12)
metadata: nothing
, 
Y: Y{LinRange{Float64},Nothing,DimensionalData.Forward}
val: range(1.0, stop=10.0, length=10)
metadata: nothing
)

julia> d[At(1),At(1)]
0.5142413612261603

@rafaqz rafaqz closed this as completed Oct 2, 2019
@rafaqz
Copy link
Owner

rafaqz commented Oct 2, 2019

This is fixed in master and will be registered as an update soon

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

No branches or pull requests

2 participants