Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
r2ogs6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
r2ogs6
Commits
c0d79b43
Commit
c0d79b43
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
[base] Improved get_obj_status
parent
74bbda4b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Merge branch 7 fixed functionality into master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/utils.R
+39
-43
39 additions, 43 deletions
R/utils.R
with
39 additions
and
43 deletions
R/utils.R
+
39
−
43
View file @
c0d79b43
...
...
@@ -181,60 +181,56 @@ get_implemented_classes <- function(){
#===== INFO UTILITY =====
#'get_list_status
#'@description Helper function for get_status() to check if a list has at least
#' one element.
#'@param flag Boolean flag to keep track of missing components
#'@param obj_list The specified list
#'@param element_type Optional: What kind of elements are in the list?
#'@param is_opt flag: Does the list need at least one element?
get_list_status
<-
function
(
flag
,
obj_list
,
element_type
=
"list element"
,
is_opt
=
FALSE
){
sim_ready
<-
flag
if
(
length
(
obj_list
)
==
0
){
if
(
!
is_opt
){
cat
(
crayon
::
red
(
"\u2717"
))
sim_ready
<-
FALSE
#'get_obj_status
#'@description Helper function for get_status() to check the status of an OGS6
#' parameter
#'@param flag flag: To keep track of missing components
#'@param obj OGS6 parameter: Either a wrapper list or an r2ogs6 class object
get_obj_status
<-
function
(
flag
,
obj
){
assertthat
::
assert_that
(
assertthat
::
is.flag
(
flag
))
ogs6_parameter_name
<-
unlist
(
strsplit
(
deparse
(
substitute
(
obj
)),
"."
,
fixed
=
TRUE
))[[
2
]]
is_optional
<-
is_optional_sim_component
(
ogs6_parameter_name
)
if
(
is.null
(
obj
)
||
length
(
obj
)
==
0
){
if
(
!
is_optional
){
cat
(
crayon
::
red
(
"\u2717\t"
))
flag
<-
FALSE
}
else
{
cat
(
crayon
::
yellow
(
"()"
))
cat
(
crayon
::
yellow
(
"()
\t
"
))
}
}
else
{
cat
(
crayon
::
green
(
"\u2713"
))
cat
(
crayon
::
green
(
"\u2713
\t
"
))
}
cat
(
" At least one"
,
element_type
,
"was defined"
,
"\n"
)
# Check if parameter is r2ogs6 class object or wrapper list
if
(
any
(
grepl
(
"r2ogs6_"
,
class
(
obj
),
fixed
=
TRUE
))){
cat
(
"OGS6$"
,
ogs6_parameter_name
,
" is defined\n"
,
sep
=
""
)
}
else
{
cat
(
"OGS6$"
,
ogs6_parameter_name
,
" has at least one element\n"
,
sep
=
""
)
}
return
(
invisible
(
sim_ready
))
return
(
invisible
(
flag
))
}
#'obj_is_defined
#'@description Helper function for get_status() to check if an object was
#' defined
#'@param flag Boolean flag to keep track of missing components
#'@param obj The specified object
#'@param obj_type Optional: What kind of object is this?
#'@param is_opt flag: Is the element optional i.e. can it be NULL?
obj_is_defined
<-
function
(
flag
,
obj
,
obj_type
=
""
,
is_opt
=
FALSE
){
is_defined
<-
flag
if
(
is.null
(
obj
)){
cat
(
crayon
::
red
(
"\u2717"
))
is_defined
<-
FALSE
}
else
{
cat
(
crayon
::
green
(
"\u2713"
))
}
#'is_optional_sim_component
#'@description Checks if a simulation component is optional
#'@param ogs6_parameter_name string: Name of a OGS6 parameter
is_optional_sim_component
<-
function
(
ogs6_parameter_name
){
cat
(
" "
,
obj_type
,
"object is not NULL"
,
"\n"
)
optional_sim_components
<-
c
(
"gml"
,
"local_coordinate_system"
,
"curves"
,
"search_length_algorithm"
,
"test_definition"
,
"insitu"
)
return
(
invisible
(
is_defined
))
return
(
invisible
(
ogs6_parameter_name
%in%
optional_sim_components
))
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment