Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Jan 19, 2025
1 parent b9acd7f commit bd9a0b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/safeds/data/tabular/containers/_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def __init__(

# Implementation
self._name: str = name
self._lazy_frame: pl.LazyFrame = pl.LazyFrame(data, schema={name: dtype}, strict=False)
self.__series_cache: pl.Series | None = None
self.__series_cache: pl.Series | None = pl.Series(name, data, dtype=dtype, strict=False)
self._lazy_frame: pl.LazyFrame = self.__series_cache.to_frame().lazy()

def __contains__(self, value: object) -> bool:
import polars as pl
Expand Down
11 changes: 7 additions & 4 deletions src/safeds/data/tabular/query/_lazy_string_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING

from safeds._utils import _structural_hash
from safeds._validation import _convert_and_check_datetime_format
from safeds._validation import _convert_and_check_datetime_format, _check_bounds, _ClosedBound
from safeds.data.tabular.containers._lazy_cell import _LazyCell

from ._string_operations import StringOperations
Expand Down Expand Up @@ -75,17 +75,20 @@ def substring(
start: _ConvertibleToIntCell = 0,
length: _ConvertibleToIntCell = None,
) -> Cell[str | None]:
if isinstance(length, int):
_check_bounds("length", length, lower_bound=_ClosedBound(0))

return _LazyCell(self._expression.str.slice(start, length))

def to_date(self, *, format: str | None = None) -> Cell[datetime.date | None]:
def to_date(self, *, format: str | None = "iso") -> Cell[datetime.date | None]:
if format == "iso":
format = "%F" # noqa: A001
elif format is not None:
format = _convert_and_check_datetime_format(format, type_="date", used_for_parsing=True) # noqa: A001

return _LazyCell(self._expression.str.to_date(format=format, strict=False))

def to_datetime(self, *, format: str | None = None) -> Cell[datetime.datetime | None]:
def to_datetime(self, *, format: str | None = "iso") -> Cell[datetime.datetime | None]:
if format == "iso":
format = "%+" # noqa: A001
elif format is not None:
Expand All @@ -99,7 +102,7 @@ def to_int(self, *, base: _ConvertibleToIntCell = 10) -> Cell[int | None]:
def to_lowercase(self) -> Cell[str | None]:
return _LazyCell(self._expression.str.to_lowercase())

def to_time(self, *, format: str | None = None) -> Cell[datetime.time | None]:
def to_time(self, *, format: str | None = "iso") -> Cell[datetime.time | None]:
if format == "iso":
format = "%T" # noqa: A001
elif format is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/safeds/data/tabular/query/_string_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def substring(

# TODO: add format parameter + document
@abstractmethod
def to_date(self, *, format: str | None = None) -> Cell[datetime.date | None]:
def to_date(self, *, format: str | None = "iso") -> Cell[datetime.date | None]:
"""
Convert the string value in the cell to a date.
Expand Down Expand Up @@ -331,7 +331,7 @@ def to_date(self, *, format: str | None = None) -> Cell[datetime.date | None]:

# TODO: add format parameter + document
@abstractmethod
def to_datetime(self, *, format: str | None = None) -> Cell[datetime.datetime | None]:
def to_datetime(self, *, format: str | None = "iso") -> Cell[datetime.datetime | None]:
"""
Convert the string value in the cell to a datetime.
Expand Down

0 comments on commit bd9a0b2

Please sign in to comment.