Skip to content

Commit

Permalink
Merge pull request #99 from realratchet/master
Browse files Browse the repository at this point in the history
Boolean infer more flexible
  • Loading branch information
realratchet authored Oct 25, 2023
2 parents 012ef0f + 31e2cfe commit 3681383
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tablite/_nimlite/infertypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ proc inferNone*(str: ptr string): PY_NoneType {.inline.} =
raise newException(ValueError, "not a none")

proc inferBool*(str: ptr string): bool {.inline.} =
let sstr = str[]
let sstr = str[].toLower()

if sstr in ["True", "true"]:
if sstr == "true":
return true
elif sstr in ["False", "false"]:
elif sstr == "false":
return false

raise newException(ValueError, "not a boolean value")
Expand Down
2 changes: 1 addition & 1 deletion tablite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def from_file(
text_escape_openings="",
text_escape_closures="",
tqdm=_tqdm,
):
) -> "Table":
"""
reads path and imports 1 or more tables
Expand Down
2 changes: 1 addition & 1 deletion tablite/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
major, minor, patch = 2023, 8, 1
major, minor, patch = 2023, 8, 2
__version_info__ = (major, minor, patch)
__version__ = ".".join(str(i) for i in __version_info__)
2 changes: 2 additions & 0 deletions tests/data/booleans.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lc_false,lc_true,py_false,py_true,xl_false,xl_true
false,true,False,True,FALSE,TRUE
6 changes: 6 additions & 0 deletions tests/test_filereader_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,3 +658,9 @@ def test_header_offset_ods():

assert list(tbl.columns.keys()) == ["header"]
assert list(tbl["header"]) == [1, 2, 3, 4, 5]

def test_booleans():
tbl = Table.from_file(Path(__file__).parent / "data" / "booleans.csv")

assert len(tbl) == 1
assert next(tbl.rows) == [False, True, False, True, False, True]

0 comments on commit 3681383

Please sign in to comment.