diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6c0c13f..fa06608 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,69 @@ Co-authored-by: name Co-authored-by: another-name ``` -## Getting Started +## Development -The `README.md` has developer setup instructions. Your contributions make this -project better for everyone. Thank you for participating! +Your contributions make this project better for everyone. Thank you for +participating! + +### Local Development + +Often it is useful to have [pixi](https://prefix.dev/) handle the dependencies: + +```bash +pixi shell +``` + +A `pre-commit` job is set up on CI to enforce consistent styles. It is advisable +to set it up locally as well using [pipx](https://pypa.github.io/pipx/) for +isolation: + +```bash +# Run before committing +pipx run pre-commit run --all-files +# Or install the git hook to enforce this +pipx run pre-commit install +``` + +For working with packages with compiled extensions, instead of `devtools::load_all()` it can be more useful to run this instead: + +```{r eval=FALSE} +devtools::clean_dll() +cpp11::cpp_register() +devtools::document() +devtools::load_all() +``` + +Also don't forget to recreate the `readme` file: +```{r eval=FALSE} +devtools::build_readme() +``` + +If you find that `pre-commit` for R is flaky, you can consider the following commands: + +```bash +find . \( -path "./.pixi" -o -path "./renv" \) -prune -o -type f -name "*.R" -exec Rscript -e 'library(styler); style_file("{}")' \; +Rscript -e 'library(lintr); lintr::lint_package(".")' +``` + +#### Tests + +Tests and checks are run on the CI, however locally one can use: + +```bash +Rscript -e 'devtools::test()' +``` + + +#### Documentation + +Ideally each change should be documented. Major changes should be `vignettes`, +and minor ones can be added to `newsfragments`. + +Benchmark vignettes are pre-computed via: + +```bash +Rscript rebuild-benchmarks.R +``` + +Which makes it faster to build the package and run checks. diff --git a/NEWS.md b/NEWS.md index 76c981e..a46f2d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ This is the changelog for the `fastMatMR` package. -# 0.0.1.0 (2023-09-02) +# fastMatMR 0.0.1.0 (2023-09-02) ## Features @@ -11,7 +11,7 @@ This is the changelog for the `fastMatMR` package. - Support reading sparse matrices from Matrix. -# 0.0.0.9000 (2023-08-31) +# fastMatMR 0.0.0.9000 (2023-08-31) ## Improved Documentation diff --git a/README.Rmd b/README.Rmd index 2b00e5e..7645d50 100644 --- a/README.Rmd +++ b/README.Rmd @@ -43,8 +43,8 @@ devtools::install_github("HaoZeke/fastMatMR") ```{r eval=FALSE} library(fastMatMR) -Matrix::Matrix(c(1, 0, 3, 2), nrow = 2, sparse = TRUE) -> spmat -write_fmm(vec, "vector.mtx") +spmat <- Matrix::Matrix(c(1, 0, 3, 2), nrow = 2, sparse = TRUE) +write_fmm(spmat, "sparse.mtx") ``` To see what this does, consider reading it back in `python`: @@ -53,59 +53,14 @@ To see what this does, consider reading it back in `python`: pip install fast_matrix_market python -c 'import fast_matrix_market as fmm; print(fmm.read_array_or_coo("sparse.mtx"))' ((array([1., 3., 2.]), (array([0, 0, 1], dtype=int32), array([0, 1, 1], dtype=int32))), (2, 2)) +python -c 'import fast_matrix_market as fmm; print(fmm.read_array("sparse.mtx"))' +array([[1., 3.], + [0., 2.]]) ``` -Similarly, we support writing and reading from other `R` objects. - -## Development - -### Local Development - -Often it is useful to have `pixi` handle the dependencies: - -```bash -pixi shell -``` - -A `pre-commit` job is set up on CI to enforce consistent styles. It is advisable -to set it up locally as well using [pipx](https://pypa.github.io/pipx/) for -isolation: - -```bash -# Run before committing -pipx run pre-commit run --all-files -# Or install the git hook to enforce this -pipx run pre-commit install -``` - -If you find that `pre-commit` for R is flaky, you can consider the following commands: - -```bash -find . \( -path "./.pixi" -o -path "./renv" \) -prune -o -type f -name "*.R" -exec Rscript -e 'library(styler); style_file("{}")' \; -Rscript -e 'library(lintr); lintr::lint_package(".")' -``` - -#### Tests - -Tests and checks are run on the CI, however locally one can use: - -```bash -Rscript -e 'devtools::test()' -``` - - -#### Documentation - -Ideally each change should be documented. Major changes should be `vignettes`, -and minor ones can be added to `newsfragments`. - -Benchmark vignettes are pre-computed via: - -```bash -Rscript rebuild-benchmarks.R -``` - -Which makes it faster to build the package and run checks. +Similarly, we support writing and reading from other `R` objects (e.g. standard +R vectors and matrices), as seen in the [basic use +vignette](https://haozeke.github.io/fastMatMR/articles/basic_usage.html). ## License diff --git a/README.md b/README.md index 8bd825d..5e1ce90 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ devtools::install_github("HaoZeke/fastMatMR") ``` r library(fastMatMR) -Matrix::Matrix(c(1, 0, 3, 2), nrow = 2, sparse = TRUE) -> spmat -write_fmm(vec, "vector.mtx") +spmat <- Matrix::Matrix(c(1, 0, 3, 2), nrow = 2, sparse = TRUE) +write_fmm(spmat, "sparse.mtx") ``` To see what this does, consider reading it back in `python`: @@ -55,59 +55,14 @@ To see what this does, consider reading it back in `python`: pip install fast_matrix_market python -c 'import fast_matrix_market as fmm; print(fmm.read_array_or_coo("sparse.mtx"))' ((array([1., 3., 2.]), (array([0, 0, 1], dtype=int32), array([0, 1, 1], dtype=int32))), (2, 2)) +python -c 'import fast_matrix_market as fmm; print(fmm.read_array("sparse.mtx"))' +array([[1., 3.], + [0., 2.]]) ``` -Similarly, we support writing and reading from other `R` objects. - -## Development - -### Local Development - -Often it is useful to have `pixi` handle the dependencies: - -``` bash -pixi shell -``` - -A `pre-commit` job is set up on CI to enforce consistent styles. It is -advisable to set it up locally as well using -[pipx](https://pypa.github.io/pipx/) for isolation: - -``` bash -# Run before committing -pipx run pre-commit run --all-files -# Or install the git hook to enforce this -pipx run pre-commit install -``` - -If you find that `pre-commit` for R is flaky, you can consider the -following commands: - -``` bash -find . \( -path "./.pixi" -o -path "./renv" \) -prune -o -type f -name "*.R" -exec Rscript -e 'library(styler); style_file("{}")' \; -Rscript -e 'library(lintr); lintr::lint_package(".")' -``` - -#### Tests - -Tests and checks are run on the CI, however locally one can use: - -``` bash -Rscript -e 'devtools::test()' -``` - -#### Documentation - -Ideally each change should be documented. Major changes should be -`vignettes`, and minor ones can be added to `newsfragments`. - -Benchmark vignettes are pre-computed via: - -``` bash -Rscript rebuild-benchmarks.R -``` - -Which makes it faster to build the package and run checks. +Similarly, we support writing and reading from other `R` objects +(e.g. standard R vectors and matrices), as seen in the [basic use +vignette](https://haozeke.github.io/fastMatMR/articles/basic_usage.html). ## License