-
Notifications
You must be signed in to change notification settings - Fork 76
NumpyDates #666
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
Merged
Merged
NumpyDates #666
Conversation
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
Implement constructors, accessors, and display for TimeDelta64 and InlineTimeDelta64. Add conversions from Dates.Period and NaT strings. Unify NaT handling via NAT sentinel. Replace unit access with unitpair and store units as (Unit, Cint). Provide defaultunit and a showvalue helper; update isnan to use NAT. Changing units between instances is not yet implemented (except for NaT). BREAKING CHANGE: TimeDelta64 fields changed from unit_base/unit_scale to unit::Tuple{Unit,Cint}. The unit(...) accessor is removed; use unitpair(d) instead. The generic Dates.value(::AbstractTimeDelta64) method was removed; use Dates.value on concrete types.
Use Dates.year(d) and Dates.month(d) in the Date-based constructor instead of value(Dates.Year(d)) and value(Dates.Month(d)). The previous approach could error or yield wrong values when computing YEAR/MONTH offsets relative to 1970, affecting YEARS and MONTHS units. Also includes minor whitespace cleanup.
Add NumpyDates tests verifying Date conversions to DateTime64 and InlineDateTime64 across units Y, M, D, h, m, s, ms, us, ns, comparing against expected int values. Covers: - DateTime64(Date, Symbol) - InlineDateTime64{U}(Date) - InlineDateTime64(Date, Symbol) and checks Dates.value and unitpair correctness. Add test/scripts/np_dates.py to generate NumPy-based ground-truth int64 values for selected dates.
- Replace ÷ with fld in conversions to apply floor semantics for negative values, matching NumPy datetime64 behavior - Correct ATTOSECONDS multiplier to 1e15 - Add comprehensive DateTime -> DateTime64/InlineDateTime64 tests, including pre-epoch cases, and refine existing Date tests - Add script to generate NumPy reference values for tests
Add module docstring and detailed docs for Unit enum and datetime/ timedelta types (DateTime64, InlineDateTime64, TimeDelta64, InlineTimeDelta64), including accepted constructor inputs and unit references. Document supertypes AbstractDateTime64 and AbstractTimeDelta64. No functional changes.
- Add NumpyDates section to pythoncall-reference with API docs - Update release notes with NumpyDates overview - Clarify docstrings: runtime vs inline units and memory layout
Add mapping entries for numpy.datetime64 and numpy.timedelta64 in conversion-to-julia.md. Document conversion to NumpyDates types and inline/Dates fallbacks to clarify behavior when passing numpy date/time objects from Python.
…escale function - Add pyconvert rules for InlineDateTime64 and InlineTimeDelta64 types - Refactor DateTime64 and TimeDelta64 constructors to use rescale for unit conversions - Introduce unitscale and rescale functions in Unit.jl for efficient scaling between units - Add convert methods for DatesInstant and DatesPeriod types - Update common.jl with new type aliases and helper functions - Enhance tests for new conversion capabilities and error handling These changes streamline the conversion logic, reduce code duplication, and improve performance by centralizing unit scaling operations. No breaking changes to public APIs.
…for datetime64 and timedelta64 - Implement rescale function to handle unit changes in DateTime64 and TimeDelta64 instead of throwing errors - Expand Base.convert methods for InlineDateTime64 and InlineTimeDelta64 to support more types - Add new pyconvert rules for NumpyDates.DatesInstant and NumpyDates.DatesPeriod in numpy.jl This enhances type conversions and removes previous limitations on unit scaling.
…delta support - Simplified accessor functions in DateTime64, InlineDateTime64, InlineTimeDelta64, and TimeDelta64 by removing unnecessary function wrappers - Added support for NumpyDates.InlineDateTime64 and InlineTimeDelta64 in pyjlarray_isarrayabletype and pytypestrdescr - Refactored pytypestrdescr to use if-elseif structure for better readability - Updated PyArray.jl to handle unbound units in type conversion This enhances numpy date type integration while cleaning up code structure.
…edelta types Ensure that type T is concrete before checking if it subtypes the union of InlineDateTime64 and InlineTimeDelta64, preventing potential issues with abstract types in pytypestrdescr function.
8d8ea6e
to
60de18b
Compare
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.
numpy.datetime64
andnumpy.timedelta64
to these types.PyArray
.Todo: