[WIP] Support get_class and roundtrip on datetime datasets#1313
Draft
[WIP] Support get_class and roundtrip on datetime datasets#1313
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1313 +/- ##
==========================================
- Coverage 93.17% 93.02% -0.15%
==========================================
Files 41 41
Lines 10099 10143 +44
Branches 2079 2093 +14
==========================================
+ Hits 9410 9436 +26
- Misses 413 423 +10
- Partials 276 284 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4 tasks
_isoformat was returning a Python str while convert_dtype labeled the result as the 'ascii' dtype. Encode to bytes (matching _ascii's contract) so the scalar branch produces the expected b'YYYY-MM-DDTHH:MM:SS' values. Also handle str and bytes passthrough for idempotence when __convert_string has already pre-converted the value. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add Column (Data) and BarWithColumnData (Container) helper classes and two tests exercising build of datetime/date values through a dataset spec with data_type_inc set. test_date_array_ext_spec specifically mirrors the traceback in #1311. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add _parse_isoformat helper (reverse of _isoformat) and wire it into __get_subspec_values so attributes and dataset data with isodatetime/datetime dtype are converted from stored ISO str/bytes back into datetime/date before being passed to the container constructor. Also applied to Data containers' direct const_args['data'] assignment in construct(). Scoped to scalar values; inc-site dtype override and array datasets are not yet handled. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Pass ignore_name/ignore_hdmf_attrs to assertContainerEqual so the top-level 'root' vs 'my_group' name mismatch and read-time object_id reassignment don't fail the equality check. - my_data3 has no data_type_inc, so it is stored as a named scalar dataset field on the group and read back as a plain datetime value. Assert against the value directly rather than .data. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
construct() now accepts an optional spec_ext (parallel to build()) that
carries per-site overrides from the parent's subspec. Threaded through
BuildManager.construct, TypeMap.construct, and ObjectMapper.construct.
The Data-container construct path uses spec_ext for dtype resolution when
the base def has no dtype, so a parent group spec like
DatasetSpec(data_type_inc='X', dtype='datetime', ...)
correctly drives datetime parsing on read even when X's def declares no
dtype. __get_sub_builders passes the inc-site subspec as spec_ext at the
construct call site.
spec_ext defaults to None to preserve backward compatibility with all
existing call sites.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Data containers can wrap scalar values (e.g., a single datetime) for which len() is not defined. Gate the length comparison on _is_collection so the helper works for both scalar and collection-valued Data instances. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
scalar_data now includes datetime.datetime and datetime.date so generated classes for dtype-less DatasetSpecs accept scalar datetime values on construct (read path) and on user-side construction (write path). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Motivation
Fix #429. Related to #1312.
How to test the behavior?
Checklist
CHANGELOG.mdwith your changes?