-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle different data types for destinations from CellGrid The destinations cell may hold other data types than string (e.g. when read from Excel). This fix handles data types other than strings by casting to a string before further processing. Note: by default `datetime` is rendered as `dd/mm/yyyy hh:mm:ss` which contains a whitespace (" "). This would be interpreted as *two* destinations. Solution: Replace whitespace with underscore and raise a warning to the user. --------- Co-authored-by: Jan Bielecki <[email protected]>
- Loading branch information
Showing
4 changed files
with
49 additions
and
7 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,25 @@ | ||
import datetime | ||
import warnings | ||
from pdtable.io.parsers.blocks import _get_destinations_safely_stripped | ||
|
||
|
||
class TestGetDestinationsSafelyStripped: | ||
def test_string_input(self) -> None: | ||
assert _get_destinations_safely_stripped(" hello ") == "hello" | ||
|
||
def test_int_input(self) -> None: | ||
assert _get_destinations_safely_stripped(123) == "123" | ||
|
||
def test_string_input_with_leading_trailing_spaces(self) -> None: | ||
assert _get_destinations_safely_stripped(" hello world ") == "hello world" | ||
|
||
def test_int_input_with_leading_trailing_spaces(self) -> None: | ||
assert _get_destinations_safely_stripped(" 123 ") == "123" | ||
|
||
def test_datetime_input(self) -> None: | ||
datetime_now = datetime.datetime.now() | ||
|
||
with warnings.catch_warnings(record=True) as w: | ||
destinations = _get_destinations_safely_stripped(datetime_now) | ||
assert len(w) == 1 | ||
assert destinations.replace(' ', '') == destinations |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
pandas<2.0 | ||
numpy | ||
numpy<2.0 | ||
typing-extensions | ||
|
||
# OPTIONAL | ||
|
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