FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix missing value propagation in `as_integers/doubles()`, take 2 by romainfrancois · Pull Request #319 · r-lib/cpp11 · GitHub

/ cpp11 Public

Fix missing value propagation in as_integers/doubles(), take 2 - #319

Merged
romainfrancois merged 10 commits into
mainfrom
revert_265
May 25, 2023
Merged

romainfrancois merged 10 commits into
mainfrom
revert_265

Conversation

Copy link
Copy Markdown
Collaborator

This reverts commit 3c87798.

romainfrancois commented May 24, 2023 •
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Turns out #265 is breaking something that I can't quite understand, see #318 for some drama. I'll try to approach its intent a different way.

(edit) it was a ci oversight 🤯

romainfrancois mentioned this pull request May 25, 2023
run: |
options(warn = 2)
pak::local_install_dev_deps("cpp11test", dependencies = TRUE)
install.packages(".", repos = NULL, type = "source")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

cc @kevinushey @DavisVaughan just a FYI, because this has driven me insane over the past few days.

Because this is a non-standard setup that involves an extra package (cpp11test) that lives under the source tree, we actually do need to install cpp11 from locally, which is not done for usual testing (it just does R CMD build + check).

So I ended up testing against cran version instead of local, so:

  • none of the changes in header files were stressed, causing failures on ci.
  • but locally everything was fine

And then because I'm always more suspicious of my local setup than the ci, I tried a bunch of things (see #318 for some drama ci-based testing)

@@ -1,9 +1,7 @@
#include "Rversion.h"

#include "cpp11/doubles.hpp"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Order of includes actually does not matter, make format can do its thing.

Comment thread inst/include/cpp11/R.hpp

template <typename T>
inline bool is_na(const T& value) {
inline typename std::enable_if<!std::is_same<typename std::decay<T>::type, double>::value,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I trust this approach more than an unconstrained template <typename T> followed by a fully specialized is_na<double>.

And also that means all of is_na() is in this one file.

doubles xn(x);
writable::integers ret = writable::integers(xn.size());
std::transform(xn.begin(), xn.end(), ret.begin(), [](double value) {
if (!is_convertible_without_loss_to_integer(value)) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Do we need to consider the case when have (double)NA_INTEGER in a doubles, currently the static_cast<int> will turn this into NA_INTEGER so we end up with NA although we started with something that is not NA (in the double land).

Should is_convertible_without_loss_to_integer() return false in that case. R does this:

> as.integer(cpp11::cpp_eval("(double)NA_INTEGER"))
[1] NA
Warning message:
NAs introduced by coercion to integer range 

romainfrancois changed the title Revert "Fix missing value propagation in as_integers/doubles() (#265)" Fix missing value propagation in as_integers/doubles(), take 2 May 25, 2023
romainfrancois merged commit 28538e5 into main May 25, 2023
romainfrancois deleted the revert_265 branch May 25, 2023 09:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL