Skip to content

comparing logical vectors of same length #51

Closed

Description

@moodymudskipper

When comparing logical vectors of the same length I don't find the output very useful :

waldo::compare(rep(TRUE,50), c(FALSE, rep(TRUE,24), FALSE, rep(TRUE,23), FALSE))
`old[1:6]`: TRUE  TRUE TRUE TRUE TRUE TRUE
`new[1:4]`: FALSE           TRUE TRUE TRUE

`old[25:30]`: TRUE TRUE TRUE       TRUE TRUE TRUE
`new[23:29]`: TRUE TRUE TRUE FALSE TRUE TRUE TRUE

`old[48:50]`: TRUE TRUE TRUE      
`new[47:50]`: TRUE TRUE TRUE FALSE

The gaps are strangely placed, and it seems waldo tries to align both and be informative in case we find the same sequences on both sides with some inserts. It works very nicely if I do something like waldo::compare(letters, c("a", letters, "a")), not so much for logicals vectors of the same length. Maybe in that case a summary of the locations of mismatches would work better ?

(I love this package very much, many thanks for the great work)

Activity

  1. hadley commented on Nov 6, 2020

    @hadley
    Member

    I've tweaked the settings I'm passing to diffobj::ses(). I don't think it 100% fixes the problem, but should make it much less common.

    waldo::compare(rep(TRUE,50), c(FALSE, rep(TRUE,24), FALSE, rep(TRUE,23), FALSE))
    #> `old[1:4]`: TRUE  TRUE TRUE TRUE
    #> `new[1:4]`: FALSE TRUE TRUE TRUE
    #> 
    #> `old[23:29]`: TRUE TRUE TRUE TRUE  TRUE TRUE TRUE
    #> `new[23:29]`: TRUE TRUE TRUE FALSE TRUE TRUE TRUE
    #> 
    #> `old[47:50]`: TRUE TRUE TRUE TRUE 
    #> `new[47:50]`: TRUE TRUE TRUE FALSE
  2. moodymudskipper commented on Nov 6, 2020

    @moodymudskipper
    Author

    Awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions