Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-convert numbers to strings when appending to a text dtype tensor (…
…#2782) Auto-convert numbers to strings when appending to a text dtype tensor
- Loading branch information
1 parent
aacf27a
commit 9fa795d
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
|
||
from deeplake.core.chunk.uncompressed_chunk import UncompressedChunk | ||
from deeplake.core.meta import TensorMeta | ||
|
||
|
||
def test_text_sample_to_byte_string(): | ||
chunk = UncompressedChunk( | ||
min_chunk_size=10, | ||
max_chunk_size=1000, | ||
tiling_threshold=1000, | ||
tensor_meta=TensorMeta(), | ||
) | ||
|
||
assert chunk._text_sample_to_byte_string("test") == b"test" | ||
assert chunk._text_sample_to_byte_string(3) == b"3" | ||
assert chunk._text_sample_to_byte_string(3.5) == b"3.5" | ||
assert chunk._text_sample_to_byte_string(None) == b"" | ||
assert chunk._text_sample_to_byte_string([]) == b"" |