functime-org / functime

Time-series machine learning at scale. Built with Polars for embarrassingly parallel feature extraction and forecasts on panel data.
https://docs.functime.ai
Apache License 2.0
970 stars 52 forks source link

chore: Replace deprecated `zero_copy_only` argument with `allow_copy` #222

Open khrapovs opened 4 weeks ago

khrapovs commented 4 weeks ago

What does this implement/fix? Explain your changes.

Replace deprecated zero_copy_only argument with allow_copy (https://docs.pola.rs/py-polars/html/reference/series/api/polars.Series.to_numpy.html). For example, I get this warning:

DeprecationWarning: The `zero_copy_only` parameter for `Series.to_numpy` is deprecated. Use the `allow_copy` parameter instead, which is the inverse of `zero_copy_only`.
fft = np.fft.rfft(x.to_numpy(zero_copy_only=True))
vercel[bot] commented 4 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
functime-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 7:21am
baggiponte commented 4 weeks ago

Ciao @khrapovs, thank you for this PR! 😊

I noticed GH says there are conflicts with the main branch: would you mind reviewing them?

Also, I could not keep up with Polars versioning and API changes, so for the moment we are stuck with essentially >=20.0.7 (if not == 😥). What Polars version are you using?

khrapovs commented 4 weeks ago

I noticed GH says there are conflicts with the main branch: would you mind reviewing them?

Apologies, clicked the wrong button. The branch is now up-to-date.

Also, I could not keep up with Polars versioning and API changes, so for the moment we are stuck with essentially >=20.0.7 (if not == 😥). What Polars version are you using?

In my own project polars==0.20.31.

baggiponte commented 3 weeks ago

I noticed GH says there are conflicts with the main branch: would you mind reviewing them?

Apologies, clicked the wrong button. The branch is now up-to-date.

Thanks!

Also, I could not keep up with Polars versioning and API changes, so for the moment we are stuck with essentially >=20.0.7 (if not == 😥). What Polars version are you using?

In my own project polars==0.20.31.

Uh that's what I was suspecting. Unfortunately, we can't just merge this immediately (and have some parts of the codebase supporting Polars>=0.20.31 and some other >=0.20.7).

I'm working on conformal predictions right now but of course supporting the latest Polars is my goal. I'll keep this PR when we are working on this (pretty substantial) effort (which is going to happen very soon).

Issue is #159. Anyone is free to add a checklist of stuff to do!

khrapovs commented 3 weeks ago

This problem can be solved by something along these lines:

if polars.version < X:
  ...to_numpy(zero_copy_only=True)...
else:
  ...to_numpy(allow_copy=False)...

But would anyone tolerate this ugliness in the codebase? Even if it is temporary until the lower requirement for polars is risen until X?