ropensci / popler

The R package to browse and query the popler database
https://docs.ropensci.org/popler
MIT License
8 stars 7 forks source link

concatenate_queries() function in get_data() #38

Closed AldoCompagnoni closed 7 years ago

AldoCompagnoni commented 7 years ago

A function to checks the vailidity of that the ... argument in get_data. There are a few cases of "legal" ... input in get_data: 1a. A browse object 1b. A browse call (eg. get_data( browse(genus == "poa") ))

  1. A logical argument
  2. A combination of 1(a or b) and 2.

There are at least four error cases

  1. More than 2 arguments in ...
  2. Two logical statements
  3. Two objects
  4. Any object that is not a "popler" objects
AldoCompagnoni commented 7 years ago

Brad made the concatenate_queries function!

I have made unit tests. These A. address the 4 error messages I presented below; B. address the expected outputs of concatenate_queries (which should be calls, and/or calls that include and & operator).

AldoCompagnoni commented 7 years ago

To close the issue, Brad will update the content of the error messages returned by concatenate_queries. In particular:

  1. concatenate_queries(poa_d, poa_d) should specifically say that you entered two browse objects.
  2. concatenate_queries(year == 2000, genus == "Poa") should specifically say that you entered two logical statements.
  3. concatenate_queries(poa_d, poa_d, obj) should say that you specified 3 entries (not only refer to obj as source of error)
bochocki commented 7 years ago

I've addressed the error messages as follows: 1.

> concatenate_queries(poa_d, poa_d)
Error in concatenate_queries(poa_d, poa_d) : 
  You cannot enter more than one browse() argument.
  Please refer to the '...' argument in ?get_data.

2.

> concatenate_queries(year == 2000, genus == "Poa")
Error in concatenate_queries(year == 2000, genus == "Poa") : 
  You cannot enter more than one logical argument.
  Please refer to the '...' argument in ?get_data.
  1. > concatenate_queries(poa_d, poa_d, obj)
    Error in concatenate_queries(poa_d, poa_d, obj) : 
    You cannot enter more than two arguments:
    1) an object returned by browse() and/or
    2) a logical statement
    Please refer to the '...' argument in ?get_data.

suggest closing this issue

AldoCompagnoni commented 7 years ago

I have just changed the language (sorry for being paranoid!) from "logical argument" to "logical expression", following the semantics in the subset function in base! This issue is closed!

AldoCompagnoni commented 7 years ago

Re-opening this issue, because running the code poa_d <- browse( genus == "Poa"); concatenate_queries(poa_d) Returns nothing.

AldoCompagnoni commented 7 years ago

This was a conflict that I introduced: I forced concatenate_queries to look for attributes(browse(genus == "Poa"))$search_expression. However, browse would only contain attributes(browse(genus == "Poa"))$search_argument.

I changed search_argument and search_expression to search_expr.