Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 690a8c9

Browse files
author
Raphael Sonabend
authored
Merge pull request #8 from xoopR/fix_extract
0.1.1
2 parents 4201d79 + 0578f2e commit 690a8c9

File tree

12 files changed

+156
-69
lines changed

12 files changed

+156
-69
lines changed

.github/workflows/r-cmd-check.yml renamed to .github/workflows/check-covr.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
2-
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
31
on:
4-
push:
5-
branches:
6-
- main
72
pull_request:
8-
branches:
9-
- main
3+
branches: main
4+
schedule:
5+
- cron: "0 4 * * *"
106

11-
name: R-CMD-check
7+
name: R-CMD-check / codecov
128

139
jobs:
14-
R-CMD-check:
10+
check-covr:
1511
runs-on: ${{ matrix.config.os }}
1612

1713
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
@@ -64,7 +60,7 @@ jobs:
6460
6561
- name: Install dependencies
6662
run: |
67-
install.packages(c("remotes"))
63+
install.packages("remotes")
6864
remotes::install_deps(dependencies = TRUE)
6965
remotes::install_cran("rcmdcheck")
7066
shell: Rscript {0}
@@ -87,3 +83,13 @@ jobs:
8783
with:
8884
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
8985
path: check
86+
87+
- name: Install covr
88+
if: ${{ github.event_name == 'pull_request' && runner.os == 'Linux' && matrix.config.r == 'release'}}
89+
run: install.packages('covr')
90+
shell: Rscript {0}
91+
92+
- name: Test coverage
93+
if: ${{ github.event_name == 'pull_request' && runner.os == 'Linux' && matrix.config.r == 'release'}}
94+
run: covr::codecov()
95+
shell: Rscript {0}

.github/workflows/codecov.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
name: Create Release
7+
8+
jobs:
9+
build:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Extract version
18+
run: |
19+
echo "PACKAGE_VERSION=$(grep '^Version' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
20+
echo "PACKAGE_NAME=$(grep '^Package' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
21+
22+
- name: Create Release
23+
id: create_release
24+
uses: actions/create-release@v1
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
27+
with:
28+
tag_name: v${{ env.PACKAGE_VERSION }}
29+
release_name: ${{ env.PACKAGE_NAME }} ${{ env.PACKAGE_VERSION }}
30+
body: |
31+
https://github.com/xoopR/param6/blob/main/NEWS.md
32+
draft: false
33+
prerelease: false
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
on:
2+
pull_request:
3+
branches: main
4+
5+
name: Version Check
6+
7+
jobs:
8+
all:
9+
runs-on: ${{ matrix.config.os }}
10+
11+
name: Version Check
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
config:
17+
- { os: ubuntu-latest, r: "release" }
18+
19+
env:
20+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
21+
RGL_USE_NULL: true
22+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
23+
24+
steps:
25+
- uses: actions/checkout@v2.1.1
26+
27+
- name: New version
28+
run: |
29+
echo "NEW_VERSION=$(grep '^Version' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
30+
31+
- uses: actions/checkout@v2
32+
with:
33+
ref: main
34+
35+
- name: Old version
36+
run: |
37+
echo "OLD_VERSION=$(grep '^Version' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
38+
39+
- name: Compare versions
40+
run: |
41+
Rscript -e "if (commandArgs(TRUE)[1] <= commandArgs(TRUE)[2]) stop('Package version has not been updated.')" ${{ env.NEW_VERSION }} ${{ env.OLD_VERSION }}
42+
43+
- name: Check version format
44+
run: |
45+
Rscript -e "if (!grepl('^[0-9]*\\\.[0-9]*\\\.[0-9]*$', commandArgs(TRUE)[1])) stop('Format of package version must be major.minor.patch.')" ${{ env.NEW_VERSION }}

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: param6
22
Title: A Fast and Lightweight R6 Parameter Interface
33
Description: By making use of 'set6', alongside the S3 and R6 paradigms, this package provides a fast and lightweight R6 interface for parameters and parameter sets.
4-
Version: 0.1.0
4+
Version: 0.1.1
55
Authors@R:
66
person(given = "Raphael",
77
family = "Sonabend",

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# param6 0.1.1
2+
3+
* Bug fix in extracting parameters from sets without tags
4+
* Allow option to stop `Dictionary` deep cloning R6 objects
5+
16
# param6 0.1.0
27

38
* Initial upload to CRAN.

R/Dictionary.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,20 @@ Dictionary <- R6Class("Dictionary",
6969
#' returned.
7070
#' @param keys (`character()`) \cr
7171
#' Keys of items to get.
72-
get = function(keys) .Dictionary__get(self, private, keys),
72+
#' @param clone (`logical(1)`) \cr
73+
#' If `TRUE` (default) then deep clones R6 objects if requested.
74+
get = function(keys, clone = TRUE) {
75+
.Dictionary__get(self, private, keys, clone)
76+
},
7377

7478
#' @description Gets the given items from the dictionary as list.
7579
#' @param keys (`character()`) \cr
7680
#' Keys of items to get.
77-
get_list = function(keys) .Dictionary__get_list(self, private, keys),
81+
#' @param clone (`logical(1)`) \cr
82+
#' If `TRUE` (default) then deep clones R6 objects if requested.
83+
get_list = function(keys, clone = TRUE) {
84+
.Dictionary__get_list(self, private, keys, clone)
85+
},
7886

7987
#' @description Checks if the given key is in the list, returns a logical.
8088
#' @param key (`character(1)`) \cr

R/Dictionary_methods.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
invisible(self)
2828
}
2929

30-
.Dictionary__get <- function(self, private, x) { # nolint
30+
.Dictionary__get <- function(self, private, x, clone = TRUE) { # nolint
3131
if (length(private$.types) == 1 || length(x) == 1) {
3232
x <- private$.items[checkmate::assert_subset(x, self$keys)]
3333
if (length(x) == 1) {
3434
x <- x[[1]]
35-
if (checkmate::testR6(x)) {
35+
if (checkmate::testR6(x) && clone) {
3636
x <- x$clone(deep = TRUE)
3737
}
3838
} else {
3939
x <- unlist(x)
4040
x <- sapply(x, function(.x) {
41-
if (checkmate::testR6(.x)) {
41+
if (checkmate::testR6(.x) && clone) {
4242
.x$clone(deep = TRUE)
4343
} else {
4444
.x
@@ -54,10 +54,10 @@
5454
}
5555
}
5656

57-
.Dictionary__get_list <- function(self, private, x) { # nolint
57+
.Dictionary__get_list <- function(self, private, x, clone = TRUE) { # nolint
5858
lapply(private$.items[checkmate::assert_subset(x, self$keys)],
5959
function(.x) {
60-
if (checkmate::testR6(.x)) {
60+
if (checkmate::testR6(.x) && clone) {
6161
.x$clone(deep = TRUE)
6262
} else {
6363
.x

R/ParameterSet_methods.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,13 @@
155155
inc_null = FALSE))
156156
values <- unname(.get_field(self, private$.value, id = ids))
157157

158-
tag <- unname(.get_field(self, private$.tags, id = ids))
159-
if (!is.null(prefix)) {
160-
unfix_tags <- unprefix(tag)
158+
if (length(private$.tags)) {
159+
tag <- unname(.get_field(self, private$.tags, id = ids))
160+
if (!is.null(prefix)) {
161+
unfix_tags <- unprefix(tag)
162+
}
163+
} else {
164+
tag <- unfix_tags <- rep(list(NULL), length(values))
161165
}
162166

163167
if (length(unfix_ids)) {

man/Dictionary.Rd

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)