Skip to content

Commit

Permalink
Merge pull request #8 from imbi-heidelberg/language_support
Browse files Browse the repository at this point in the history
100% code coverage
  • Loading branch information
max-pilz authored May 2, 2024
2 parents 6e3dfc3 + a3c1112 commit 2e4dbb7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
12 changes: 6 additions & 6 deletions tests/testthat/data/test_data_changed.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ID;DECISION;author;title;Abstract
1;exclude;John Doe 2019;A beautiful paper;Lorem ipsum dolor sit mathematics, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit mathematics commodo magna eros quis urna.
2;exclude;John Doe and Jane Roe 2019;A very beautiful paper;Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.
3;include;John Doe and Jane Roe 2020;An enormously interesting paper;Aenean nec lorem. hello hello hello In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.
4;include;Alan Mathison Turing;The chemical basis of morphogenesis;It is suggested that a system of chemical substances, called morphogens, reacting together and diffusing through a tissue, is adequate to for the main phenomena of morphogenesis. Such a system, although it may originally be quite homogeneous, may later develop a pattern or structure due to an instability of the homogeneous equilibrium, which is triggered off by random disturbances. Such reaction-diffusion systems are considered in some detail in the case of an isolated ring of cells, a mathematically convenient, though biologically unusual system. The investigation is chiefly concerned with the onset of instability. It is found that there are six essentially different forms which this may take. In the most interesting form stationary waves appear on the ring. It is suggested that this might , for instance, for the tentacle patterns on Hydra and for whorled leaves. A system of reactions and diffusion on a sphere is also considered. Such a system appears to for gastrulation. Another reaction system in two dimensions gives rise to patterns reminiscent of dappling. It is also suggested that stationary waves in two dimensions could for the phenomena of phyllotaxis. The purpose of this paper is to discuss a possible mechanism by which the genes of a zygote may determine the anatomical structure of the resulting organism. The theory does not make any new hypotheses, it merely suggests that certain well-known physical laws are sufficient to for many of the facts. The full understanding of the paper requires a good knowledge of mathematics, some biology, and some elementary chemistry. Since readers cannot be expected to be experts in all of these subjects, a number of elementary facts are explained, which can be found in text-books, but whose omission would make the paper difficult reading.
5;exclude;Author;A paper without abstract;NA
ID;author;title;Abstract
1;John Doe 2019;A beautiful paper;Lorem ipsum dolor sit mathematics, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit mathematics commodo magna eros quis urna.
2;John Doe and Jane Roe 2019;A very beautiful paper;Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.
3;John Doe and Jane Roe 2020;An enormously interesting paper;Aenean nec lorem. hello hello hello In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.
4;Alan Mathison Turing;The chemical basis of morphogenesis;It is suggested that a system of chemical substances, called morphogens, reacting together and diffusing through a tissue, is adequate to for the main phenomena of morphogenesis. Such a system, although it may originally be quite homogeneous, may later develop a pattern or structure due to an instability of the homogeneous equilibrium, which is triggered off by random disturbances. Such reaction-diffusion systems are considered in some detail in the case of an isolated ring of cells, a mathematically convenient, though biologically unusual system. The investigation is chiefly concerned with the onset of instability. It is found that there are six essentially different forms which this may take. In the most interesting form stationary waves appear on the ring. It is suggested that this might , for instance, for the tentacle patterns on Hydra and for whorled leaves. A system of reactions and diffusion on a sphere is also considered. Such a system appears to for gastrulation. Another reaction system in two dimensions gives rise to patterns reminiscent of dappling. It is also suggested that stationary waves in two dimensions could for the phenomena of phyllotaxis. The purpose of this paper is to discuss a possible mechanism by which the genes of a zygote may determine the anatomical structure of the resulting organism. The theory does not make any new hypotheses, it merely suggests that certain well-known physical laws are sufficient to for many of the facts. The full understanding of the paper requires a good knowledge of mathematics, some biology, and some elementary chemistry. Since readers cannot be expected to be experts in all of these subjects, a number of elementary facts are explained, which can be found in text-books, but whose omission would make the paper difficult reading.
5;Author;A paper without abstract;NA
11 changes: 11 additions & 0 deletions tests/testthat/test_constructor.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ test_that("constructor works", {
MetaNLP(csv), obj
)

# data frame can be created when column decision does not exist
source_path <- test_path("data", "test_data_changed.csv")
obj_no_dec <- MetaNLP(source_path)

expect_true(
is.null(obj_no_dec@data_frame$decision_)
)
expect_true(
!is.null(obj@data_frame$decision_)
)

# throw an error if one column is missing
csv1 <- csv[-1]
csv2 <- csv[-4]
Expand Down
9 changes: 8 additions & 1 deletion tests/testthat/test_selection.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ test_that("Feature selection works", {
all(temp)
)

# test 6: the optino "1se" leads to fewer columns than "min"
# test 6: is a seed is set, "lambda = avg" and "lambda = min" return the same results

sel_feat_const_avg <- select_features(obj, lambda = "avg", seed = 42)
expect_equal(
sel_feat_const@data_frame, sel_feat_const_avg@data_frame
)

# test 7: the option "1se" leads to fewer columns than "min"
sel_feat_1se <- select_features(obj, lambda = "1se", seed = 42)

expect_lt(
Expand Down
17 changes: 13 additions & 4 deletions tests/testthat/test_writecsv.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,43 @@ test_that("write_csv works correctly", {
source_path <- test_path("data", "test_data.csv")
obj <- MetaNLP(source_path)

# test 1: default file name is correct
# test 1: when no path is specified, file is saved in working directory
write_csv(obj)

expect_true(
file.exists("train_wcm.csv")
)

# test 2: default file name is correct
write_csv(obj, path = test_path("data"))
source_path2 <- test_path("data", "train_wcm.csv")
expect_no_error(
read.csv2(source_path2)
)

# test 2: file name can be changed
# test 3: file name can be changed
write_csv(obj, path = test_path("data"), type = "test")
source_path3 <- test_path("data", "test_wcm.csv")
expect_no_error(
read.csv2(source_path3)
)

# test 3: correct data frame is saved
# test 4: correct data frame is saved
data_read <- data.frame(read.csv2(source_path3))
expect_true(
all(obj@data_frame == data_read)
)

# test 4: default file name can be overwritten
# test 5: default file name can be overwritten
source_path4 <- test_path("data", "written.csv")
write_csv(obj, source_path4)

expect_no_error(
read.csv2(source_path4)
)

# remove all the files
file.remove("train_wcm.csv")
file.remove(source_path2)
file.remove(source_path3)
file.remove(source_path4)
Expand Down

0 comments on commit 2e4dbb7

Please sign in to comment.