From 3c7cd491908170b29df2523bdff892391d720a10 Mon Sep 17 00:00:00 2001 From: Laurent Gautier Date: Sat, 17 Aug 2024 10:27:58 -0400 Subject: [PATCH] Fix test to reflect likely inconsisteny in r-polars types. (#17) --- .github/workflows/pythonpackage.yml | 2 +- rpy2_arrow/tests_polars.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 0882731..cd6c961 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -62,7 +62,7 @@ jobs: if: startsWith(matrix.os, 'ubuntu') run: | install.packages("nanoarrow") - install.packages("polars", repos = "https://rpolars.r-universe.dev/bin/linux/jammy/4.3") + install.packages("polars", repos = "https://rpolars.r-universe.dev/bin/linux/jammy/4.4") shell: Rscript {0} - name: Install dependencies run: | diff --git a/rpy2_arrow/tests_polars.py b/rpy2_arrow/tests_polars.py index 439fb3e..85be713 100644 --- a/rpy2_arrow/tests_polars.py +++ b/rpy2_arrow/tests_polars.py @@ -115,9 +115,22 @@ def test_converter_py2rpy_dataframe(self, values, dtype, rpotype, cmp): field = R_SQBRACKET( R_DOLLAR(r_podataf, 'schema'), 1 )[0] + type_in_library = R_DOLLAR( + R_DOLLAR( + getattr( + rpy2polars.rpack_polars, 'pl' + ), + 'dtypes' + ), + rpotype + ) assert R_EQUAL( field, - R_DOLLAR(getattr(rpy2polars.rpack_polars, 'pl'), rpotype) + # `r-polars` is a bit inconsistent in the way it declares + # types. Some are R functions while others are non-callable + # objects. + type_in_library() if 'function' in type_in_library.rclass + else type_in_library ) @pytest.mark.parametrize(