Skip to content

Commit

Permalink
Fix problems in winbuilder check due to non-availability of kanjistat…
Browse files Browse the repository at this point in the history
….data
  • Loading branch information
dschuhmacher committed May 29, 2024
1 parent 5202cb2 commit c2ec801
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Suggests:
testthat (>= 3.0.0),
tibble,
withr
Remotes: dschuhmacher/kanjistat.data
Additional_repositories: https://dschuhmacher.github.io/drat
License: GPL (>= 3)
Encoding: UTF-8
LazyData: true
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# kanjistat 0.13.2.9100 (development version)
# kanjistat 0.14.0 (2024-05-29)

## New features

Expand Down
1 change: 1 addition & 0 deletions R/stroke_edit_distance.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ strokesignature2 <- function(kvec) {
#' }
#'
sedist <- function(k1, k2, type = c("full", "before_slash", "first")) {
check_for_data()
type <- match.arg(type)
kvec1 <- convert_kanji(k1, "kanjivec", simplify=FALSE)
if (is(kvec1, "kanjivec")) { # if k1 was just a single kanji specified in atomic form
Expand Down
31 changes: 17 additions & 14 deletions tests/testthat/test-stroke_edit_distance.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# contains indirectly also tests for values of dstrokedit

test_that("sedist, same as Yencken, type does not matter", {
ind1 <- 384L
ind2 <- c(93L, 413L, 786L, 895L, 1020L, 1137L, 1282L, 1359L, 1433L, 1642L, 1959L)
res <- sedist(ind1, ind2)
expect_equal(res, matrix(dstrokedit[ind1,ind2], 1, length(ind2)), tolerance = 1e-6)
expected <- structure(c(0.25, 0.25, 0.33333333333333331, 0.30769230769230771,
0.30769230769230771, 0.41666666666666669, 0.41666666666666669,
0.25, 0.41666666666666669, 0.41666666666666669, 0.41666666666666669
), dim = c(1L, 11L))
expect_equal(res, expected)
expect_equal(sedist(ind1, ind2, type="before_slash"), expected)
expect_equal(sedist(ind1, ind2, type="first"), expected)
skip_if_not_installed("spatstat.data")
ind1 <- 384L
ind2 <- c(93L, 413L, 786L, 895L, 1020L, 1137L, 1282L, 1359L, 1433L, 1642L, 1959L)
res <- sedist(ind1, ind2)
expect_equal(res, matrix(dstrokedit[ind1,ind2], 1, length(ind2)), tolerance = 1e-6)
expected <- structure(c(0.25, 0.25, 0.33333333333333331, 0.30769230769230771,
0.30769230769230771, 0.41666666666666669, 0.41666666666666669,
0.25, 0.41666666666666669, 0.41666666666666669, 0.41666666666666669
), dim = c(1L, 11L))
expect_equal(res, expected)
expect_equal(sedist(ind1, ind2, type="before_slash"), expected)
expect_equal(sedist(ind1, ind2, type="first"), expected)
})


Expand All @@ -28,9 +29,11 @@ test_that("sedist, different from Yencken, type does matter", {
0.33333333333333331, 0.33333333333333331, 0.2857142857142857,
0.5, 0.44444444444444442) # sedist first
expect_equal(dstrokedit[ind1,ind2], expected0)
expect_equal( as.vector(sedist(ind1, ind2, type="full")), expected1)
expect_equal( as.vector(sedist(ind1, ind2, type="before_slash")), expected1)
expect_equal( as.vector(sedist(ind1, ind2, type="first")), expected2)
#
skip_if_not_installed("spatstat.data")
expect_equal( as.vector(sedist(ind1, ind2, type="full")), expected1)
expect_equal( as.vector(sedist(ind1, ind2, type="before_slash")), expected1)
expect_equal( as.vector(sedist(ind1, ind2, type="first")), expected2)
})
# first entry checked manually using strokesigraw and historical stroke type data by Lars Yencken
# 観 4,2,3,4,3,4,2b,3a,2b,2b,2b,3,11a,2a,2a,2a,4,19 (500)
Expand Down

0 comments on commit c2ec801

Please sign in to comment.