Skip to content
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

shift fix type coercion for integer64 #5189

Merged
merged 20 commits into from
Oct 8, 2021
Merged

shift fix type coercion for integer64 #5189

merged 20 commits into from
Oct 8, 2021

Conversation

ben-schwen
Copy link
Member

Closes #4865

Also changes type coercion for the integer case to switch neatless between integer, double and integer64.

@codecov
Copy link

codecov bot commented Oct 1, 2021

Codecov Report

Merging #5189 (fdc1dc6) into master (cd81808) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5189      +/-   ##
==========================================
- Coverage   99.38%   99.38%   -0.01%     
==========================================
  Files          77       77              
  Lines       14541    14532       -9     
==========================================
- Hits        14452    14443       -9     
  Misses         89       89              
Impacted Files Coverage Δ
src/utils.c 97.41% <ø> (-0.03%) ⬇️
src/assign.c 99.85% <100.00%> (+<0.01%) ⬆️
src/init.c 100.00% <100.00%> (ø)
src/shift.c 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd81808...fdc1dc6. Read the comment docs.

NEWS.md Outdated Show resolved Hide resolved
@MichaelChirico
Copy link
Member

NB: coverage decrease is spurious

@mattdowle mattdowle added this to the 1.14.3 milestone Oct 6, 2021
src/shift.c Outdated
} else {
thisfill = PROTECT(coerceVector(fill, REALSXP));
}
SEXP thisfill = PROTECT(coerceAs(fill, elem, ScalarLogical(0))); // #4865 use coerceAs for (NA) type coercion
Copy link
Member

@mattdowle mattdowle Oct 6, 2021

Choose a reason for hiding this comment

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

very nice! i.e. glad to see the back of NA_INT64_LL and those unsigned long long casts.

@mattdowle
Copy link
Member

I tackled the news item by focusing it on the most easily conveyed example: nafill(xInt64, fill=0). Also added the error message so that folk searching for the error message might find it, as per contributing guide point 2 which has gotten quite dense now.
I didn't see why there were two blocks for the tests: first one being one loop, the 2nd being a nested loop. I started playing with that and testing in v1.14.2 to see which of the new tests worked before. I liked the nested loop so tried to make that the only loop to see what would happen. The revised new test passes in v1.14.2 but now fails in this PR. I committed anyway, and I'm thinking coerceAs could be enhanced now to make these pass again, since it seems to be singleton 0 and NA which could be coerced without warning from complex. Maybe there'll still be some warnings which should be tested by the tests. I'll keep going on this, hence WIP.

@mattdowle mattdowle added the WIP label Oct 6, 2021
@ben-schwen
Copy link
Member Author

I guess thats also kind of my fault. I only exchanged the coercing for the cases: INTSXP and REALSXP.
Changing it also for LGLSXP, CPLSXP and STRSXP should convert most errors into warnings.

Whats then still missing is the conversion from CPLSXP to other types. Is dropping imaginary part a valid approach for this? Maybe with a warning?

@mattdowle
Copy link
Member

mattdowle commented Oct 7, 2021

Looking at the coerceVector(source, SXP) in memrecycle made me realize that's not calling the as.character method; e.g. the below behavior in 1.14.2 looks wrong. I was expecting this to have been reported but I didn't find any issue. Does anyone know any issue numbers about this? integer64 (and nanotime) was turned off with an error asking user to as.character . So I'm about to remove the coerceInt64toStr function I just added in this PR and just change memrecycle to call as.character at R level to catch all cases.

> DT = data.table(A=letters[1:3])
> DT
        A
   <char>
1:      a
2:      b
3:      c
> DT[2, A:=as.Date("2020-03-04")]
> DT
        A
   <char>
1:      a
2:  18325
3:      c
> 

@mattdowle mattdowle removed the WIP label Oct 8, 2021
@mattdowle
Copy link
Member

Tiny % drop in project coverage (and hence coverage fail on project vs 100% coverage of diff) is correct due to removal of covered code.

@mattdowle mattdowle merged commit 5f9df4d into master Oct 8, 2021
@mattdowle mattdowle deleted the shift_asCoerce branch October 8, 2021 05:18
@ben-schwen ben-schwen mentioned this pull request Oct 16, 2021
7 tasks
@jangorecki jangorecki modified the milestones: 1.14.9, 1.15.0 Oct 29, 2023
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.

shift() with data type integer64
4 participants