Initial import (#1677787).

This commit is contained in:
Elliott Sales de Andrade 2019-02-17 19:27:21 -05:00
parent 641a94286e
commit 2b8bb043ed
4 changed files with 185 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/purrr_0.3.0.tar.gz

View File

@ -0,0 +1,86 @@
From 29f7778a53963c3f3d4a420ce36e1e060995bdb6 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Fri, 15 Feb 2019 06:30:58 -0500
Subject: [PATCH] Skip dplyr-related tests if unavailable.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
tests/testthat/test-flatten.R | 1 +
tests/testthat/test-imap.R | 1 +
tests/testthat/test-map.R | 1 +
tests/testthat/test-map_n.R | 5 +++++
tests/testthat/test-retired-invoke.R | 5 +++++
5 files changed, 13 insertions(+)
diff --git a/tests/testthat/test-flatten.R b/tests/testthat/test-flatten.R
index 0050bc1..62cb6ae 100644
--- a/tests/testthat/test-flatten.R
+++ b/tests/testthat/test-flatten.R
@@ -77,6 +77,7 @@ test_that("preserves inner names", {
# data frame flatten ------------------------------------------------------
test_that("can flatten to a data frame with named lists", {
+ skip_if_not_installed("dplyr")
expect_is(flatten_dfr(list(c(a = 1), c(b = 2))), "data.frame")
expect_equal(flatten_dfc(list(1)), tibble::tibble(V1 = 1))
})
diff --git a/tests/testthat/test-imap.R b/tests/testthat/test-imap.R
index 7574d16..59078a0 100644
--- a/tests/testthat/test-imap.R
+++ b/tests/testthat/test-imap.R
@@ -19,6 +19,7 @@ test_that("atomic vector imap works", {
})
test_that("data frame imap works", {
+ skip_if_not_installed("dplyr")
expect_identical(imap_dfc(x, paste), imap_dfr(x, paste))
})
diff --git a/tests/testthat/test-map.R b/tests/testthat/test-map.R
index a6a7253..5f960ae 100644
--- a/tests/testthat/test-map.R
+++ b/tests/testthat/test-map.R
@@ -61,6 +61,7 @@ test_that("map forces arguments in same way as base R", {
})
test_that("row and column binding work", {
+ skip_if_not_installed("dplyr")
mtcar_mod <- mtcars %>%
split(.$cyl) %>%
map(~ lm(mpg ~ wt, data = .x))
diff --git a/tests/testthat/test-map_n.R b/tests/testthat/test-map_n.R
index dba4f83..49594d5 100644
--- a/tests/testthat/test-map_n.R
+++ b/tests/testthat/test-map_n.R
@@ -47,6 +47,11 @@ test_that("outputs are suffixes have correct type", {
expect_is(pmap_dbl(list(x), mean), "numeric")
expect_is(pmap_chr(list(x), paste), "character")
expect_is(pmap_raw(list(x), as.raw), "raw")
+})
+
+test_that("outputs are suffixes have correct type for data frames", {
+ skip_if_not_installed("dplyr")
+ x <- 1:3
expect_is(pmap_dfr(list(x), as.data.frame), "data.frame")
expect_is(pmap_dfc(list(x), as.data.frame), "data.frame")
})
diff --git a/tests/testthat/test-retired-invoke.R b/tests/testthat/test-retired-invoke.R
index f35469e..5219651 100644
--- a/tests/testthat/test-retired-invoke.R
+++ b/tests/testthat/test-retired-invoke.R
@@ -33,7 +33,12 @@ test_that("invoke_map() works with bare function", {
expect_identical(invoke_map_lgl(`&&`, data), c(TRUE, TRUE))
expect_identical(invoke_map_raw(identity, as.raw(1:3)), as.raw(1:3))
+})
+
+test_that("invoke_map() works with bare function with data frames", {
+ skip_if_not_installed("dplyr")
+ data <- list(1:2, 3:4)
ops <- set_names(c(`+`, `-`), c("a", "b"))
expect_identical(invoke_map_dfr(ops, data), invoke_map_dfc(ops, data))
})
--
2.20.1

97
R-purrr.spec Normal file
View File

@ -0,0 +1,97 @@
# When we are bootstrapping, we drop some dependencies, and/or build time tests.
%{?_with_bootstrap: %global bootstrap 1}
%global bootstrap 1
%global packname purrr
%global rlibdir %{_libdir}/R/library
Name: R-%{packname}
Version: 0.3.0
Release: 1%{?dist}
Summary: Functional Programming Tools
License: GPLv3
URL: https://CRAN.R-project.org/package=%{packname}
Source0: https://cran.r-project.org/src/contrib/%{packname}_%{version}.tar.gz
# https://github.com/tidyverse/purrr/pull/641
Patch0001: 0001-Skip-dplyr-related-tests-if-unavailable.patch
# Here's the R view of the dependencies world:
# Depends:
# Imports: R-magrittr >= 1.5, R-rlang >= 0.3.1
# Suggests: R-covr, R-crayon, R-dplyr >= 0.7.8, R-knitr, R-rmarkdown, R-testthat, R-tibble, R-tidyselect
# LinkingTo:
# Enhances:
Requires: R-magrittr >= 1.5
Requires: R-rlang >= 0.3.1
Suggests: R-crayon
Suggests: R-dplyr >= 0.7.8
Suggests: R-tibble
Suggests: R-tidyselect
BuildRequires: R-devel
BuildRequires: tex(latex)
BuildRequires: R-magrittr >= 1.5
BuildRequires: R-rlang >= 0.3.1
BuildRequires: R-crayon
BuildRequires: R-knitr
BuildRequires: R-rmarkdown
BuildRequires: R-testthat
BuildRequires: R-tibble
%if ! 0%{?bootstrap}
BuildRequires: R-dplyr >= 0.7.8
BuildRequires: R-tidyselect
%endif
%description
A complete and consistent functional programming toolkit for R.
%prep
%setup -q -c -n %{packname}
pushd %{packname}
%patch0001 -p1
# Don't need coverage; it's not packaged either.
sed -i 's/covr, //g' DESCRIPTION
popd
%build
%install
mkdir -p %{buildroot}%{rlibdir}
%{_bindir}/R CMD INSTALL -l %{buildroot}%{rlibdir} %{packname}
test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so)
rm -f %{buildroot}%{rlibdir}/R.css
%check
%if ! 0%{?bootstrap}
%{_bindir}/R CMD check %{packname}
%else
_R_CHECK_FORCE_SUGGESTS_=0 %{_bindir}/R CMD check %{packname} --no-examples
%endif
%files
%dir %{rlibdir}/%{packname}
%doc %{rlibdir}/%{packname}/doc
%doc %{rlibdir}/%{packname}/html
%{rlibdir}/%{packname}/DESCRIPTION
%doc %{rlibdir}/%{packname}/NEWS.md
%license %{rlibdir}/%{packname}/LICENSE
%{rlibdir}/%{packname}/INDEX
%{rlibdir}/%{packname}/NAMESPACE
%{rlibdir}/%{packname}/Meta
%{rlibdir}/%{packname}/R
%{rlibdir}/%{packname}/help
%dir %{rlibdir}/%{packname}/libs
%{rlibdir}/%{packname}/libs/%{packname}.so
%changelog
* Fri Feb 15 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.3.0-1
- initial package for Fedora

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (purrr_0.3.0.tar.gz) = dd220caee03515098927d26e0c7207e678715d0f14fe80a746ae2bd0a451a6f1a5b7245bd1bc3e094a899b710f2faf0a3853c72eafb2506d00dc4dc0e1d6d81b