Skip to content

Commit

Permalink
#103: add regression test and update NEWS
Browse files Browse the repository at this point in the history
  • Loading branch information
jlmelville committed Nov 3, 2022
1 parent d6a0116 commit d0f21c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
16 changes: 11 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ Based on a request by user

## Bug fixes and minor improvements

* If `n_components` was greater than `n_neighbors` then `umap_transform` would
crash the R session. Thank you to [ChVav](https://github.com/ChVav) for
reporting this (<https://github.com/jlmelville/uwot/issues/102>).
* Some new checks for NA values in input data have been added. Also a warning
will be emitted if `n_components` seems to have been set too high.
* A new setting for `init_sdev`: set `init_sdev = "range"` and initial
coordinates will be range-scaled so each column takes values between 0-10. This
pre-processing was added to the Python UMAP package at some point after `uwot`
Expand All @@ -40,6 +35,17 @@ parameters `a` and `b` are set directly when invoking `umap`, then both
feature was added in response to a question from
[kjiang18](https://github.com/kjiang18)
(<https://github.com/jlmelville/uwot/issues/95>).
* Some new checks for NA values in input data have been added. Also a warning
will be emitted if `n_components` seems to have been set too high.
* If `n_components` was greater than `n_neighbors` then `umap_transform` would
crash the R session. Thank you to [ChVav](https://github.com/ChVav) for
reporting this (<https://github.com/jlmelville/uwot/issues/102>).
* Using `umap_transform` with a model where `dens_scale` was set could cause
a segmentation fault, destroying the session. Even if it didn't it could give
an entirely artifactual "ring" structure. Thank you
[FemkeSmit](https://github.com/FemkeSmit) for reporting this and providing
assistance in diagnosing the underlying cause
(<https://github.com/jlmelville/uwot/issues/103>).

# uwot 0.1.14

Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/test_transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,27 @@ test_that("return transform fgraph (#104)", {
expect_equal(length(test_umap$rho), 10)
})

# regression tests the bug reported in #103 where ai and aj were transposed and
# also the data being transformed is larger than the original data
# this at best leads to a wide ring structure being formed for some of the
# transformed data (but may also lead to NaN or a seg fault). This test checks
# that the transformed data doesn't cover a large range, which would be
# diagnostic of the ring forming: with the error present, the range of
# coordinates is around c(-40, 40) vs c(-6, 6) otherwise
test_that("leopold transform (#103)", {
iris_species_12 <- iris[1:100, ]
iris_species_3 <- iris[101:150, ]

set.seed(42)
iris_s3_leopold <- umap(iris_species_3, dens_scale = 1, ret_model = TRUE)

set.seed(42)
iris_s12_transform <- umap_transform(iris_species_12, iris_s3_leopold)

transform_range <- range(iris_s12_transform)
# as long as the coordinates aren't in the c(-40, 40) range then we are
# probably ok
expect_gt(transform_range[1], -10.0)
expect_lt(transform_range[2], 10.0)
})

0 comments on commit d0f21c1

Please sign in to comment.