Skip to content

Commit

Permalink
MAINT: Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZeke committed Aug 30, 2023
1 parent d4bb355 commit 0abecf9
Show file tree
Hide file tree
Showing 9 changed files with 424 additions and 407 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/pkg-check.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/pkgcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: pkgcheck

# This will cancel running jobs once a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

on:
# Manually trigger the Action under Actions/pkgcheck
workflow_dispatch:
# Run on every push to main
push:
branches:
- main

jobs:
pkgcheck:
runs-on: ubuntu-latest
steps:
- uses: ropensci-review-tools/pkgcheck-action@main
4 changes: 4 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: pre-commit

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

on:
pull_request:
push:
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ repos:
- id: trailing-whitespace
exclude: ^(.lintr)
- id: end-of-file-fixer
exclude: ^(inst)
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
hooks:
- id: clang-format
exclude: ^(include)
exclude: ^(inst)
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.2.0
hooks:
Expand Down
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
Package: fastMatMR
Title: What the Package Does (One Line, Title Case)
Title: "Reads and writes matrix market files"
Version: 0.0.0.9000
Authors@R:
person("Rohit", "Goswami", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-2393-8056"))
Description: What the package does (one paragraph).
Description: """
fastMatMR is a set of bindings to the fast_matrix_market cpp library which is
used to read and write matrix market compatible files.
"""
License: MIT + file LICENSE
SystemRequirements: C++17
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
LinkingTo:
cpp11
Imports:
Imports:
cpp11
Suggests:
Suggests:
Matrix
46 changes: 26 additions & 20 deletions R/fastMatMR-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,46 @@ NULL

#' Convert Various Numeric Types to Matrix Market Format
#'
#' This function takes different types of numeric inputs—vectors, matrices, and sparse matrices—
#' and converts them into Matrix Market files. The output file is written to disk.
#' This function takes different types of numeric inputs—vectors, matrices, and
#' sparse matrices— and converts them into Matrix Market files. The output file
#' is written to disk.
#'
#' @param input A numeric object to be converted. This can be a numeric vector, a matrix, or a sparse matrix.
#' @param fname The name of the output file where the Matrix Market formatted data will be saved.
#' It is recommended to use a filename ending with ".mtx" for clarity.
#' @param input A numeric object to be converted. This can be a numeric vector,
#' a matrix, or a sparse matrix. @param fname The name of the output file
#' where the Matrix Market formatted data will be saved. It is recommended to
#' use a filename ending with ".mtx" for clarity.
#'
#' @return This function has no return value. It writes a Matrix Market formatted file to disk.
#' @return This function has no return value. It writes a Matrix Market
#' formatted file to disk.
#'
#' @examples
#' \dontrun{
#' vec <- c(1, 2, 3)
#' mat <- matrix(c(1, 2, 3, 4), nrow = 2)
#' sparse_mat <- Matrix::Matrix(c(1, 0, 0, 2), nrow = 2, sparse = TRUE)
#' Diagonal ^-
#' ## Diagonal ^-
#' sparse_mat <- Matrix::Matrix(c(1, 1, 0, 2), nrow = 2, sparse = TRUE)
#' And not diagonal -^
#' ## And not diagonal -^
#'
#' writeFMM(vec, "vector.mtx")
#' writeFMM(mat, "matrix.mtx")
#' writeFMM(sparse_mat, "sparse_matrix.mtx")
#' write_fmm(vec, "vector.mtx")
#' write_fmm(mat, "matrix.mtx")
#' write_fmm(sparse_mat, "sparse_matrix.mtx")
#' }
#'
#' @export
writeFMM <- function(input, fname = "out.mtx") {
write_fmm <- function(input, fname = "out.mtx") {
if (is.vector(input)) {
return(vec_to_fmm(input, fname))
return(vec_to_fmm(input, fname)) # nolint. C++ function.
} else if (is.matrix(input)) {
return(mat_to_fmm(input, fname))
}
else if (inherits(input, "sparseMatrix")) {
return(sparse_to_fmm(input, fname))
}
else {
stop("Unsupported input type. Accepted types are numeric vector, matrix, and sparseMatrix.")
return(mat_to_fmm(input, fname)) # nolint. C++ function.
} else if (inherits(input, "sparseMatrix")) {
return(sparse_to_fmm(input, fname)) # nolint. C++ function.
} else {
stop(
paste(
"Unsupported input type.",
"Accepted types are numeric vector, matrix, and sparseMatrix."
)
)
}
}
6 changes: 5 additions & 1 deletion renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"R": {
"Version": "4.3.1",
"Repositories": [
{
"Name": "ropenscireviewtools",
"URL": "https://ropensci-review-tools.r-universe.dev"
},
{
"Name": "CRAN",
"URL": "https://packagemanager.posit.co/cran/latest"
"URL": "https://cloud.r-project.org"
}
]
},
Expand Down
Loading

0 comments on commit 0abecf9

Please sign in to comment.