Skip to content

Commit

Permalink
Merge pull request #365 from morungos/testing
Browse files Browse the repository at this point in the history
Add basic testing, fix a few check issues (take 2)
  • Loading branch information
RobFryer authored Nov 19, 2023
2 parents 3f38937 + ed5f9dc commit c98b469
Show file tree
Hide file tree
Showing 24 changed files with 9,625 additions and 68 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,41 @@ jobs:
- name: Build data and configuration archive for AMAP/external
run: |
set +f
mkdir -p $TEMP_DIR/external
cp -R data/example_external_data $TEMP_DIR/external/
mv $TEMP_DIR/external/example_external_data $TEMP_DIR/external/data
cp -R information/AMAP $TEMP_DIR/external/
mv $TEMP_DIR/external/AMAP $TEMP_DIR/external/information
mv $TEMP_DIR/external/information/README*.* $TEMP_DIR/external/
mv $TEMP_DIR/external/data/README*.* $TEMP_DIR/external/
cd $TEMP_DIR
zip -r $WORK_DIR/docs/external.zip external
cd $WORK_DIR
continue-on-error: true

- name: Build data and configuration archive for OSPAR 2022
run: |
set +f
mkdir -p $TEMP_DIR/ospar
cp -R data/example_OSPAR $TEMP_DIR/ospar/
mv $TEMP_DIR/ospar/example_OSPAR $TEMP_DIR/ospar/data
cp -R information/OSPAR_2022 $TEMP_DIR/ospar/
mv $TEMP_DIR/ospar/OSPAR_2022 $TEMP_DIR/ospar/information
mv $TEMP_DIR/ospar/information/README*.* $TEMP_DIR/ospar/
mv $TEMP_DIR/ospar/data/README*.* $TEMP_DIR/ospar/
cd $TEMP_DIR
zip -r $WORK_DIR/docs/ospar.zip ospar
cd $WORK_DIR
continue-on-error: true

- name: Build data and configuration archive for HELCOM 2023
run: |
set +f
mkdir -p $TEMP_DIR/helcom
cp -R data/example_HELCOM $TEMP_DIR/helcom/
mv $TEMP_DIR/helcom/example_HELCOM $TEMP_DIR/helcom/data
cp -R information/HELCOM_2023 $TEMP_DIR/helcom/
mv $TEMP_DIR/helcom/HELCOM_2023 $TEMP_DIR/helcom/information
mv $TEMP_DIR/helcom/information/README*.* $TEMP_DIR/helcom/
mv $TEMP_DIR/helcom/data/README*.* $TEMP_DIR/helcom/
cd $TEMP_DIR
zip -r $WORK_DIR/docs/helcom.zip helcom
cd $WORK_DIR
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.Ruserdata
.build.timestamp
HARSAT.RProj
HARSAT.Rcheck
harsat.Rcheck
harsat_*.tar.gz
oddities/
output/
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ Let's assume the current version is `x.y.z`
```
git checkout develop
git flow release start x.y.z+1
emacs DESCRIPTION ## Update version x.y.z-9000 -> x.y.z+1
emacs DESCRIPTION ## Update version x.y.z-9000 -> x.y.z+1
emacs CHANGES.md ## Update the change log, as appropriate
R --quiet --vanilla < vignettes/precompile.R
R CMD build .
R CMD check --no-manual harsat_x.y.z+1.tar.gz
Expand All @@ -113,7 +114,7 @@ git push --tags
git push upstream
git push --tags upstream
git checkout develop
emacs DESCRIPTION ## Bump version to x.y.(z+1)-9000
emacs DESCRIPTION ## Bump version to x.y.(z+1)-9000
git commit -am "Bump develop version [ci skip]"
git push
git push upstream
Expand Down
42 changes: 42 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,45 @@ export(run_assessment)
export(tidy_data)
export(update_assessment)
export(write_summary_table)
importFrom(grDevices,dev.off)
importFrom(grDevices,extendrange)
importFrom(grDevices,grey)
importFrom(grDevices,pdf)
importFrom(grDevices,png)
importFrom(graphics,par)
importFrom(stats,AIC)
importFrom(stats,as.formula)
importFrom(stats,complete.cases)
importFrom(stats,dmultinom)
importFrom(stats,dnorm)
importFrom(stats,filter)
importFrom(stats,glm)
importFrom(stats,glm.control)
importFrom(stats,integrate)
importFrom(stats,lm)
importFrom(stats,logLik)
importFrom(stats,median)
importFrom(stats,na.omit)
importFrom(stats,optim)
importFrom(stats,pbinom)
importFrom(stats,pf)
importFrom(stats,plogis)
importFrom(stats,pnorm)
importFrom(stats,predict)
importFrom(stats,pt)
importFrom(stats,qf)
importFrom(stats,qlogis)
importFrom(stats,qnorm)
importFrom(stats,qt)
importFrom(stats,quasi)
importFrom(stats,reshape)
importFrom(stats,rnorm)
importFrom(stats,sd)
importFrom(stats,setNames)
importFrom(stats,uniroot)
importFrom(stats,update)
importFrom(utils,head)
importFrom(utils,modifyList)
importFrom(utils,read.csv)
importFrom(utils,read.delim)
importFrom(utils,tail)
9 changes: 9 additions & 0 deletions R/harsat-package.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#' @keywords internal
"_PACKAGE"

#' @importFrom grDevices dev.off extendrange grey pdf png
#' @importFrom graphics par
#' @importFrom utils head tail modifyList read.csv read.delim
#' @importFrom stats AIC as.formula complete.cases dmultinom dnorm filter
#' glm glm.control integrate lm logLik median na.omit
#' optim pbinom pf plogis pnorm predict pt qf qlogis qnorm
#' qt quasi reshape rnorm sd setNames
#' uniroot update

## usethis namespace: start
## usethis namespace: end
NULL
20 changes: 10 additions & 10 deletions R/import_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ library(readxl)
#' `retain == FALSE` are deleted later in `tidy_data`
#' * `stations`
#'
#' @section Control parameters
#'
#' Many aspects of the assessment process can be controlled through the
#' parameters stored in `info$control`. This is a list populated with default
#' values which can then be overwritten, if required, using the `control`
#' argument.
#' ## Control parameters
#'
#' Many aspects of the assessment process can be controlled through the
#' parameters stored in `info$control`. This is a list populated with default
#' values which can then be overwritten, if required, using the `control`
#' argument.
#'
#' @export
read_data <- function(
Expand Down Expand Up @@ -190,7 +189,8 @@ read_data <- function(
info$max_year <- max(data$year)
cat(
"\nArgument max_year taken to be the maximum year in the data:",
info$max_year
info$max_year,
"\n"
)
}

Expand Down Expand Up @@ -427,7 +427,7 @@ locate_information_file <- function(name, path) {
for(directory in path) {
search <- normalizePath(file.path(directory, name), mustWork = FALSE)
if(file.exists(search)) {
print(paste("found in path", name, search, path))
cat(paste("Found in path", name, search, "\n"))
return(search)
}
}
Expand All @@ -437,10 +437,10 @@ locate_information_file <- function(name, path) {
search_file <- file.path("information", name)
search <- system.file(search_file, package = "harsat", mustWork = FALSE)
if(file.exists(search)) {
print(paste("found in package", name, search, path))
cat(paste("Found in package", name, search, "\n"))
return(search)
}
print(paste("missing", name, path))
warning(paste("Missing file in path:", name, path))
return(NULL)
}

Expand Down
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ navbar:
- text: External file format
href: articles/external-file-format.html
- text: -------
- text: "Resources"
- text: Datasets
href: articles/datasets.html
- text: -------
- text: "Examples"
- text: HELCOM (read first)
href: articles/example_HELCOM.html
Expand Down
7 changes: 7 additions & 0 deletions man/read_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions test_parallel.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
## system, but we check serial too to be safe.

library(harsat)
library(here)
working.directory <- here()
working.directory <- getwd()


water_data <- read_data(
Expand Down
56 changes: 56 additions & 0 deletions tests/datasets/external-1/EXTERNAL_AMAP_STATIONS.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
station_code,country,station_name,station_latitude,station_longitude,station_governance,AMAP_region,station_longname,station_type,waterbody_type
A1,Canada,Southern Labrador Sea,56.54,-61.7,AMAP,Labrador Sea,,,
A2,Canada,Cumberland Sound,66.15,-65.7,AMAP,Labrador Sea,,,
A3,Canada,Southern Hudson Bay,56.54,-79.22,AMAP,Hudson Bay,,,
A4,Canada,Digges Island,62.56,-77.96,AMAP,Hudson Bay,,,
A5,Canada,Coats Island,62.47,-83.1,AMAP,Hudson Bay,,,
A6,Canada,Western Hudson Bay,61.11,-94.06,AMAP,Hudson Bay,,,
A7,Canada,Queen Maud Gulf,69.12,-105.06,AMAP,Queen Maud Gulf,,,
A8,Canada,Eastern Beaufort Sea,71.99,-125.25,AMAP,Beaufort Sea,,,
A9,Canada,Southern Beaufort Sea,69.5,-133.58,AMAP,Beaufort Sea,,,
A10,Canada,GSL-West Basin,60.82,-115.79,AMAP,Great Slave Lake,,,
A11,Canada,GSL-East Arm,62.41,-110.74,AMAP,Great Slave Lake,,,
A12,Canada,Fort Good Hope,61.34,-135.65,AMAP,Mackenzie River,,,
A13,Canada,Little Fox Lake,66.26,-128.63,AMAP,Little Fox Lake,,,
A14,Canada,Lake Laberge,61.06,-135.11,AMAP,Lake Laberge,,,
A15,Canada,Lake Kusawa,60.41,-136.26,AMAP,Lake Kusawa,,,
A16,Canada,Old Crow,67.57,-139.83,AMAP,Northern Yukon,,,
A17,Canada,Alert,82.5,-62.35,AMAP,Ellesmere Island,,,
A18,Canada,Lake Hazen,81.8,-71,AMAP,Ellesmere Island,,,
A19,Canada,Prince Leopold Island,74.04,-90.03,AMAP,Lancaster Sound,,,
A20,Canada,Resolute Passage,74.7,-94.83,AMAP,Lancaster Sound,,,
A21,Canada,Amituk Lake,75.05,-93.75,AMAP,Cornwallis Island,,,
A22,Canada,Char Lake,74.71,-94.9,AMAP,Cornwallis Island,,,
A23,Canada,Meretta Lake,74.68,-94.92,AMAP,Cornwallis Island,,,
A24,Canada,Resolute Lake,74.69,-94.94,AMAP,Cornwallis Island,,,
A25,Canada,Small Lake,74.76,-95.06,AMAP,Cornwallis Island,,,
A26,Canada,North Lake,74.78,-95.09,AMAP,Cornwallis Island,,,
A27,Canada,SW Beaufort Sea,70,-150,AMAP,Beaufort Sea,,,
A28,Canada,Kuujjuaq,58.1,-68.42,AMAP,Nunavik,,,
A31,Canada,Arviat,61.1078,-94.0624,AMAP,Nunavut,,,
A32,Canada,Nain,56.5417,-61.6969,AMAP,Newfoundland,,,
A33,Canada,Resolute,74.6973,-94.8297,AMAP,Nunavut,,,
A34,Canada,SachsHarbour,71.9851,-125.2465,AMAP,NWT,,,
A29,Greenland,Disko Bay,69.03,-52.04,AMAP,Greenland,,,
A90,Greenland,Ittoqqortoormiit AMAP,70.29,-21.58,AMAP~OSPAR,East Greenland,,,
A95,Greenland,Nanortalik AMAP,60.1425,-45.2395,AMAP~OSPAR,South Greenland,,,
A100,Greenland,Avanersuaq AMAP,77.28,-69.14,AMAP,Northwest Greenland,,,
A110,Greenland,Qeqertarsuaq AMAP,69.15,-53.32,AMAP,Central-West Greenland,,,
A120,Greenland,Isortoq AMAP,60.54,-47.33,AMAP,Southwest Greenland,,,
A130,Greenland,Ittoqqortoormiit Ukaleqarteq,70.72,-21.55,AMAP,East Greenland,,,
A902,Faroe Islands,Føroyskar hvalvágir ,62,-7,AMAP,Greenland-Scotland ridge,,,
A911,Faroe Islands,Mýlingsgrunnur,62.38333,-7.41667,OSPAR~AMAP,Greenland-Scotland ridge,,,
A912,Faroe Islands,Á Mýrunum,62.16914,-7.08579,AMAP,Greenland-Scotland ridge,,,
A919,Faroe Islands,Tindhólmur,62.079,-7.43217,AMAP,Greenland-Scotland ridge,,,
A921,Faroe Islands,Vestmanna,62.15383,-7.15983,AMAP,Greenland-Scotland ridge,,,
A917,Faroe Islands,Sveipur,61.95,-6.71667,AMAP,Greenland-Scotland ridge,,,
A909,Faroe Islands,Koltur,61.99447,-6.99343,AMAP,Greenland-Scotland ridge,,,
A916,Faroe Islands,Skúvoy,61.76833,-6.80167,AMAP,Greenland-Scotland ridge,,,
A12429,Faroe Islands,Leitisvatn,62.04803,-7.23487,AMAP,Greenland-Scotland ridge,,,
A12434,Faroe Islands,Mjáuvøtn,62.12789,-7.00171,AMAP,Greenland-Scotland ridge,,,
A400,Sweden,Storvindeln,65.7,17.13,AMAP~OSPAR,Barents Sea,,,
A401,Sweden,Abiskojaure AMAP,68.28789,18.58575,AMAP~OSPAR,Barents Sea,,,
A47001,Norway,Svalbard,77.875,20.975,AMAP,Barents Sea,,,
A47002,Norway,Svalbard-Kongsfjorden area,79,11.6667,AMAP,Barents Sea,,,
A47010,Norway,Bjørnøya,74.452,19.115,AMAP,Barents Sea,,,
A47011,Norway,Bjørnøya-Ellasjoen,74.388,19.031,AMAP,Barents Sea,,,
Loading

0 comments on commit c98b469

Please sign in to comment.