Skip to content

Commit

Permalink
Merge pull request #518 from natverse/fix/igraph200
Browse files Browse the repository at this point in the history
igraph dfs may signal unreachable nodes with 0
  • Loading branch information
jefferis authored Oct 14, 2024
2 parents 2538b4c + c2b83ae commit 3a6bf39
Show file tree
Hide file tree
Showing 21 changed files with 198 additions and 147 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ travisbuildchildren.sh
^\.github$
^depends.Rds$
^codecov\.yml$
^CODE_OF_CONDUCT\.md$
^CRAN-SUBMISSION$
86 changes: 28 additions & 58 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#on: push
# 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
branches: [main, master]

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

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -21,71 +20,42 @@ jobs:
fail-fast: false
matrix:
config:
#- {os: windows-latest, r: 'release', rglusenull: "true"}
- {os: macOS-latest, r: 'release', rglusenull: "true"}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", rglusenull: "true", codecov: "true"}
#- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release', codecov: 'true'}
- {os: ubuntu-latest, r: 'oldrel-1'}

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

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

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

- 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@v2

- name: Query dependencies
run: Rscript -e "install.packages('remotes')" -e "saveRDS(remotes::dev_package_deps(dependencies = TRUE), 'depends.Rds', version = 2)"

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('depends.Rds') }}
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-

- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install Covr
run: Rscript -e "remotes::install_github('r-lib/covr')"
extra-packages: any::rcmdcheck, natverse/natcpp
needs: check

- name: Build CMTK
if: ${{matrix.config.os != 'windows-latest'}}
run: sh ./build-cmtk.sh
env:
CC: clang
CXX: clang++
MAKEFLAGS: "-j2"

- name: Install dependencies
run: Rscript -e "library(remotes)" -e "update(readRDS('depends.Rds'))" -e "remotes::install_cran('rcmdcheck')"

- name: Install manual dependencies
run: Rscript -e "remotes::install_github('natverse/natcpp')"

- name: Check
run: Rscript -e "rcmdcheck::rcmdcheck(args = c('--no-manual', '--as-cran'), error_on = 'warning', check_dir = 'check')"

- name: Upload check results
if: failure()
uses: actions/upload-artifact@v2
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check

- name: Test coverage
if: matrix.config.codecov
run: |
Rscript -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")'
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
62 changes: 62 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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]
pull_request:
branches: [main, master]

name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RGL_USE_NULL: true

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Depends:
rgl (>= 0.98.1)
Imports:
nabor,
igraph (>= 0.7.1),
igraph (>= 1.0),
methods,
filehash (>= 2.3),
digest,
Expand Down
18 changes: 9 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ S3method(ndigest,neuron)
S3method(ndigest,neuronlistfh)
S3method(nvertices,default)
S3method(nvertices,dotprops)
S3method(nvertices,igraph)
S3method(nvertices,neuron)
S3method(nvertices,neuronlist)
S3method(nvertices,shapelist3d)
Expand Down Expand Up @@ -389,27 +390,26 @@ importFrom(digest,digest)
importFrom(igraph,"V<-")
importFrom(igraph,E)
importFrom(igraph,V)
importFrom(igraph,add.edges)
importFrom(igraph,add_edges)
importFrom(igraph,as.directed)
importFrom(igraph,as.undirected)
importFrom(igraph,as_edgelist)
importFrom(igraph,decompose.graph)
importFrom(igraph,bfs)
importFrom(igraph,decompose)
importFrom(igraph,degree)
importFrom(igraph,delete.vertices)
importFrom(igraph,dfs)
importFrom(igraph,diameter)
importFrom(igraph,distances)
importFrom(igraph,get.diameter)
importFrom(igraph,get.shortest.paths)
importFrom(igraph,get.vertex.attribute)
importFrom(igraph,graph.bfs)
importFrom(igraph,graph.dfs)
importFrom(igraph,is.connected)
importFrom(igraph,is.directed)
importFrom(igraph,is_connected)
importFrom(igraph,is_directed)
importFrom(igraph,make_empty_graph)
importFrom(igraph,neighborhood)
importFrom(igraph,set_edge_attr)
importFrom(igraph,shortest.paths)
importFrom(igraph,shortest_paths)
importFrom(igraph,vcount)
importFrom(igraph,vertex_attr)
importFrom(methods,is)
importFrom(nabor,knn)
importFrom(nat.utils,RunCmdForNewerInput)
Expand Down
6 changes: 3 additions & 3 deletions R/graph-nodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' available). Set to FALSE when this is not desired.
#' @param exclude.isolated Do not count isolated vertices as root/end points
#' (default)
#' @importFrom igraph V degree get.vertex.attribute
#' @importFrom igraph V degree vertex_attr
#' @export
#' @seealso \code{\link{rootpoints}}, \code{\link{ngraph}}
#' @examples
Expand All @@ -27,7 +27,7 @@
graph.nodes<-function(x, type=c('root','end','branch'), original.ids='name',
exclude.isolated=TRUE){
type=match.arg(type)
if(type=='root' && !is.directed(x))
if(type=='root' && !is_directed(x))
stop("Cannot establish root points for undirected graph")

# root points are those without incoming edges
Expand All @@ -42,7 +42,7 @@ graph.nodes<-function(x, type=c('root','end','branch'), original.ids='name',
}

if(is.character(original.ids))
vertex_names=get.vertex.attribute(x, original.ids, index=vertex_idxs)
vertex_names=vertex_attr(x, original.ids, index=vertex_idxs)
if(!is.character(original.ids) || is.null(vertex_names))
as.integer(vertex_idxs)
else
Expand Down
Loading

0 comments on commit 3a6bf39

Please sign in to comment.