-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add numpy
2 support
#434
Add numpy
2 support
#434
Changes from 5 commits
fd2e731
a0f8af4
8245f04
eb58404
f18af1e
c8192f4
20b6d4b
45853f2
712a276
5697b1d
3888e2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,13 +401,13 @@ def read_source_metadata( | |
) -> Tuple[int, int, np.dtype]: | ||
if source_type == "TILEDB_ARRAY": | ||
schema = tiledb.ArraySchema.load(source_uri) | ||
size = schema.domain.dim(1).domain[1] + 1 | ||
dimensions = schema.domain.dim(0).domain[1] + 1 | ||
size = np.int64(schema.domain.dim(1).domain[1]) + 1 | ||
dimensions = np.int64(schema.domain.dim(0).domain[1]) + 1 | ||
return size, dimensions, schema.attr(0).dtype | ||
if source_type == "TILEDB_SPARSE_ARRAY": | ||
schema = tiledb.ArraySchema.load(source_uri) | ||
size = schema.domain.dim(0).domain[1] + 1 | ||
dimensions = schema.domain.dim(1).domain[1] + 1 | ||
size = np.int64(schema.domain.dim(0).domain[1]) + 1 | ||
dimensions = np.int64(schema.domain.dim(1).domain[1]) + 1 | ||
return size, dimensions, schema.attr(0).dtype | ||
if source_type == "TILEDB_PARTITIONED_ARRAY": | ||
with tiledb.open(source_uri, "r", config=config) as source_array: | ||
|
@@ -2016,7 +2016,7 @@ def consolidate_partition_udf( | |
prev_index = partial_indexes[0] | ||
i = 0 | ||
for partial_index in partial_indexes[1:]: | ||
s = slice(int(prev_index), int(partial_index - 1)) | ||
s = slice(int(prev_index), int(partial_index) - 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is also because numpy 2 does not do data type promotion. With numpy 1 and the original code we were getting:
With numpy 2 and the original code we were getting:
Notice that we get |
||
if ( | ||
s.start <= s.stop | ||
and s.start != np.iinfo(np.dtype("uint64")).max | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We make this change b/c of changes to numpy data type promotion.
With numpy 1 and the original code we were getting:
With numpy 2 and the original code we instead were getting:
This is because in
size = schema.domain.dim(1).domain[1] + 1
the+ 1
used to cause a cast toint64
(which is required because2147483647
isint32
max).As mentioned in https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion, numpy no longer casts automatically:
So here we explicitly cast to
int64
so that we return the same value as we did before.