Skip to content

Commit

Permalink
Merge commit '415ae254b9e4a0f74656b03e27dca2c4034d5027'
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Jan 27, 2025
2 parents 1ef1f23 + 415ae25 commit f7a771c
Showing 75 changed files with 1,074 additions and 619 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -9,8 +9,11 @@ on:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
@@ -25,21 +28,25 @@ jobs:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}
# use 4.0 or 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: 'oldrel-4'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
#- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
CXX14: g++
CXX14STD: -std=c++1y
CXX14FLAGS: -Wall -g -02

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

@@ -57,3 +64,8 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
10 changes: 7 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -9,7 +9,9 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
@@ -19,8 +21,10 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

@@ -39,7 +43,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
12 changes: 9 additions & 3 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@ on:
issue_comment:
types: [created]

name: Commands
name: pr-commands.yaml

permissions: read-all

jobs:
document:
@@ -13,8 +15,10 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
@@ -50,8 +54,10 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
25 changes: 18 additions & 7 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@ on:
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
@@ -15,36 +17,45 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -24,10 +24,10 @@ Imports:
generics (>= 0.1.2),
glue (>= 1.6.2),
hardhat (>= 1.0.0),
modelenv (>= 0.1.0),
parsnip (>= 1.2.1.9004),
modelenv (>= 0.2.0.9000),
parsnip (>= 1.0.2),
philentropy (>= 0.9.0),
prettyunits (>= 1.1.0),
Rfast (>= 2.0.6),
rlang (>= 1.0.6),
rsample (>= 1.0.0),
stats,
@@ -49,6 +49,8 @@ Suggests:
rmarkdown,
testthat (>= 3.0.0),
workflows (>= 1.1.2)
Remotes:
tidymodels/modelenv
Config/Needs/website: pkgdown, tidymodels, tidyverse, palmerpenguins,
patchwork, ggforce, tidyverse/tidytemplate
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# tidyclust (development version)

* The philentropy package is now used to calculate distances rather than Rfast. (#199)

# tidyclust 0.2.3

* Update to fix revdep issue for clustMixType. (#190)
46 changes: 38 additions & 8 deletions R/aaa.R
Original file line number Diff line number Diff line change
@@ -3,17 +3,47 @@

utils::globalVariables(
c(
".", "..object", ".cluster", ".iter_config", ".iter_model",
".iter_preprocessor", ".msg_model", ".submodels", "call_info", "cluster",
"component", "component_id", "compute_intercept", "data", "dist", "engine",
"engine2", "exposed", "func", "id", "iteration", "lab", "name", "neighbor",
"new_data", "object", "orig_label", "original", "predictor_indicators",
"remove_intercept", "seed", "sil_width", "splits", "tunable", "type",
"value", "x", "y"
".",
"..object",
".cluster",
".iter_config",
".iter_model",
".iter_preprocessor",
".msg_model",
".submodels",
"call_info",
"cluster",
"component",
"component_id",
"compute_intercept",
"data",
"dist",
"engine",
"engine2",
"exposed",
"func",
"id",
"iteration",
"lab",
"name",
"neighbor",
"new_data",
"object",
"orig_label",
"original",
"predictor_indicators",
"remove_intercept",
"seed",
"sil_width",
"splits",
"tunable",
"type",
"value",
"x",
"y"
)
)


release_bullets <- function() {
c(
"Run `knit_engine_docs()` and `devtools::document()` to update docs"
54 changes: 30 additions & 24 deletions R/append.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# https://github.com/tidymodels/tune/blob/main/R/pull.R#L136
append_predictions <- function(collection,
predictions,
split,
control,
.config = NULL) {
append_predictions <- function(
collection,
predictions,
split,
control,
.config = NULL
) {
if (!control$save_pred) {
return(NULL)
}
@@ -27,14 +29,16 @@ append_predictions <- function(collection,
dplyr::bind_rows(collection, predictions)
}

append_metrics <- function(workflow,
collection,
predictions,
metrics,
param_names,
event_level,
split,
.config = NULL) {
append_metrics <- function(
workflow,
collection,
predictions,
metrics,
param_names,
event_level,
split,
.config = NULL
) {
if (inherits(predictions, "try-error")) {
return(collection)
}
@@ -54,20 +58,22 @@ append_metrics <- function(workflow,
dplyr::bind_rows(collection, tmp_est)
}

append_extracts <- function(collection,
workflow,
grid,
split,
ctrl,
.config = NULL) {
append_extracts <- function(
collection,
workflow,
grid,
split,
ctrl,
.config = NULL
) {
extracts <-
grid %>%
dplyr::bind_cols(labels(split)) %>%
dplyr::mutate(
.extracts = list(
extract_details(workflow, ctrl$extract)
dplyr::bind_cols(labels(split)) %>%
dplyr::mutate(
.extracts = list(
extract_details(workflow, ctrl$extract)
)
)
)

if (!rlang::is_null(.config)) {
extracts <- cbind(extracts, .config)
13 changes: 8 additions & 5 deletions R/arguments.R
Original file line number Diff line number Diff line change
@@ -8,10 +8,12 @@ check_eng_args <- function(args, obj, core_args) {
if (length(common_args) > 0) {
args <- args[!(names(args) %in% common_args)]
common_args <- paste0(common_args, collapse = ", ")
rlang::warn(glue::glue(
"The following arguments cannot be manually modified ",
"and were removed: {common_args}."
))
rlang::warn(
glue::glue(
"The following arguments cannot be manually modified ",
"and were removed: {common_args}."
)
)
}
args
}
@@ -25,7 +27,8 @@ make_x_call <- function(object, target) {
}

object$method$fit$args[[unname(data_args["x"])]] <-
switch(target,
switch(
target,
none = rlang::expr(x),
data.frame = rlang::expr(maybe_data_frame(x)),
matrix = rlang::expr(maybe_matrix(x)),
14 changes: 11 additions & 3 deletions R/cluster_spec.R
Original file line number Diff line number Diff line change
@@ -10,11 +10,19 @@
#' @export
#' @keywords internal
new_cluster_spec <- function(cls, args, eng_args, mode, method, engine) {
modelenv::check_spec_mode_engine_val(model = cls, mode = mode, eng = engine)
modelenv::check_spec_mode_engine_val(
model = cls,
mode = mode,
eng = engine,
call = rlang::caller_env()
)

out <- list(
args = args, eng_args = eng_args,
mode = mode, method = method, engine = engine
args = args,
eng_args = eng_args,
mode = mode,
method = method,
engine = engine
)
class(out) <- make_classes_tidyclust(cls)
out <- modelenv::new_unsupervised_spec(out)
Loading

0 comments on commit f7a771c

Please sign in to comment.