Giter Site home page Giter Site logo

Comments (12)

pdeffebach avatar pdeffebach commented on June 14, 2024 1

Sorry, I meant the error at the call of foo, which requires two arguments.

The behavior you described is the correct behavior. I believe Cols(:x1, :x1) should be equivalent to [:x1].

from dataapi.jl.

bkamins avatar bkamins commented on June 14, 2024

CC @pdeffebach, @CameronBieganek

from dataapi.jl.

pdeffebach avatar pdeffebach commented on June 14, 2024

To clarify the issue is as follows, right?

function foo(x, y)
    x .+ y .- mean(x)
end
  • Case 1: select(df, Cols(:x1, :x1) => foo) errors
  • Case 2: select(df, Cols(:x1, :x1) => foo) works.

My intuition is to throw an error. Given that Cols promises no guarantee of ordering in the vast majority of scenarios, the user shouldn't rely on a 1:1 behavior of Cols in this context. They can do

select(df, [:x1, :x1] => foo)

If they want, right?

from dataapi.jl.

nalimilan avatar nalimilan commented on June 14, 2024

@pdeffebach No, the idea is that if it didn't error, Cols(:x1, :x1) would be equivalent to [:x1] (contrary to [:x1, :x1]).

As usual, we can throw an error for now and relax the rules later if needed.

from dataapi.jl.

bkamins avatar bkamins commented on June 14, 2024

I believe Cols(:x1, :x1) should be equivalent to [:x1].

What is the benefit of allowing this over throwing an error?

from dataapi.jl.

nalimilan avatar nalimilan commented on June 14, 2024

I guess it could make sense if these are stored in variables which can take multiple values. Though half of the time it would probably indicate a bug and you can always call unique first.

from dataapi.jl.

pdeffebach avatar pdeffebach commented on June 14, 2024

What is the benefit of allowing this over throwing an error?

I think it would be frustrating for users if

Cols(x #= Container which contains :x1 =#, y #= Container which contains :x1=#) # Between(), etc.

worked but not

Cols(:x1, :x1)

from dataapi.jl.

bkamins avatar bkamins commented on June 14, 2024

half of the time it would probably indicate a bug

This is my understanding of the situation, but given there is no support for it it is even easier to have Cols behave by always taking a union.

from dataapi.jl.

CameronBieganek avatar CameronBieganek commented on June 14, 2024

Cols(:x1, :x1) == Cols(:x1) makes sense to me. That's consistent with the

Cols(A, B, C) ==> (A, B\A, C\(A  B))

behavior I mentioned in the other thread.

from dataapi.jl.

bkamins avatar bkamins commented on June 14, 2024

It is consistent when A, B, C are sets. I considered :x1 to be a separate case as it is not a set but a set element.

from dataapi.jl.

CameronBieganek avatar CameronBieganek commented on June 14, 2024

I'm willing to consider :x1 to be a set with one element. I'd hate to have to write [:x1] all the time. 🙂

from dataapi.jl.

piever avatar piever commented on June 14, 2024

I don't have a strong opinion here, but I would say it's fine to allow it. If one of them is not a symbol literal, this could be useful (say Cols(:x1, col) and col is set programmatically).

The only analogous thing I can think of is for example repeated named arguments in julia Base, and there they are only forbidden if they are passed "not programmatically":

julia> (; a = 1, a = 2)
ERROR: syntax: field name "a" repeated in named tuple
Stacktrace:
 [1] top-level scope at REPL[1]:1
 [2] eval(::Module, ::Any) at ./boot.jl:331
 [3] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [4] run_backend(::REPL.REPLBackend) at /home/pietro/.julia/packages/Revise/WkyNB/src/Revise.jl:1023
 [5] top-level scope at none:0

julia> (; a = 1, :a => 2)
(a = 2,)

As we do not have a good way to test if the symbol was a literal or came from some variable, the simplest is probably to just allow it.

from dataapi.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.