-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try from err typos #229
Try from err typos #229
Conversation
Apologies for being picky. I think the hashmap code needs to be its own separate PR, and it probably needs some discussion first in an issue. It's not clear to me that we want to always convert a hashmap into a list, as opposed to an environment. And for a PR that fixes spelling and other minor issues (such as Finally, the integration tests are failing because R check notices that there are no man pages. I think |
Your comments make sense and aren't too picky. I agree discussing hashmap is reasonable. The lack of From HashMap<String, Robj> seemed to someone new on the project to be simply an oversight given existing From,TryFrom implementations for HashMap with &str and String keys. edit: I should mention, too, that even if HashMap to List is deemed proper the existing implementation should handle better unnamed lists. Currently the conversion of an unnamed list produces an empty list, when I think probably it should just fail. Will implement your suggestions and resubmit. Thanks |
I've opened an issue about hasmaps: #230 |
recent upstream commits here, and
edit |
It's starting to look good, but there are some changes that don't seem to belong (the change in the changelog, the hashmap code). Overall, from experience, I'd say once you have more than a handful of commits chances are something went wrong and you'd be better off starting over. Also, never rebase, just merge in the main tree. The tests fail because there's a formatting error. I'll flag it. |
extendr-api/src/lib.rs
Outdated
@@ -399,7 +399,7 @@ pub enum RType { | |||
Symbol, // SYMSXP | |||
Pairlist, // LISTSXP | |||
Function, // CLOSXP | |||
Enviroment, // ENVSXP | |||
Environment, // ENVSXP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line causes the tests to fail because the comment is not aligned.
CHANGELOG.md
Outdated
@@ -22,6 +22,7 @@ | |||
|
|||
- Use Use failure() to trigger steps on failures | |||
|
|||
- `SymPair::sym_pair()` now returns `(Option<Robj>, Robj)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is here.
extendr-api/src/robj/into_robj.rs
Outdated
let res: Robj = List::from_values(val.iter().map(|(_, v)| v)).into(); | ||
res.set_names(val.into_iter().map(|(k, _)| k)).unwrap() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this code block is here.
Err(Error::ExpectedString(robj)) | ||
} | ||
} | ||
_ => Err(Error::ExpectedScalar(robj)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably fine, but honestly it's mixing different things into one PR and I'd rather have a separate PR just for this change.
unsafe { Rf_defineVar(n.get(), v.get(), robj.get()) } | ||
if let Some(n) = n { | ||
unsafe { Rf_defineVar(n.get(), v.get(), robj.get()) } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure this is correct, but would you mind explaining? I don't see immediately how the previous code could compile and the new code also compiles.
extendr-api/src/wrapper/pairlist.rs
Outdated
@@ -31,7 +37,7 @@ impl Pairlist { | |||
let val = Rf_protect(val.get()); | |||
res = Rf_protect(Rf_cons(val, res)); | |||
num_protects += 2; | |||
if !name.is_unbound_value() { | |||
if let Some(name) = name { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is from a different PR.
extendr-api/src/wrapper/pairlist.rs
Outdated
@@ -126,7 +132,8 @@ impl Iterator for PairlistIter { | |||
let name = to_str(R_CHAR(printname) as *const u8); | |||
Some((std::mem::transmute(name), value)) | |||
} else { | |||
Some((na_str(), value)) | |||
// empty string represents the absense of the name | |||
Some(("", value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is from a different PR.
extendr-api/src/wrapper/pairlist.rs
Outdated
@@ -143,7 +150,7 @@ impl IntoIterator for Pairlist { | |||
/// test! { | |||
/// let pairlist = pairlist!(a=1, 2).as_pairlist().unwrap(); | |||
/// let vec : Vec<_> = pairlist.into_iter().collect(); | |||
/// assert_eq!(vec, vec![("a", r!(1)), (na_str(), r!(2))]); | |||
/// assert_eq!(vec, vec![("a", r!(1)), ("", r!(2))]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is from a different PR.
extendr-api/src/wrapper/symbol.rs
Outdated
robj: unsafe { new_owned(make_symbol(val)) }, | ||
} | ||
Symbol { | ||
robj: unsafe { new_owned(make_symbol(val)) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is from a different PR.
|
||
/// Return string `"Hello world!"` to R. | ||
/// @export | ||
/// @usage NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like deleting the actual meaningful comments (such as "Return string ...). You probably don't need to add @usage NULL
at all, and can instead use //
rather than ///
to indicate the comment. Then the comment doesn't get moved into the R wrapper, the function is not exported, and R check should be happy.
It's possible that a lot of things will be fixed if you just merge in master. |
hmm, so i did not make most of the changes you commented on --- they come from the previous commits made yesterday (re: #226) and which i pulled this afternoon to avoid merge conflicts. the same is true from the below. **edit: ** last sentence makes no sense here anymore. to your main point: it would have been cleaner to start over. nonetheless, thank you for the time here, and please do let me know the preference in situations like this.
yes, will do |
@clauswilke To clean up this git history mess a bit my plan is to merge to master on my fork and have the PR point there. I've not done that before as I typically am a maintainer on projects I work on. If doing so, with some loss of the commit history, is undesirable please do let me know. Trying to reduce the amount of nonsense I produce for review here going forward. Thanks again |
Yes, all you have to do is merge master into your current branch and then push. The PR should update and GitHub should then only register the changes since master. The history doesn't matter because when we merge the PR we squash. It's another reason why each PR should be one single issue only; it's going to be only one commit on the master branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
HashMap of Robj should convert without error.
We could make the String into a T : AsRef<str>
to be more generic, but later will do.
I think this looks good now. Could you try to merge in master so we no longer see the changes that aren't actually part of your PR? |
great, thanks for the comments all. what follows is rather tedious. TLDR summary is that i can reopen a PR to reset history, switch the PR base branch and back to trick github, or do nothing. the PR merge shouldn't associate the unrelated commits to this PR, as the history displayed here is a cosmetic feature of github apparently. on the commit history from upstream/master that isn't mine but appears here: i did indeed merge my branch into origin/master (my fork master), but the issue of github showing commits from upstream/master appears to be a github issue. see this long-standing thread, still active: annoying, though it seems this issue is mostly cosmetic since you will squash this PR's commits anyway. i see a few options and am happy to do what is easiest or best from your perspective:
|
I think we should try to get this right, most importantly so you've got the workflow down in the future, and also because if I merge now I'm quite certain it'll look like @yutannihilation co-authored the PR. In brief, I think this is where you went wrong:
You need to merge upstream master into your branch, but you should not touch your fork master. In general, the workflow that works is:
|
looks like a new PR is the cleanest solution i think. if you would prefer, i could squash the history into one commit, with me as author.
in case this is a reference to my future self or others: i should have been more clear. i did that only after the previous commit history from origin/master had shown up in this PR, so it cannot be the cause, at least not this time. but your comment is still valid, i think, in broad terms: these errant commits, which were updates to origin/master while this PR was ongoing, showed up after i merged upstream/master into origin/master then into my branch, rather than merging upstream/master directly into my branch. otherwise, i followed your steps 1-7. step 6 was the key here, in other words. noted. |
Whichever is easier for you. I don't particularly care. We squash when we merge into master. |
* fix TryFrom<Robj> for Vec<f64> Err type * add associated tests in extendrtests, plus one for HashMap<str, Robj>
ok, this should fix things. thanks for the back and forth. |
CI failures on R-devel runner are probably irrelevant to this pull request, so please ignore (probably due to the recent API change on R-devel, which itself is a bit worrisome...).
|
I'm still confused by the hashmap situation but I'm going to merge since this contains many useful fixes. We can sort out the hashmap in future PRs. |
Fixes minor typographical errors for the following conversions and adds corresponding integration tests:
Error::ExpectedInteger
and is notError::ExpectedReal
&str
impl existedI did not fix the misspelling 'Enviroment' throughout extendr-api since it does not actually produce errors.
R documentation quashed for the conversion test functions.