-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP #544 #546
WIP #544 #546
Conversation
This is just the beginning... and it should not be merged at all |
R/data-repository.R
Outdated
|
||
private$throwPropertyIsReadonly("baseGrid") | ||
private$.baseGrid <- value | ||
private$wrapProperty("BaseGrid", value$ref) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposing now some of the Readonly properties
R/data-set.R
Outdated
} | ||
), | ||
public = list( | ||
dataRepository = NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public for now so that I can debug stuff. It will be private once the implementation is stable
R/data-set.R
Outdated
self$dataRepository$name <- value | ||
}, | ||
#' @field xUnit Unit in which the xValues are defined | ||
xUnit = function(value){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the real implementation. Just dummies for now for all methods
R/data-set.R
Outdated
# Create an empty data repository with a base grid and column | ||
dataRepository <- DataRepository$new() | ||
# Passing time for dimension for now | ||
xValues <- DataColumn$new(rClr::clrNew("OSPSuite.Core.Domain.Data.BaseGrid", "xValues", getDimensionByName("Time"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to initialize with some kind of defaults (time, and conc for instance)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will use our tasks to get the name instead of using magic string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
values = function(value) { | ||
private$wrapReadOnlyProperty("ValuesAsArray", value) | ||
private$wrapProperty("ValuesAsArray", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated core to support setting values as well.
# we use the ignore case parameter set to true so that we do not have to worry about casing when set via scripts | ||
unit <- rClr::clrCall(dimension, "FindUnit", value, TRUE) | ||
if(is.null(unit)){ | ||
stop(messages$errorUnitNotSupported(unit = value, dimension = self$dimension)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, an error will be thrown. This is OK in the DataColun object. In the DataSet one, we could be a bit more user friendly (see comment below)
} | ||
# updating the dimension | ||
rClr::clrSet(self$ref, "Dimension", getDimensionByName(value)) | ||
private$.dimension <- NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For efficient usage, we are caching dimension and unit. We need to reset the cache obviously when updating the dimension
R/data-set.R
Outdated
if (missing(value)) { | ||
return(private$.xValues$dimension) | ||
} | ||
private$setColumnDimension(private$.xValues, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have define a method for each set
a ction so that we can call it for x, y and later error
#' @description | ||
#' Print the object to the console | ||
#' @param ... Rest arguments. | ||
print = function(...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
values <- private$getColumnValues(column) | ||
|
||
#now we need to update dimension and display unit | ||
column$displayUnit <- unit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HERE: If the unit is not supported, we could easily update the dimension by using the method getDimensionForUnit. That way, the user would never have to worry about updating the dimension when updating the unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msevestre I would not prefer to automatically change the dimension, as I see it as a sanity check here. Simply changing the unit only affects what actual values the data have, but not the meaning of the data. Changing the dimension actually means that the data means something else. What do you think?
R/data-set.R
Outdated
initializeCache = function() { | ||
private$.xValues <- self$dataRepository$baseGrid | ||
# TODO we need to be a bit more careful here | ||
private$.yValues <- self$dataRepository$allButBaseGrid[[1]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a more to do. Specifically regarding the error column.
Codecov Report
@@ Coverage Diff @@
## develop #546 +/- ##
===========================================
- Coverage 88.61% 88.49% -0.13%
===========================================
Files 72 74 +2
Lines 1449 1625 +176
===========================================
+ Hits 1284 1438 +154
- Misses 165 187 +22
Continue to review full report at Codecov.
|
@msevestre Should we remove "utilities-data-mapping" and completely replace it by "utilities-data-set"? E.g. |
Should we maybe fork this so we can merge PRs? I do not want to have a huge PR without intermediate states. |
* Continue working on DataSet * Update man on DataColumn * WIP DataSet adding (failing) test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PavelBal I think this is good to review ...
#' | ||
#' @param name Name of new meta data list entry | ||
#' @param value Value of new meta data list entry | ||
addMetaData = function(name, value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PavelBal Add and remove meta data as separate function in data repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there was this comment
#' If \code{value} is \code{NULL}, the entry with corresponding name is deleted from meta data set.
That I don't want to have. Let's create two methods instead
validateIsString(name) | ||
validateIsString(value) | ||
dataRepositoryTask <- getNetTask("DataRepositoryTask") | ||
rClr::clrCall(dataRepositoryTask, "AddMetaData", self$ref, name, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way to coherce a parameter to string in R. If yes, then we can remove the need for value to be a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as.character()
works e.g. for numerics but not for class objects, so maybe leave the check here.
R/data-set.R
Outdated
#' When changing from arithmetic to geometric error, the values are considered in as fraction (1 = 100%). | ||
#' When changing from geometric to arithmetic, the values are set to the same unit as \code{yErrorUnit}. | ||
yErrorType = function(value) { | ||
private$.createErrorColumnIfMissing() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when accessing Error properties, I create the column if it's not there. The way it was implemented @PavelBal , you would modify the original repo if loaded from file and I don't think this is pure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand... Now the original repo is modified the first time any property of yError is called, no?
#' | ||
#' @return A string containing the name of the enumerated constant in enumType whose value is enumValue; or null if no such constant is found. | ||
netEnumName <- function(enumType, enumValue){ | ||
netTypeObj <- rClr::clrGetType(enumType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PavelBal also fixed this
tests/testthat/test-data-set.R
Outdated
expect_equal(dataSet$yErrorValues, numeric(0)) | ||
}) | ||
|
||
test_that("it can print a data set", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PavelBal Also fixed this
R/utilities-data-set.R
Outdated
@@ -0,0 +1,46 @@ | |||
|
|||
makeColumn <- function(dataSet, property) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is intended to be private it seems. Let make it start with a "."
#' @return DataSet objects as dataframe with columns name, xValue, yValue, yErrorValues, | ||
#' xDimension, xUnit, yDimension, yUnit, yErrorType, yErrorUnit, yMolWeight | ||
#' @export | ||
dataSetToDataFrame <- function(dataSets) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need tests for this method, at least just to make sure that this does not crash with updated DataSet class
@PavelBal DLL updated to support the RemoveColumn |
Merge branch '544-data-set' of https://github.com/Open-Systems-Pharmacology/OSPSuite-R into 544-data-set
@msevestre I think this is ready. Tests for "toDataFrame" are WIP and can be added in another PR, I think. |
No description provided.