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

Use rSharp instead of rClr #1376

Merged
merged 50 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
64b2904
Added authors to _pkgdown.yml
PavelBal Mar 1, 2024
c3aa982
- Exchange rClr for rSharp as dependency
PavelBal Mar 1, 2024
cb252aa
Docs
PavelBal Mar 1, 2024
a9ff16f
Replace all calls to rClr by calls to rShapr
PavelBal Mar 1, 2024
afa99c5
Replace `clrLoadAssembly` by `loadAssembly`
PavelBal Mar 1, 2024
5e6ef83
- Replace `rClrCallStatic` by `callStatic`
PavelBal Mar 1, 2024
0900614
`getEnumNames`
PavelBal Mar 1, 2024
d17ffd0
Use correct package reference in test
PavelBal Mar 5, 2024
7726ebc
- Remove enc2utf, as conversion is done in rSharp
PavelBal Mar 5, 2024
c4ea6f6
Moved some wrappers to NetObject in rSharp
PavelBal Mar 5, 2024
ec28d58
Loading package works
PavelBal Mar 5, 2024
4f3f2b5
.wrapProperty
PavelBal Mar 6, 2024
d2f0e17
Replace all clrGet
PavelBal Mar 6, 2024
44901ff
Replace all clrSet
PavelBal Mar 6, 2024
904681c
Replace clrCall
PavelBal Mar 7, 2024
2cfd437
Replace clrNew
PavelBal Mar 7, 2024
ea2db97
DotNetWrapper expects a NetObject and not a pointer.
PavelBal Mar 7, 2024
7f40e86
Remove ref
PavelBal Mar 7, 2024
c2e4b54
Fix all initilialize
PavelBal Mar 7, 2024
6b78e5b
Remove direct pointers
PavelBal Mar 7, 2024
58777e4
Styler
PavelBal Mar 7, 2024
4698e28
Documentation
PavelBal Mar 7, 2024
98da2e8
Correct calling of private print methods
PavelBal Mar 8, 2024
379610f
Prepend '.' to wrapPropertyReadOnly
PavelBal Mar 8, 2024
533aa3d
Prepend '.' to throwPropertyISREadONly
PavelBal Mar 8, 2024
cbd6af7
Fix test for dotNetWrapper
PavelBal Mar 8, 2024
ddf7295
Fix clrGetType to getType
PavelBal Mar 11, 2024
9d5057e
use NPOI for .NET Core
rwmcintosh Mar 11, 2024
9e35238
Fix .wrapProperty
PavelBal Mar 12, 2024
8e8e505
Fix print calls in DataCombined
PavelBal Mar 12, 2024
8334e63
Update snapshots for the use with the latest TLF
PavelBal Mar 12, 2024
9b77397
Remove unnecessary libs
PavelBal Mar 12, 2024
9e9bf0d
Docs
PavelBal Mar 12, 2024
11fc4d2
Merge branch 'develop' of https://github.com/Open-Systems-Pharmacolog…
PavelBal May 22, 2024
4ac9572
Adjust README.Rmd
PavelBal May 22, 2024
bcc398f
Remove appveyor for R 3.6
PavelBal May 22, 2024
3c5cd80
Skip individual and simulation tests
PavelBal May 22, 2024
e78a3f8
Moved a test using population creation from simulation-results test
PavelBal May 22, 2024
f557c7e
Merge branch 'develop' of https://github.com/Open-Systems-Pharmacolog…
PavelBal May 22, 2024
19fe1fa
Update snapshots.
PavelBal May 22, 2024
6c5fd9f
Delete "install-packages.R"
PavelBal May 22, 2024
0f9dd55
Update documentation
PavelBal May 22, 2024
568deb5
Move vignettes that use PK-Sim functions to WIP folder
PavelBal May 22, 2024
63dcd58
Fixed author roles
PavelBal May 22, 2024
3259623
Fix role
PavelBal May 22, 2024
052bf1d
unzip rSharp archive before installing it
Felixmil May 23, 2024
fd01545
correct typo
Felixmil May 23, 2024
3b829cd
delete and ignore tests/testthat/*.pdf
Felixmil May 23, 2024
a05bf4a
Tweak test to avoid writing file in package directory
Felixmil May 23, 2024
30fa5fd
update c++ libs (#1415)
Yuri05 May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ vignettes/*.pdf
rsconnect/
doc
Meta

# test artifacts
tests/testthat/*.pdf
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package: ospsuite
Title: R package to manipulate OSPSuite Models
Version: 12.0.0
Authors@R:
c(person("Open-Systems-Pharmacology Community", role = "cph"),
c(person("Open-Systems-Pharmacology Community", role = c("cph", "fnd")),
person("Michael", "Sevestre", role = c("aut", "cre"), email = "michael@design2code.ca"),
person("Pavel", "Balazki", role = "aut"),
person("Juri", "Solodenko", role = "aut", comment = c(ORCID = "0000-0001-6922-588X")),
Expand All @@ -20,7 +20,7 @@ BugReports:
https://github.com/open-systems-pharmacology/ospsuite-r/issues
Depends:
R (>= 3.6),
rClr (>= 0.9.1)
rSharp
Imports:
dplyr (>= 1.0.0),
ospsuite.utils (>= 1.4.0),
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export(validateDimension)
export(validateUnit)
import(data.table)
import(ospsuite.utils)
import(rClr)
import(rSharp)
import(tidyr)
import(tlf)
import(xml2)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
`quantityOrDimension` (was `dimension` previously). It can now use objects
of class `Quantity` as inputs, to be consistent with the `toBaseUnit()`
function.
- The package gains a new dependency `{rSharp}`

## Major Changes

Expand All @@ -44,6 +45,7 @@
- `plotPopulationTimeProfile()` has a new `aggregation` argument that allow
the user to choose between quantiles, arithmetic and geometric aggregations
of y.
- The package loses dependency `{rClr}`


## Minor improvements and bug fixes
Expand Down
14 changes: 7 additions & 7 deletions R/aging-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ AgingData <- R6::R6Class("AgingData",
active = list(
#' @field individualIds Array of individual ids (corresponding to the individualId column of the aging table)
individualIds = function(value) {
private$wrapIntegerProperty("IndividualIds", value)
private$.wrapProperty("IndividualIds", value, asInteger = TRUE)
Copy link
Member Author

Choose a reason for hiding this comment

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

},
#' @field parameterPaths Array of parameter paths (corresponding to the ParameterPath column of the aging table)
parameterPaths = function(value) {
private$wrapProperty("ParameterPaths", value)
private$.wrapProperty("ParameterPaths", 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.

Internal methods and functions should have a . prefix.

},
#' @field times Array of time values (corresponding to the Time column of the aging table)
times = function(value) {
private$wrapProperty("Times", value)
private$.wrapProperty("Times", value)
},
#' @field values Array of parameter values (corresponding to the Value column of the aging table)
values = function(value) {
private$wrapProperty("Values", value)
private$.wrapProperty("Values", value)
}
),
public = list(
#' @description
#' Initialize a new instance of the class
#' @return A new `OSPSuite.R.Domain.AgingData` object.
initialize = function() {
ref <- rClr::clrNew("OSPSuite.R.Domain.AgingData")
super$initialize(ref)
netObj <- rSharp::newObjectFromName("OSPSuite.R.Domain.AgingData")
Copy link
Member Author

Choose a reason for hiding this comment

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

ref were S4 objects in rClr. In rSharp, we directly use R6 objects as wrapper around pointers, and DonNetWrapper inherits from it. Therefore, all classes in ospsuite-r that wrap a .NET class should inherit from NetObject implemented in rSharp.

super$initialize(netObj)
Copy link
Member Author

Choose a reason for hiding this comment

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

The NetObject class from rSharp requires a pointer to .NET object in the constructor. DotNetWrapper extends it for accepting valid NetObject instances.

},

#' @description
#' Print the object to the console
#' @param ... Rest arguments.
print = function(...) {
private$printClass()
private$.printClass()
invisible(self)
}
)
Expand Down
13 changes: 2 additions & 11 deletions R/api-config.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@ ApiConfig <- R6::R6Class(
active = list(
#' @field pkParametersFilePath Full path of the pkParameter file
pkParametersFilePath = function(value) {
private$wrapProperty("PKParametersFilePath", value)
private$.wrapProperty("PKParametersFilePath", value)
},
#' @field dimensionFilePath Full path of the dimension file
dimensionFilePath = function(value) {
private$wrapProperty("DimensionFilePath", value)
}
),
public = list(
#' @description
#' Initialize a new instance of the class
#' @return A new `ApiConfig` object.
initialize = function() {
ref <- rClr::clrNew("OSPSuite.R.ApiConfig")
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 done in .initPackage().

super$initialize(ref)
private$.wrapProperty("DimensionFilePath", value)
}
)
)
8 changes: 4 additions & 4 deletions R/application.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ Application <- R6::R6Class(
#' @field startTime Start time of application instance (Read-Only)
startTime = function(value) {
if (missing(value)) {
.toObjectType(private$wrapReadOnlyProperty("StartTime", value), Parameter)
.toObjectType(private$.wrapReadOnlyProperty("StartTime", value), Parameter)
}
},
#' @field infusionTime Infusion time of application instance or null if undefined (Read-Only)
infusionTime = function(value) {
if (missing(value)) {
.toObjectType(private$wrapReadOnlyProperty("InfusionTime", value), Parameter)
.toObjectType(private$.wrapReadOnlyProperty("InfusionTime", value), Parameter)
}
},
#' @field drugMass Applied drugmass of the application instance of null if undefined (Read-Only)
drugMass = function(value) {
if (missing(value)) {
.toObjectType(private$wrapReadOnlyProperty("DrugMass", value), Parameter)
.toObjectType(private$.wrapReadOnlyProperty("DrugMass", value), Parameter)
}
}
),
Expand All @@ -32,7 +32,7 @@ Application <- R6::R6Class(
#' Print the object to the console
#' @param ... Rest arguments.
print = function(...) {
private$printClass()
private$.printClass()
self$startTime$printValue()

if (!is.null(self$infusionTime)) {
Expand Down
8 changes: 4 additions & 4 deletions R/container.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ Container <- R6::R6Class(
active = list(
#' @field containerType Type of container
containerType = function(value) {
private$wrapReadOnlyProperty("ContainerTypeAsString", value)
private$.wrapReadOnlyProperty("ContainerTypeAsString", value)
}
),
public = list(
#' @description
#' Print the object to the console
#' @param ... Rest arguments.
print = function(...) {
private$printClass()
private$printLine("Container type", self$containerType)
private$printLine("Path", self$path)
private$.printClass()
private$.printLine("Container type", self$containerType)
private$.printLine("Path", self$path)
invisible(self)
}
)
Expand Down
37 changes: 16 additions & 21 deletions R/data-column.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,69 +12,64 @@ DataColumn <- R6::R6Class(
active = list(
#' @field values Returns the values defined in the column
values = function(value) {
private$wrapVectorProperty("Value", "ValuesAsArray", value, "ValuesAsArray")
private$.wrapVectorProperty("Value", "ValuesAsArray", value, "ValuesAsArray")
},
#' @field name Returns the name of the column (Read-Only)
name = function(value) {
private$wrapReadOnlyProperty("Name", value)
private$.wrapReadOnlyProperty("Name", value)
},
#' @field unit The base unit in which the values are defined (Read-Only)
unit = function(value) {
if (!missing(value)) {
value <- enc2utf8(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.

}
private$.unit <- private$wrapExtensionMethodCached(WITH_DIMENSION_EXTENSION, "BaseUnitName", "unit", private$.unit, value)
private$.unit <- private$.wrapExtensionMethodCached(WITH_DIMENSION_EXTENSION, "BaseUnitName", "unit", private$.unit, value)
return(private$.unit)
},
#' @field displayUnit The unit in which the values should be displayed
displayUnit = function(value) {
if (missing(value)) {
return(private$wrapExtensionMethod(WITH_DISPLAY_UNIT_EXTENSION, "DisplayUnitName", "displayUnit", value))
return(private$.wrapExtensionMethod(WITH_DISPLAY_UNIT_EXTENSION, "DisplayUnitName", "displayUnit", value))
}
value <- enc2utf8(value)
dimension <- getDimensionByName(self$dimension)
# 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)
unit <- dimension$call("FindUnit", value, TRUE)
Copy link
Member Author

Choose a reason for hiding this comment

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

New syntax for calling a method of an object.

if (is.null(unit)) {
stop(messages$errorUnitNotSupported(unit = value, dimension = self$dimension))
}
rClr::clrSet(self$ref, "DisplayUnit", unit)
self$set("DisplayUnit", unit)
},
#' @field dimension The dimension of the values
dimension = function(value) {
if (missing(value)) {
if (is.null(private$.dimension)) {
private$.dimension <- private$wrapExtensionMethodCached(WITH_DIMENSION_EXTENSION, "DimensionName", "dimension", private$.dimension, value)
private$.dimension <- private$.wrapExtensionMethodCached(WITH_DIMENSION_EXTENSION, "DimensionName", "dimension", private$.dimension, value)
}
return(private$.dimension)
}
value <- enc2utf8(value)
# updating the dimension
rClr::clrSet(self$ref, "Dimension", getDimensionByName(value))
self$set("Dimension", getDimensionByName(value))
private$.dimension <- NULL
private$.unit <- NULL
},
#' @field molWeight Molecular weight of associated observed data in internal unit
#' In no molecular weight is defined, the value is `NULL`
molWeight = function(value) {
dataInfo <- rClr::clrGet(self$ref, "DataInfo")
dataInfo <- self$get("DataInfo")
if (missing(value)) {
return(rClr::clrGet(dataInfo, "MolWeight"))
return(dataInfo$get("MolWeight"))
}

validateIsNumeric(value)
rClr::clrSet(dataInfo, "MolWeight", value)
dataInfo$set("MolWeight", value)
},
#' @field LLOQ Lower Limit Of Quantification.
#' In no LLOQ is defined, the value is `NULL`
LLOQ = function(value) {
dataInfo <- rClr::clrGet(self$ref, "DataInfo")
dataInfo <- self$get("DataInfo")
if (missing(value)) {
return(rClr::clrGet(dataInfo, "LLOQAsDouble"))
return(dataInfo$get("LLOQAsDouble"))
}

validateIsNumeric(value)
rClr::clrSet(dataInfo, "LLOQAsDouble", value)
dataInfo$set("LLOQAsDouble", value)
}
),
public = list(
Expand All @@ -83,9 +78,9 @@ DataColumn <- R6::R6Class(
#' @param ... Rest arguments.
print = function(...) {
if (self$unit == "") {
private$printLine(self$name)
private$.printLine(self$name)
} else {
private$printLine(self$name, paste0("base unit: [", self$unit, "]"))
private$.printLine(self$name, paste0("base unit: [", self$unit, "]"))
}
invisible(self)
}
Expand Down
Loading