Skip to content

Commit

Permalink
Merge pull request #38 from trafficonese/master
Browse files Browse the repository at this point in the history
testthat 3
  • Loading branch information
trafficonese authored Dec 26, 2024
2 parents 14f24c3 + 800ecbc commit cbea007
Show file tree
Hide file tree
Showing 55 changed files with 340 additions and 332 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:

name: R-CMD-check

permissions: read-all


jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
Expand All @@ -18,11 +21,11 @@ jobs:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: '4.1.0'}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -32,7 +35,7 @@ jobs:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
Expand All @@ -48,4 +51,4 @@ jobs:
with:
args: 'c("--no-manual", "--as-cran")'
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
build_args: 'c("--no-manual")'
12 changes: 8 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@ LazyData: TRUE
License: MIT + file LICENSE
URL: https://ysosirius.github.io/windfarmGA/index.html
BugReports: https://github.com/YsoSirius/windfarmGA/issues
RoxygenNote: 7.2.3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Suggests:
testthat,
testthat (>= 3.0.0),
foreach,
parallel,
doParallel,
progress,
stars,
raster,
leaflet,
elevatr,
elevatr (>= 0.99.0),
ggplot2,
gstat,
rworldmap
Encoding: UTF-8
X-schema.org-keywords: windfarm-layout, optimization, genetic-algorithm, renewable-energy, r, rstats, r-package
Config/testthat/edition: 3
Config/testthat/parallel: true

1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export(is_doparallel_installed)
export(is_elevatr_installed)
export(is_foreach_installed)
export(is_ggplot2_installed)
export(is_gstat_installed)
export(is_leaflet_installed)
export(is_parallel_installed)
export(mutation)
Expand Down
6 changes: 4 additions & 2 deletions R/genetic_algorithm.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#' @param Polygon1 The considered area as SpatialPolygon, SimpleFeature Polygon
#' or coordinates as matrix/data.frame
#' @param GridMethod Should the polygon be divided into rectangular or hexagonal
#' grid cells? The default is "Rectangular" grid. Hexagonal grids
#' are computed when assigning "h" or "hexagon" to this input variable.
#' grid cells? The default is `Rectangular` grid. Hexagonal grids
#' are computed when assigning `h` or `hexagon` to this input variable.
#' @param Rotor The rotor radius in meter
#' @param n The amount of turbines
#' @param fcrR A numeric value used for grid spacing. Default is \code{5}
Expand Down Expand Up @@ -256,7 +256,9 @@ genetic_algorithm <- function(Polygon1, GridMethod, Rotor, n, fcrR,
)
}
max_cores <- parallel::detectCores()
print("max_cores"); print(max_cores)
if (numCluster > max_cores) {
print(paste0("Maximum number of cores is: ", max_cores, "\n'numCluster' will be set to: ", max_cores - 1))
warning("Maximum number of cores is: ", max_cores, "\n'numCluster' will be set to: ", max_cores - 1)
numCluster <- max_cores - 1
}
Expand Down
6 changes: 0 additions & 6 deletions R/pkg_installed.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ is_leaflet_installed <- function() {
requireNamespace("leaflet", quietly = TRUE)
}

##' @rdname package_installed
##' @export
is_gstat_installed <- function() {
requireNamespace("gstat", quietly = TRUE)
}

##' @rdname package_installed
##' @export
is_elevatr_installed <- function() {
Expand Down
9 changes: 3 additions & 6 deletions R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -806,11 +806,10 @@ plot_leaflet <- function(result, Polygon1, which = 1, orderitems = TRUE, GridPol
## Plot a Leaflet Map ###################
overlay_group <- c("Wake Circles", "Title", "Polygon", "Turbines", "Grid")
opaycity <- 0.4
map <- leaflet::leaflet() %>%
map <-
leaflet::leaflet() %>%
leaflet::addTiles(group = "OSM") %>%
leaflet::addProviderTiles("Stamen.Terrain", group = "Terrain") %>%
leaflet::addProviderTiles("Esri.WorldImagery", group = "Satellite") %>%
leaflet::addProviderTiles("Stamen.Toner", group = "Toner") %>%
## Write a Popup with the energy output
leaflet::addPopups(title_locat[1], (title_locat[2] + 0.0002),
group = "Title",
Expand Down Expand Up @@ -862,9 +861,7 @@ plot_leaflet <- function(result, Polygon1, which = 1, orderitems = TRUE, GridPol
leaflet::addLayersControl(
baseGroups = c(
"OSM",
"Terrain",
"Satellite",
"Toner"
"Satellite"
),
overlayGroups = overlay_group,
options = leaflet::layersControlOptions(collapsed = TRUE)
Expand Down
4 changes: 2 additions & 2 deletions R/terrain_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' crs = 3035
#' ))
#' Polygon_wgs84 <- sf::st_transform(Polygon1, st_crs(4326))
#' srtm <- elevatr::get_elev_raster(locations = as(Polygon_wgs84, "Spatial"), z = 11)
#' srtm <- elevatr::get_elev_raster(locations = Polygon_wgs84, z = 11)
#' res <- terrain_model(srtm, Polygon1)
#' }
terrain_model <- function(topograp = TRUE, Polygon1, sourceCCL, sourceCCLRoughness,
Expand Down Expand Up @@ -68,7 +68,7 @@ terrain_model <- function(topograp = TRUE, Polygon1, sourceCCL, sourceCCLRoughne
polygon_wgs84 <- sf::st_transform(Polygon1, st_crs(4326))
srtm <- tryCatch(elevatr::get_elev_raster(
verbose = verbose,
locations = as(polygon_wgs84, "Spatial"), z = 11
locations = polygon_wgs84, z = 11
),
error = function(e) {
stop("\nDownloading Elevation data failed for the given Polygon.\n",
Expand Down
48 changes: 23 additions & 25 deletions R/windfarmGA_package.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
#' windfarmGA
#'
#' @importFrom terra xyFromCell extract plot res resample lapp rast crop crs
#' project terrain app values global classify mosaic viewshed sprc add_legend
#' @importFrom sf st_as_sf st_geometry st_coordinates st_transform st_crs
#' st_make_grid st_intersection st_area sf_extSoftVersion st_centroid st_bbox
#' st_cast st_combine `st_crs<-` st_distance st_is_valid
#' @importFrom grDevices colorRampPalette topo.colors
#' @importFrom graphics plot.new text plot par points abline title lines grid
#' layout axis legend mtext boxplot
#' @importFrom RColorBrewer brewer.pal
#' @importFrom calibrate textxy
#' @importFrom stats runif smooth.spline sd aggregate median dist complete.cases
#' quantile
#' @importFrom utils download.file unzip read.csv globalVariables
#' @importFrom methods as is
#' @importFrom Rcpp sourceCpp
#' @importFrom magrittr %>%
NULL

#' @useDynLib windfarmGA, .registration = TRUE
#' @author \strong{Maintainer}: Sebastian Gatscha \email{sebastian_gatscha@@gmx.at}
#' @details
#' `r lifecycle::badge("stable")`
#'
#' @description
#' \if{html}{\figure{windfarmGA.png}{options: width="25\%" alt="Figure: windfarmGA.png"}}
#' \if{latex}{\figure{windfarmGA.png}{options: width=0.2in}}
#' A package to optimize small wind farms with irregular shapes
Expand All @@ -21,26 +41,4 @@
#' \item \href{https://windfarmga.shinyapps.io/windga_shiny}{Shiny App}
#' \item \href{https://github.com/YsoSirius/windfarmGA/issues}{Report Issues}
#' }
#'
#' @importFrom terra xyFromCell extract plot res resample lapp rast crop crs
#' project terrain app values global classify mosaic viewshed sprc add_legend
#' @importFrom sf st_as_sf st_geometry st_coordinates st_transform st_crs
#' st_make_grid st_intersection st_area sf_extSoftVersion st_centroid st_bbox
#' st_cast st_combine `st_crs<-` st_distance st_is_valid
#' @importFrom grDevices colorRampPalette topo.colors
#' @importFrom graphics plot.new text plot par points abline title lines grid
#' layout axis legend mtext boxplot
#' @importFrom RColorBrewer brewer.pal
#' @importFrom calibrate textxy
#' @importFrom stats runif smooth.spline sd aggregate median dist complete.cases
#' quantile
#' @importFrom utils download.file unzip read.csv globalVariables
#' @importFrom methods as is
#' @importFrom Rcpp sourceCpp
#' @importFrom magrittr %>%
#'
#' @useDynLib windfarmGA, .registration = TRUE
#' @docType package
#' @name windfarmGA_
#' @author \strong{Maintainer}: Sebastian Gatscha \email{sebastian_gatscha@@gmx.at}
NULL
"_PACKAGE"
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# windfarmGA

<p align="center">
<img src="https://raw.githubusercontent.com/YSoSirius/windfarmGA/master/inst/img/windfarmGA.png" width="150"/>
</p>
<img src="https://raw.githubusercontent.com/YSoSirius/windfarmGA/master/inst/img/windfarmGA.png" align="right" width="150"/>

<!-- badges: start -->
[![](https://www.r-pkg.org/badges/version/windfarmGA)](https://www.r-pkg.org/pkg/windfarmGA)
Expand Down
6 changes: 4 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.2.0 (2022-04-22 ucrt)",
"runtimePlatform": "R version 4.4.0 Patched (2024-05-26 r86642 ucrt)",
"author": [
{
"@type": "Person",
Expand Down Expand Up @@ -43,6 +43,7 @@
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -132,6 +133,7 @@
"@type": "SoftwareApplication",
"identifier": "elevatr",
"name": "elevatr",
"version": ">= 0.99.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -284,7 +286,7 @@
"SystemRequirements": null
},
"keywords": ["windfarm-layout", "optimization", "genetic-algorithm", "renewable-energy", "r", "rstats", "r-package"],
"fileSize": "3298.43KB",
"fileSize": "5158.331KB",
"relatedLink": "https://ysosirius.github.io/windfarmGA/index.html",
"releaseNotes": "https://github.com/trafficonese/windfarmGA/blob/master/NEWS.md",
"readme": "https://github.com/trafficonese/windfarmGA/blob/master/README.md",
Expand Down
4 changes: 2 additions & 2 deletions man/barometric_height.Rd

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

12 changes: 6 additions & 6 deletions man/calculate_energy.Rd

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

2 changes: 1 addition & 1 deletion man/circle_intersection.Rd

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

4 changes: 2 additions & 2 deletions man/crossover.Rd

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

12 changes: 6 additions & 6 deletions man/fitness.Rd

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

Loading

0 comments on commit cbea007

Please sign in to comment.