ropensci / taxa

taxonomic classes for R
https://docs.ropensci.org/taxa
Other
48 stars 12 forks source link

Verify and add tests for character as input for class constructors #14

Closed zachary-foster closed 7 years ago

zachary-foster commented 7 years ago

Hi @sckott, I was thinking that it would be useful if all of the classes allowed for character input when being initialized as well as objects as they currently do. I started doing this for taxonomy and therefore most of the others as well since the taxonomy constructor now calls their constructors to do the character to object conversion, but I bet there are edge cases still unhanded.

For example, the following code is used in the tests of taxonomy:

> taxonomy(c("a", "b", "c"), c("a", "d"))
<Taxonomy>
  4 taxa: 1. a, 2. b, 3. d, 4. c
  4 edges: NA->1, 1->2, 1->3, 2->4

I did have to reduce the stringency of some of the constructors to do this, particularly taxon which required the rank and hierarchy, which used the rank to sort taxa. I modified hierarchy to only sort taxa when all had ranks and otherwise retain input order.

Is all this OK with you?

sckott commented 7 years ago

Probably. Can you point me to where the change is in the code? is this an example of the change https://github.com/ropenscilabs/taxa/blob/issue-9/R/taxa-taxonomy.R#L28-L30

zachary-foster commented 7 years ago

I think this commit has all of the changes to the class constructors:

https://github.com/ropenscilabs/taxa/commit/8516219d6355954b75ea47ec3dd103b4345dc30a

sckott commented 7 years ago

yeah, looks good!

zachary-foster commented 7 years ago

Cool, this seems to be done then.