Read missing, infinite and fractional-millisecond datetimes and durations - #254
Open
Thenewmanator15 wants to merge 1 commit into
Open
Thenewmanator15 wants to merge 1 commit into
Thenewmanator15 wants to merge 1 commit into
Conversation
…ions
A datetime array holding NaT, or a duration holding NaN or a fractional number of
milliseconds, was not converted at all: the conversion threw (DateTime of NaN,
Millisecond(1.5) or Millisecond(NaN)), and the object came back as its raw uint32
MCOS reference. Missing and infinite values now become `missing` (so an array with
one is Union{Missing,DateTime} or Union{Missing,Millisecond}), and durations are
rounded to whole milliseconds, as datetimes already were.
test/missing_gen.m writes test/v7 and test/v7.3/missing_times.mat (NaT in an array,
alone and with a time zone; ±Inf datetimes; NaN durations; 1.5, 2.25 and 2.75 ms).
The .mat files are not included; the testset is skipped until they are generated
in MATLAB and committed.
This branch has not been deployed
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
datetimearray holdingNaT, or adurationholdingNaNor a fractional number of milliseconds, is not converted at all today: the conversion throws —DateTimeofNaN,Millisecond(1.5),Millisecond(NaN)— and the variable comes back as its rawuint32MCOS reference (UInt32[0xdd000000, 0x2, …]) instead of values. Fractional milliseconds are common in real durations (milliseconds(1.5),seconds(0.0025)), so any such array was affected, as was every datetime array with a gap.With this change:
NaTandNaNdurations becomemissing, so an array holding one isUnion{Missing,DateTime}/Union{Missing,Millisecond}; arrays without one keep their concrete element type;±Infdatetimes (whichDateTimecannot hold) aremissingtoo;The comment asking whether a stored datetime's imaginary part is the sub-millisecond part now answers it: it is the low half of a double-double, below half an ulp of the real part, so
real + imag == realinFloat64and nothing is lost atDateTimeresolution.Tests, and the same request as #253.
test/missing_gen.mwritestest/v7/missing_times.matandtest/v7.3/missing_times.mat:NaTin an array, alone, and with a time zone;±Infdatetimes;NaNdurations, in an array and alone; 1.5, 2.25 and 2.75 ms. I can't contribute the.matfiles, so they are not included — could someone with MATLAB run the script intest/and commit its two files? Until then the testset skips. Against the files the script writes (MATLAB R2025a), onmasterall seven variables come back as rawuint32references in both formats; with this change the full suite passes (599). Without the files: 581 pass, 2 skipped.Not in scope: writing arrays with
missingdatetimes or durations back to a file.🤖 Generated with Claude Code