-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added substring, json, len, is_valid methods (#767)
this closes #722
- Loading branch information
Showing
7 changed files
with
118 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
.. autosummary:: | ||
:toctree: ../apidocs/ | ||
Timestream.len | ||
Timestream.lower | ||
Timestream.substring | ||
Timestream.upper | ||
``` |
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
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,6 @@ | ||
{"_time":"1996-12-19T16:39:57.000000000","_key":"A","len":5.0} | ||
{"_time":"1996-12-19T16:39:58.000000000","_key":"B","len":5.0} | ||
{"_time":"1996-12-19T16:39:59.000000000","_key":"B","len":11.0} | ||
{"_time":"1996-12-19T16:40:00.000000000","_key":"B","len":null} | ||
{"_time":"1996-12-19T16:40:01.000000000","_key":"B","len":null} | ||
{"_time":"1996-12-19T16:40:02.000000000","_key":"B","len":7.0} |
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,6 @@ | ||
{"_time":"1996-12-19T16:39:57.000000000","_key":"A","substring_0_2":"hE","substring_1":"Ello","substring_0_i":"","substring_i":"hEllo"} | ||
{"_time":"1996-12-19T16:39:58.000000000","_key":"B","substring_0_2":"Wo","substring_1":"orld","substring_0_i":"World","substring_i":""} | ||
{"_time":"1996-12-19T16:39:59.000000000","_key":"B","substring_0_2":"he","substring_1":"ello world","substring_0_i":"hello wor","substring_i":"ld"} | ||
{"_time":"1996-12-19T16:40:00.000000000","_key":"B","substring_0_2":null,"substring_1":null,"substring_0_i":null,"substring_i":null} | ||
{"_time":"1996-12-19T16:40:01.000000000","_key":"B","substring_0_2":null,"substring_1":null,"substring_0_i":null,"substring_i":null} | ||
{"_time":"1996-12-19T16:40:02.000000000","_key":"B","substring_0_2":"go","substring_1":"oodbye","substring_0_i":"goodbye","substring_i":"goodbye"} |
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,31 @@ | ||
import kaskada as kd | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def source() -> kd.sources.CsvString: | ||
content = "\n".join( | ||
[ | ||
"time,key,s,n,t", | ||
'1996-12-19T16:39:57,A,"hEllo",0,"hEllo"', | ||
'1996-12-19T16:39:58,B,"World",5,"world"', | ||
'1996-12-19T16:39:59,B,"hello world",-2,"hello world"', | ||
'1996-12-19T16:40:00,B,,-2,"greetings"', | ||
'1996-12-19T16:40:01,B,,2,"salutations"', | ||
'1996-12-19T16:40:02,B,"goodbye",,', | ||
] | ||
) | ||
return await kd.sources.CsvString.create( | ||
content, time_column="time", key_column="key" | ||
) | ||
|
||
|
||
async def test_len(source, golden) -> None: | ||
s = source.col("s") | ||
golden.jsonl( | ||
kd.record( | ||
{ | ||
"len": s.len() | ||
} | ||
) | ||
) |
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,35 @@ | ||
import kaskada as kd | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def source() -> kd.sources.CsvString: | ||
content = "\n".join( | ||
[ | ||
"time,key,s,n,t", | ||
'1996-12-19T16:39:57,A,"hEllo",0,"hEllo"', | ||
'1996-12-19T16:39:58,B,"World",5,"world"', | ||
'1996-12-19T16:39:59,B,"hello world",-2,"hello world"', | ||
'1996-12-19T16:40:00,B,,-2,"greetings"', | ||
'1996-12-19T16:40:01,B,,2,"salutations"', | ||
'1996-12-19T16:40:02,B,"goodbye",,', | ||
] | ||
) | ||
return await kd.sources.CsvString.create( | ||
content, time_column="time", key_column="key" | ||
) | ||
|
||
|
||
async def test_substring(source, golden) -> None: | ||
s = source.col("s") | ||
n = source.col("n") | ||
golden.jsonl( | ||
kd.record( | ||
{ | ||
"substring_0_2": s.substring(start=0, end=2), | ||
"substring_1": s.substring(start=1), | ||
"substring_0_i": s.substring(end=n), | ||
"substring_i": s.substring(start=n), | ||
} | ||
) | ||
) |