Convert single sample coordinates to dense xdas coordinates - #12
Merged
Conversation
An axis holding one sample gives tie indices of (0, 0), which xdas rejects with "`tie_indices` must be strictly increasing". Converting any patch with such an axis to an xdas DataArray therefore raised, for example DASCore's delta_patch example, whose distance axis has a single channel. Represent a single sample axis as a dense coordinate instead, which has no such constraint and round trips back to DASCore unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 338 340 +2
=========================================
+ Hits 338 340 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
np.arange defaults to int32 on Windows. Scaling those seconds to
nanoseconds overflows at nine seconds, so the time axes built from it were
not evenly sampled and the DASPy conversion correctly refused them:
arange(10, dtype=int32): last=2020-01-01T00:00:00.410065408
arange(10, dtype=int64): last=2020-01-01T00:00:09.000000000
This only affected the tests, which are the only place the pattern is
used. Ask for int64 explicitly so the axes are the same on every platform.
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.
Description
Two independent fixes, both needed to get
maingreen again. Neither changes behaviour for data that already converted successfully.1. Single sample coordinates
mainfails CI onTestDASCorePatch::test_example_patch_to_xdas_dataarray[delta_patch]:EvenlySampledCoordinate.to_xdas_coordbuilds anInterpCoordinatefromtie_indices, andDASCorePatchConverter._to_base_coordssets those to(0, len(coord) - 1). For an axis holding a single sample that degenerates to(0, 0), which xdas rejects. DASCore'sdelta_patchexample is(1, 200), i.e. one channel, so it trips over this.This is not specific to that example: any patch with a single channel, or a single time sample, failed to convert to an xdas DataArray.
A single sample axis is now represented as a
DenseCoordinate, which has no ordering constraint on its indices. It round trips back to DASCore unchanged, which the existingtest_example_patch_round_trip_to_dascore[delta_patch]covers.Worth noting this is not an xdas regression: xdas has rejected equal tie indices in every release back to 0.2.5. The test suite parametrizes over
tuple(EXAMPLE_PATCHES), so it grows as DASCore adds examples, anddelta_patchis simply the first one to have a length-one dimension.2. int32 overflow in the test time coordinates
With the above fixed, the Windows runners then failed two DASPy tests:
np.arangedefaults to int32 on Windows, anddc.to_timedelta64scaling those seconds to nanoseconds overflows at nine seconds:The error was correct, the time axis really was not evenly sampled. Only the tests use this pattern, so they now ask for int64 explicitly.
Verification
delta_patchexample test both fail without the source change and pass with it..pre-commit-config.yaml.Note
This is independent of #11, which is red for the
delta_patchreason above. Merging this first should turn #11 green.Checklist
I have (if applicable):