Permit true-ASCII attributes in non-from-pandas dataframes#1337
Merged
Conversation
nguyenv
reviewed
Oct 4, 2022
There was a problem hiding this comment.
Can you apply this diff? It modifies test_ascii_attribute to do better checking with var for dtype="ascii".
diff --git a/tiledb/tests/test_libtiledb.py b/tiledb/tests/test_libtiledb.py
index d322d77..98fa5a0 100644
--- a/tiledb/tests/test_libtiledb.py
+++ b/tiledb/tests/test_libtiledb.py
@@ -526,7 +526,15 @@ class AttributeTest(DiskTestCase):
dom = tiledb.Domain(
tiledb.Dim(name="d", domain=(1, 4), tile=1, dtype=np.uint32)
)
- attrs = [tiledb.Attr(name="A", dtype="ascii", var=True)]
+
+ with pytest.raises(TypeError) as exc_info:
+ tiledb.Attr(name="A", dtype="ascii", var=False)
+ assert (
+ str(exc_info.value) == "dtype is not compatible with var-length attribute"
+ )
+
+ attrs = [tiledb.Attr(name="A", dtype="ascii")]
+
schema = tiledb.ArraySchema(domain=dom, attrs=attrs, sparse=sparse)
tiledb.Array.create(path, schema)
@@ -547,6 +555,7 @@ class AttributeTest(DiskTestCase):
assert A.schema.nattr == 1
A.schema.dump()
assert_captured(capfd, "Type: STRING_ASCII")
+ assert A.schema.attr("A").isvar
assert A.schema.attr("A").dtype == np.bytes_
assert A.schema.attr("A").isascii
assert_array_equal(A[:]["A"], np.asarray(ascii_data, dtype=np.bytes_))
|
Thank you so much for catching this. Just have some minor things to add. |
|
Oh, please also update this under Bug Fixes in |
Contributor
Author
|
ok all ready for re-review @nguyenv -- thank you!! :) |
Contributor
Author
|
@nguyenv can you please merge this PR? I lack permissions to do so in this repo |
Yes will do so tomorrow morning. |
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.
Context:
main-oldbranch oftiledbsoma-pyto themainbranch.main-oldall the dataframes are written usingfrom_pandas: e.g. https://github.com/single-cell-data/TileDB-SOMA/blob/0.1.12/apis/python/src/tiledbsoma/annotation_dataframe.py#L411-L425maindataframes can be created that way, or from Arrow as at https://github.com/single-cell-data/TileDB-SOMA/blob/53af1a7a26dd241013102e9ac5b7db9e6a128393/apis/python/src/tiledbsoma/soma_dataframe.py#L92-L108dtype="ascii"as on [python] Update ASCII storage for dataframes single-cell-data/TileDB-SOMA#273, but in this non-from-pandas context (see [python] Use true ASCII attributes in dataframes single-cell-data/TileDB-SOMA#359), I getgiving me
However, with this mod in place, the array-create succeeds as intended.