Skip to content

ScientificTypes.scitype(Any[]) errors (but other empty vectors work fine) #107

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

Closed
DilumAluthge opened this issue Aug 5, 2020 · 1 comment · Fixed by #108
Closed

ScientificTypes.scitype(Any[]) errors (but other empty vectors work fine) #107

DilumAluthge opened this issue Aug 5, 2020 · 1 comment · Fixed by #108
Assignees

Comments

@DilumAluthge
Copy link
Member

julia> ScientificTypes.scitype(Any[])
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
  [1] _empty_reduce_error()
    @ Base ./reduce.jl:299
  [2] mapreduce_empty(f::Function, op::Base.BottomRF{ScientificTypes.var"#8#9"}, T::Type)
    @ Base ./reduce.jl:342
  [3] reduce_empty(op::Base.MappingRF{typeof(ScientificTypes.scitype),Base.BottomRF{ScientificTypes.var"#8#9"}}, #unused#::Type{Any})
    @ Base ./reduce.jl:329
  [4] reduce_empty_iter(op::Base.MappingRF{typeof(ScientificTypes.scitype),Base.BottomRF{ScientificTypes.var"#8#9"}}, itr::Vector{Any}, #unused#::Base.HasEltype)
    @ Base ./reduce.jl:355
  [5] reduce_empty_iter(op::Base.MappingRF{typeof(ScientificTypes.scitype),Base.BottomRF{ScientificTypes.var"#8#9"}}, itr::Vector{Any})
    @ Base ./reduce.jl:354
  [6] foldl_impl
    @ ./reduce.jl:49 [inlined]
  [7] mapfoldl_impl
    @ ./reduce.jl:44 [inlined]
  [8] #mapfoldl#196
    @ ./reduce.jl:160 [inlined]
  [9] mapfoldl
    @ ./reduce.jl:160 [inlined]
 [10] #mapreduce#200
    @ ./reduce.jl:287 [inlined]
 [11] mapreduce
    @ ./reduce.jl:287 [inlined]
 [12] #reduce#202
    @ ./reduce.jl:456 [inlined]
 [13] reduce
    @ ./reduce.jl:456 [inlined]
 [14] scitype_union
    @ ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:26 [inlined]
 [15] #arr_scitype#11
    @ ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:92 [inlined]
 [16] arr_scitype
    @ ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:92 [inlined]
 [17] #scitype#10
    @ ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:77 [inlined]
 [18] scitype(A::Vector{Any}, C::MLJScientificTypes.MLJ, ::Val{:other})
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:77
 [19] scitype(X::Vector{Any}, C::MLJScientificTypes.MLJ; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}})
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:10
 [20] scitype(X::Vector{Any}, C::MLJScientificTypes.MLJ)
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:10
 [21] scitype(X::Vector{Any}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}})
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:9
 [22] scitype(X::Vector{Any})
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:9
 [23] top-level scope
    @ REPL[9]:1

Steps to reproduce:

In Bash:

rm -rf ~/.julia

In Julia:

julia> import Pkg

julia> Pkg.add(["ScientificTypes", "MLJScientificTypes"])

julia> import ScientificTypes
[ Info: Precompiling ScientificTypes [321657f4-b219-11e9-178b-2701a2544e81]

julia> import MLJScientificTypes
[ Info: Precompiling MLJScientificTypes [2e2323e0-db8b-457b-ae0d-bdfb3bc63afd]

julia> ScientificTypes.set_convention(MLJScientificTypes.MLJ())

julia> ScientificTypes.scitype(Int[])
AbstractVector{ScientificTypes.Count} = AbstractArray{ScientificTypes.Count,1}

julia> ScientificTypes.scitype(Float64[])
AbstractVector{ScientificTypes.Continuous} = AbstractArray{ScientificTypes.Continuous,1}

julia> ScientificTypes.scitype(String[])
AbstractVector{ScientificTypes.Textual} = AbstractArray{ScientificTypes.Textual,1}

julia> ScientificTypes.scitype(Any[])
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
  [1] _empty_reduce_error()
    @ Base ./reduce.jl:299
  [2] mapreduce_empty(f::Function, op::Base.BottomRF{ScientificTypes.var"#8#9"}, T::Type)
    @ Base ./reduce.jl:342
  [3] reduce_empty(op::Base.MappingRF{typeof(ScientificTypes.scitype),Base.BottomRF{ScientificTypes.var"#8#9"}}, #unused#::Type{Any})
    @ Base ./reduce.jl:329
  [4] reduce_empty_iter(op::Base.MappingRF{typeof(ScientificTypes.scitype),Base.BottomRF{ScientificTypes.var"#8#9"}}, itr::Vector{Any}, #unused#::Base.HasEltype)
    @ Base ./reduce.jl:355
  [5] reduce_empty_iter(op::Base.MappingRF{typeof(ScientificTypes.scitype),Base.BottomRF{ScientificTypes.var"#8#9"}}, itr::Vector{Any})
    @ Base ./reduce.jl:354
  [6] foldl_impl
    @ ./reduce.jl:49 [inlined]
  [7] mapfoldl_impl
    @ ./reduce.jl:44 [inlined]
  [8] #mapfoldl#196
    @ ./reduce.jl:160 [inlined]
  [9] mapfoldl
    @ ./reduce.jl:160 [inlined]
 [10] #mapreduce#200
    @ ./reduce.jl:287 [inlined]
 [11] mapreduce
    @ ./reduce.jl:287 [inlined]
 [12] #reduce#202
    @ ./reduce.jl:456 [inlined]
 [13] reduce
    @ ./reduce.jl:456 [inlined]
 [14] scitype_union
    @ ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:26 [inlined]
 [15] #arr_scitype#11
    @ ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:92 [inlined]
 [16] arr_scitype
    @ ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:92 [inlined]
 [17] #scitype#10
    @ ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:77 [inlined]
 [18] scitype(A::Vector{Any}, C::MLJScientificTypes.MLJ, ::Val{:other})
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:77
 [19] scitype(X::Vector{Any}, C::MLJScientificTypes.MLJ; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}})
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:10
 [20] scitype(X::Vector{Any}, C::MLJScientificTypes.MLJ)
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:10
 [21] scitype(X::Vector{Any}; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}})
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:9
 [22] scitype(X::Vector{Any})
    @ ScientificTypes ~/.julia/packages/ScientificTypes/b8I2Y/src/scitype.jl:9
 [23] top-level scope
    @ REPL[9]:1

To edit a specific method, type the corresponding number into the REPL and press Ctrl+Q

julia> Pkg.status()
Status `~/.julia/environments/v1.6/Project.toml`
  [2e2323e0] MLJScientificTypes v0.2.8
  [321657f4] ScientificTypes v0.8.0

julia> import InteractiveUtils

julia> InteractiveUtils.versioninfo()
Julia Version 1.6.0-DEV.569
Commit 84ef118f06 (2020-08-01 18:56 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.6.0)
  CPU: Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, haswell)
@tlienart tlienart self-assigned this Aug 5, 2020
@tlienart
Copy link
Collaborator

tlienart commented Aug 5, 2020

I'll have a look, thanks for the heads up :)

tlienart added a commit to tlienart/ScientificTypes.jl that referenced this issue Aug 5, 2020
@ablaom ablaom closed this as completed in 765ad0a Aug 7, 2020
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

Successfully merging a pull request may close this issue.

2 participants