JuliaDynamics / StateSpaceSets.jl

The `StateSpaceSet` interface for packages of JuliaDynamics
MIT License
2 stars 2 forks source link

Constructor for generators #28

Open kahaaga opened 2 weeks ago

kahaaga commented 2 weeks ago

It would be nice if the following worked:

julia> StateSpaceSet(rand(SVector{5, Float64}) for i = 1:1000)
ERROR: MethodError: no method matching StateSpaceSet(::Base.Generator{UnitRange{Int64}, var"#3#4"})
The type `StateSpaceSet` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  StateSpaceSet(::Vector{<:Real}, ::AbstractStateSpaceSet{D, T}) where {D, T}
   @ StateSpaceSets ~/.julia/packages/StateSpaceSets/uC924/src/statespaceset_concrete.jl:93
  StateSpaceSet(::Array{SVector{D, T}, 1}) where {D, T}
   @ StateSpaceSets ~/.julia/packages/StateSpaceSets/uC924/src/statespaceset_concrete.jl:43
  StateSpaceSet(::Vector{<:AbstractArray{T}}) where T<:Number
   @ StateSpaceSets ~/.julia/packages/StateSpaceSets/uC924/src/statespaceset_concrete.jl:57
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[14]:1
Datseris commented 2 weeks ago

I don't know how to extract state space size for generators, so if this worked, it would just forward to collect and use that. But if that's the case, shouldn't the user do the collect instead? Or just add the [ ] ?