Open-Systems-Pharmacology / OSPSuite.RUtils

Utility functions for Open Systems Pharmacology R packages
https://www.open-systems-pharmacology.org/OSPSuite.RUtils/dev/
GNU General Public License v2.0
1 stars 3 forks source link

numeric and integer validators error with factors #102

Closed IndrajeetPatil closed 2 years ago

IndrajeetPatil commented 2 years ago

The behaviour of validateIsNumeric() is different with factors for R versions >= 4.1 and < 4.1 due to the following change:

Using c() to combine a factor with other factors now gives a factor, an ordered factor when combining ordered factors with identical levels.

The current PR adds tests to make sure that the correct behaviour continues to be observed for R > 4.1, and we don't unintentionally introduce a regression.

Closes #94

codecov-commenter commented 2 years ago

Codecov Report

Merging #102 (9b8d69b) into develop (c784c6f) will decrease coverage by 0.00%. The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop     #102      +/-   ##
===========================================
- Coverage    99.40%   99.40%   -0.01%     
===========================================
  Files           17       17              
  Lines          169      168       -1     
===========================================
- Hits           168      167       -1     
  Misses           1        1              
Impacted Files Coverage Δ
R/validation-type.R 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c784c6f...9b8d69b. Read the comment docs.

IndrajeetPatil commented 2 years ago

@abdullahhamadeh I can reproduce this issue, but only for R versions < "4.1".

Need to figure out what exactly changed in the latest version of R that leads to the correct behaviour.

Do you have a workaround for this for the time being?

abdullahhamadeh commented 2 years ago

Thanks @IndrajeetPatil. I do have a workaround: validateIsOfType(factor(3),type = "numeric") gives

Error in validateIsOfType(factor(3), type = "numeric") : 
  validateIsOfType: argument 'factor(3)' is of type 'factor', but expected 'numeric'!
msevestre commented 2 years ago

fine with me. MErging