Giter Site home page Giter Site logo

Comments (8)

moodymudskipper avatar moodymudskipper commented on June 9, 2024

Also what would be the expected output for list(list(1,2)) %in{}% list(list(1,2), 3) ?

I believe we should unlist by default the rhs, it seems to be what range() does anyway :

range(list(1,list(3,4)))
#> [1] 1 4

Then I think failing like == does is good enough so we avoid opening a new can of worms and can aim to have everything consistent with == rather than %in%, does that sound right ?

list(list(1,2)) %in% list(list(1,2), 3)
#> [1] TRUE
list(list(1,2)) == list(list(1,2), 3)
#> Error in list(list(1, 2)) == list(list(1, 2), 3): comparaison de ces types non implémentée
list(1,2) %in% list(1, 3)
#> [1]  TRUE FALSE
list(1,2) == list(1, 3)
#> Error in list(1, 2) == list(1, 3): comparaison de ces types non implémentée
c(1,2) == list(1, 3)
#> [1]  TRUE FALSE
c(1,2) %in% list(1, 3)
#> [1]  TRUE FALSE
list(1,2) == c(1, 3)
#> [1]  TRUE FALSE
list(1,2) %in% c(1, 3)
#> [1]  TRUE FALSE

Created on 2019-08-18 by the reprex package (v0.3.0)

from inops.

moodymudskipper avatar moodymudskipper commented on June 9, 2024

I've pushed a few changes, including making %in{}% consistent, other check ops were ok, and I made tests for those

from inops.

karoliskoncevicius avatar karoliskoncevicius commented on June 9, 2024

Making it consistent with == sounds about right to me!.

Also I am wondering if there is a way to make them adhere to "group generics". Specifically "Group Ops" in ?groupGeneric

from inops.

moodymudskipper avatar moodymudskipper commented on June 9, 2024

Group "Ops":
... (arithmetic ops)
"==", "!=", "<", "<=", ">=", ">"
... (on unary ops)
The classes of both arguments are considered in dispatching any member of this group. For each argument its vector of classes is examined to see if there is a matching specific (preferred) or Ops method. If a method is found for just one argument or the same method is found for both, it is used. If different methods are found, there is a warning about ‘incompatible methods’: in that case or if no method is found for either argument the internal method is used.

I think group generics allow identical(iris < 3, 3 > iris) to be TRUE, I think it would be confusing in our case, you would want "^foo" %in~% x to work as x %in~% "^foo" ? Or maybe I'm missing something.

Note that the data.frame methods for the comparison ("Compare": ==, <, ...) and logic ("Logic": & | and !) operators return a logical matrix instead of a data frame, for convenience and back compatibility.

This is implemented in our operators already

If the members of this group are called as functions, any argument names are removed to ensure that positional matching is always used.

we could do that, but I don't see the point, the positional matching is used by primitives for speed as far as I understand, and operators are almost never invoked as functions.

from inops.

karoliskoncevicius avatar karoliskoncevicius commented on June 9, 2024

What I meant is that if somebody writes a custom S3 (or S4 for that matter) object and implements Ops.class <- function(e1, e2) { ... } that it would extend automatically to the operators in this package as well.

Maybe it doesn't make much sense, since the e2 in our case is not an object of a new class.

Yeah let's drop this. Bad idea.

from inops.

moodymudskipper avatar moodymudskipper commented on June 9, 2024

regex ops must be made consistent as well + tests and then we can close this

from inops.

moodymudskipper avatar moodymudskipper commented on June 9, 2024

regex ops defined and should behave ok, tests to design still

from inops.

moodymudskipper avatar moodymudskipper commented on June 9, 2024

closing this as we have an issue about unit tests
#7

from inops.

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.