Skip to content
Snippets Groups Projects
Commit 39bd9611 authored by Ruben Heinrich's avatar Ruben Heinrich
Browse files

[base] docs and NAMESPACE cleanup

parent c3e744a8
No related branches found
No related tags found
1 merge request!6Merge branch 7 fixed functionality into master
...@@ -8,7 +8,7 @@ test_that("export_gml works", { ...@@ -8,7 +8,7 @@ test_that("export_gml works", {
dir.create(test_path) dir.create(test_path)
# Define gml object # Define gml object
test_gml <- r2ogs6_gml( test_gml <- OGS6_gml$new(
name = "test_geometry", name = "test_geometry",
points = tibble::tibble( points = tibble::tibble(
x = c(0, 0, 0, 0, 1, 1, 1, 1), x = c(0, 0, 0, 0, 1, 1, 1, 1),
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
skip_if_python_modules_missing <- function() { skip_if_python_modules_missing <- function() {
used_modules <- c("vtk", used_modules <- c("vtk",
"vtk.numpy_interface.dataset_adapter", "vtk.numpy_interface.dataset_adapter")
"zlib")
lapply(used_modules, function(x){ lapply(used_modules, function(x){
if(!reticulate::py_module_available(x)){ if(!reticulate::py_module_available(x)){
...@@ -45,7 +44,7 @@ test_that("OGS6_pvd$get_timestep_by_vtu_path works", { ...@@ -45,7 +44,7 @@ test_that("OGS6_pvd$get_timestep_by_vtu_path works", {
timestep <- ogs6_pvd$get_timestep_by_vtu_path(vtu_path = vtu_path) timestep <- ogs6_pvd$get_timestep_by_vtu_path(vtu_path = vtu_path)
expect_equal(timestep, "99.9999999999986") expect_equal(timestep, 99.9999999999986)
}) })
...@@ -63,36 +62,55 @@ test_that("OGS6_pvd$get_PointData_time_tibble works", { ...@@ -63,36 +62,55 @@ test_that("OGS6_pvd$get_PointData_time_tibble works", {
"velocity") "velocity")
time_tibble <- ogs6_pvd$get_PointData_time_tibble(Names = Names) time_tibble <- ogs6_pvd$get_PointData_time_tibble(Names = Names)
expect_equal(length(time_tibble), 341)
})
test_that("OGS6_pvd$get_PointData_at_timestep works", {
skip_if_python_modules_missing()
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
expect_equal(length(time_tibble), 2) point_data <- ogs6_pvd$get_PointData_at_timestep(point_ids = 0,
Names = "HydraulicFlow",
timestep = 0)
expect_equal(length(point_data), 1)
expect_equal(names(point_data), "p0")
}) })
#===== OGS6_vtu ===== #===== OGS6_vtu =====
test_that("read_in_vtu works", { test_that("OGS6_vtu initialization works", {
vtu_path <- system.file("extdata/benchmarks/flow_free_expansion", vtu_path <- system.file("extdata/benchmarks/flow_free_expansion",
"cube_1x1x1.vtu", "cube_1x1x1.vtu",
package = "r2ogs6") package = "r2ogs6")
ogs6_vtu <- read_in_vtu(vtu_path = vtu_path) vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path)
expect_equal("vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid" %in% expect_equal("vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid" %in%
class(ogs6_vtu$vtkUnstructuredGrid), TRUE) class(vtu_obj$vtkUnstructuredGrid), TRUE)
}) })
#===== generate_structured_mesh ===== #===== generate_structured_mesh =====
#Add test... #Add test...
#===== read_in_PointData_DataArray ===== #===== get_PointData =====
test_that("read_in_PointData_DataArray works", { test_that("get_PointData works", {
skip_if_python_modules_missing() skip_if_python_modules_missing()
...@@ -100,31 +118,9 @@ test_that("read_in_PointData_DataArray works", { ...@@ -100,31 +118,9 @@ test_that("read_in_PointData_DataArray works", {
"flow_free_expansion_ts_1000_t_10000.000000.vtu", "flow_free_expansion_ts_1000_t_10000.000000.vtu",
package = "r2ogs6") package = "r2ogs6")
vtu_obj <- read_in_vtu(vtu_path) vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path)
pd_data_array <- vtu_obj$get_PointData_DataArray(Name = "HydraulicFlow")
expect_equal(class(pd_data_array), "array")
})
#===== General .vtk library tests ===== pd_data_array <- vtu_obj$get_PointData(Name = "HydraulicFlow")
expect_equal(class(pd_data_array), "array")
test_that("zlib decompressing works as expected", {
skip_if_python_modules_missing()
py_env <- reticulate::py_run_string(
paste(
"import zlib",
"test_data = bytearray('123', 'utf-8')",
"compr_data = zlib.compress(test_data)",
"decompr_data = zlib.decompress(compr_data)",
"check = test_data.decode('utf-8') == decompr_data.decode('utf-8')",
sep = "\n"
),
convert = TRUE
)
expect_equal(py_env$check, TRUE)
}) })
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment