Closed lorenzwalthert closed 1 year ago
I'll give this a go after work, I think it should be possible
Ups, thanks @alexander-beedie, I misspelled freezegun in my search. Updated issue title and comment.
@nezinomas just FYI, this should work in the next release
@MarcoGorelli @ritchie46 Is it possible that this partially broke with the 1.0 release?
I am right now upgrading from 0.20.31
to 1.6
and now the following code fails:
import datetime
import polars as pl
from freezegun import freeze_time
with freeze_time("2012-01-14"):
pl.lit(datetime.date.today())
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/Users/armin/venv/weplan3.11/lib/python3.11/site-packages/polars/functions/lit.py", line 132, in lit
return wrap_expr(plr.lit(value, allow_object=False))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot create expression literal for value of type FakeDate: FakeDate(2012, 1, 14)
Hint: Pass `allow_object=True` to accept any value and create a literal of type Object.
thanks @aberres for reporting - it should work in 1.5.x, it regressed in 1.6.0
https://github.com/pola-rs/polars/pull/18497 should address it, will get back to it soon-ish (and if I can't fix it in time, i'd suggest we just revert the PR that introduced the regression, no big deal)
@MarcoGorelli Great, thanks for looking into this.
I will upgrade to 1.5 then and skip 1.6.
Problem description
In some of our unit tests and benchmarks, we use the relatively popular freezegun package to manipulate system time. However, when I try to create a data frame that consists such a mocked date time, I get an error:
Solution
It would be great if bindings for this object type would be supported. We are transitioning from pandas and there it seemed to always have worked out of the box ~(could not find an issue in GitHub with 'freezegun' in it)~. Thanks a lot for this library, it's a game changer for us. Hear my system info FWIW.