Code Monkey home page Code Monkey logo

Comments (1)

mcabbott avatar mcabbott commented on June 12, 2024

I agree it would be nice to make this all work. Trying to recover what's actually going on first, this works:

a = AcceleratedArrays.Interval(sd, ed)
A(in(a), :) # in(...) isa Function, so this goes to:
findall(in(a), dates) # isa StepRange, could be UnitRange

but without the in it gets treated as a scalar, which fails:

a |> typeof |> supertype # , isn't anything recognised
AxisKeys.findindex(a, axiskeys(A,1)) # error, from this:
findfirst(isequal(a), axiskeys(A,1))

For IntervalSets.Interval there's a special findindex method to avoid this:
https://github.com/mcabbott/AxisKeys.jl/blob/master/src/selectors.jl#L6
It doesn't call findall(in(s), r), because that would be an error:

findall(in(IntervalSets.Interval(sd, ed)), dates.parent)
findall(in(IntervalSets.Interval(3,5.5)), 0:10) # same error without Dates

and instead falls back to giving a vector, as you observe. The issue to fix that is JuliaMath/IntervalSets.jl#52 (which should become a PR).

But it remains to figure out what to do with AcceleratedArrays.Interval, without depending on that package. Why does this differ anyway, it's some issue about isless vs <? But it could still subtype AbstractInterval, that would be nice because IntervalSets.jl is a small package for precisely this purpose.

Is there another way to catch this? We could send z::Any to finall(in(z), axiskeys(A,1)) instead of findfirst(isequal(z), axiskeys(A,1)), i.e. treat objects whose type doesn't match eltype of keys as collections, not individual values, but that doesn't seem ideal. For example push!(KeyedArray(rand(3), [:a, :b, :c]), 0.44) has eltype Any.

from axiskeys.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.