Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 23 additions & 57 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches:
- main
- master

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -22,64 +19,33 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

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

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(c(remotes::system_requirements("ubuntu", "20.04"), remotes::system_requirements("ubuntu", "20.04", package="curl")))')

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
extra-packages: any::rcmdcheck
needs: check

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
69 changes: 34 additions & 35 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
tags:
-'*'
branches: [main, master]
pull_request:
release:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: macOS-latest
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
- uses: actions/checkout@v4

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

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown", type = "binary")
shell: Rscript {0}
extra-packages: any::pkgdown, local::.
needs: website

- name: Install package
run: R CMD INSTALL .
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy package
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: natcpp
Title: Fast C++ Primitives for the 'NeuroAnatomy Toolbox'
Version: 0.1.1
Version: 0.1.1.9000
Authors@R:
person(given = "Gregory",
family = "Jefferis",
Expand All @@ -16,7 +16,7 @@ Description: Fast functions implemented in C++ via 'Rcpp' to support the
package will automatically use routines from this package when it is
available to enable large performance gains.
License: GPL (>= 3)
URL: https://github.com/natverse/natcpp
URL: https://github.com/natverse/natcpp, https://natverse.org/natcpp/
BugReports: https://github.com/natverse/natcpp/issues
Imports:
Rcpp (>= 1.0.6)
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

export(c_EdgeListFromSegList)
export(c_ListofMatrixRows)
export(c_coords21dindex)
export(c_ijkpos)
export(c_listlengths)
export(c_seglengths)
export(c_sub2ind)
export(c_topntail)
export(c_topntail_list)
export(c_total_cable)
Expand Down
37 changes: 37 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,43 @@ c_total_cable <- function(sl, x, y, z) {
.Call(`_natcpp_c_total_cable`, sl, x, y, z)
}

#' Convert physical coordinates to pixel coordinates
#'
#' @param xyz Nx3 matrix of physical coordinates
#' @param dims Integer dimensions of the 3d image array
#' @param origin Numeric: 3d coordinates of the origin
#' @param voxdims Numeric: 3 numbers describing the voxel dimensions
#' @param clamp Logical: whether or not to clamp values within the pixel
#' boundaries of the image.
#' @return Nx3 integer matrix of pixel coordinates
#' @export
c_ijkpos <- function(xyz, origin, voxdims, dims, clamp = FALSE) {
.Call(`_natcpp_c_ijkpos`, xyz, origin, voxdims, dims, clamp)
}

#' Find 1D index given n-dimensional indices
#' @param dims Integer dimensions of the array (usually 3d)
#' @param indices Nx3 integer matrix of pixel coordinates
#' @return numeric vector of linear indices into the array
#' @export
c_sub2ind <- function(dims, indices) {
.Call(`_natcpp_c_sub2ind`, dims, indices)
}

#' Convert physical coordinates to 1d indices into image array
#'
#' @param xyz Nx3 matrix or data.frame of physical coordinates
#' @param dims Integer dimensions of the 3d image array
#' @param origin Numeric: 3d coordinates of the origin
#' @param voxdims Numeric: 3 numbers describing the voxel dimensions
#' @param clamp Logical: whether or not to clamp values within the pixel
#' boundaries of the image.
#' @return Nx3 integer matrix of pixel coordinates
#' @export
c_coords21dindex <- function(xyz, origin, voxdims, dims, clamp = FALSE) {
.Call(`_natcpp_c_coords21dindex`, xyz, origin, voxdims, dims, clamp)
}

#' Convert a matrix into list of row vectors
#'
#' @details Typically this will be for 3D coordinates but there are no limits
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![R-CMD-check](https://github.com/natverse/natcpp/workflows/R-CMD-check/badge.svg)](https://github.com/natverse/natcpp/actions)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/natcpp)](https://CRAN.R-project.org/package=natcpp)
[![R-CMD-check](https://github.com/natverse/natcpp/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/natverse/natcpp/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The goal of *natcpp* is to provide accelerated routines through compiled C++
Expand Down
19 changes: 13 additions & 6 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
url: https://natverse.org/natcpp/
template:
bootstrap: 5
navbar:
structure:
left:
- home
- intro
- reference
- articles
- tutorials
- news
- help
- news
right:
- natverse
- search
- github
- natverse
- lightswitch
components:
home:
icon: fas fa-home fa-lg
href: index.html
reference:
text: Reference
href: reference/index.html
search:
search: []
news:
text: Changelog
href: news/index.html
github:
icon: fab fa-github fa-lg
href: https://github.com/natverse/natcpp/
aria-label: GitHub
natverse:
text: natverse
href: https://natverse.github.io
Expand Down
26 changes: 26 additions & 0 deletions man/c_coords21dindex.Rd

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

26 changes: 26 additions & 0 deletions man/c_ijkpos.Rd

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

19 changes: 19 additions & 0 deletions man/c_sub2ind.Rd

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

Loading