Skip to content
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

Merged
merged 17 commits into from
Aug 5, 2021
Merged

WIP #544 #546

merged 17 commits into from
Aug 5, 2021

Conversation

msevestre
Copy link
Member

No description provided.

@msevestre
Copy link
Member Author

This is just the beginning... and it should not be merged at all

@msevestre msevestre requested review from PavelBal and Yuri05 July 2, 2021 13:53

private$throwPropertyIsReadonly("baseGrid")
private$.baseGrid <- value
private$wrapProperty("BaseGrid", value$ref)
Copy link
Member Author

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,
Copy link
Member Author

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){
Copy link
Member Author

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")))
Copy link
Member Author

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)

Copy link
Member Author

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

@msevestre
Copy link
Member Author

@PavelBal Tagging @hannaei as well here for review

Copy link
Member Author

@msevestre msevestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hannaei @PavelBal @Yuri05
Please review. I think this is in a good place for @hannaei or @PavelBal to continue now. I have added capabilities in core to update dimension and unit

values = function(value) {
private$wrapReadOnlyProperty("ValuesAsArray", value)
private$wrapProperty("ValuesAsArray", value)
Copy link
Member Author

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))
Copy link
Member Author

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
Copy link
Member Author

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)
Copy link
Member Author

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 seta 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(...) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hannaei and @PavelBal
Here the print method should be enhanced to show the data in a user friendly fashion. I'll leave that to you

values <- private$getColumnValues(column)

#now we need to update dimension and display unit
column$displayUnit <- unit
Copy link
Member Author

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.

Copy link
Member

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]]
Copy link
Member Author

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-commenter
Copy link

codecov-commenter commented Jul 2, 2021

Codecov Report

Merging #546 (e5624f4) into develop (1832b04) will decrease coverage by 0.12%.
The diff coverage is 84.15%.

❗ Current head e5624f4 differs from pull request most recent head 45587b6. Consider uploading reports for the commit 45587b6 to get more accurate results
Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
R/messages.R 100.00% <ø> (ø)
R/object-base.R 100.00% <ø> (ø)
R/utilities-data-set.R 0.00% <0.00%> (ø)
R/data-repository.R 88.37% <90.00%> (+4.37%) ⬆️
R/data-column.R 95.45% <94.73%> (+81.16%) ⬆️
R/data-set.R 94.82% <94.82%> (ø)
R/dot-net-wrapper.R 92.85% <100.00%> (+0.35%) ⬆️
R/utilities-units.R 93.82% <100.00%> (+0.23%) ⬆️
R/utilities.R 100.00% <100.00%> (ø)
... and 1 more

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 1832b04...45587b6. Read the comment docs.

@PavelBal
Copy link
Member

PavelBal commented Jul 5, 2021

@msevestre Should we remove "utilities-data-mapping" and completely replace it by "utilities-data-set"? E.g. loadDataRepositoryFromPKML would become loadDataSetFromPKML and create a data set object.

@PavelBal
Copy link
Member

PavelBal commented Jul 5, 2021

Should we maybe fork this so we can merge PRs? I do not want to have a huge PR without intermediate states.

PavelBal and others added 5 commits July 27, 2021 11:31
* Continue working on DataSet

* Update man on DataColumn

* WIP DataSet

adding (failing) test
@msevestre msevestre marked this pull request as ready for review July 27, 2021 21:49
Copy link
Member Author

@msevestre msevestre left a 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) {
Copy link
Member Author

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.

Copy link
Member Author

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)
Copy link
Member Author

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

Copy link
Member

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()
Copy link
Member Author

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

Copy link
Member

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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PavelBal also fixed this

expect_equal(dataSet$yErrorValues, numeric(0))
})

test_that("it can print a data set", {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PavelBal Also fixed this

@@ -0,0 +1,46 @@

makeColumn <- function(dataSet, property) {
Copy link
Member Author

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) {
Copy link
Member Author

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

@msevestre
Copy link
Member Author

@PavelBal DLL updated to support the RemoveColumn

@PavelBal
Copy link
Member

PavelBal commented Aug 5, 2021

@msevestre I think this is ready. Tests for "toDataFrame" are WIP and can be added in another PR, I think.

@msevestre msevestre merged commit 7139c40 into develop Aug 5, 2021
@msevestre msevestre deleted the 544-data-set branch August 5, 2021 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants