Skip to content

Commit

Permalink
add a docstring note to series to_torch
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed May 19, 2024
1 parent a68782a commit 362b8d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4537,11 +4537,19 @@ def to_torch(self) -> torch.Tensor:
This functionality is currently considered **unstable**. It may be
changed at any point without it being considered a breaking change.
Notes
-----
PyTorch tensors do not support UInt16, UInt32, or UInt64; these dtypes
will be automatically cast to Int32, Int64, and Int64, respectively.
Examples
--------
>>> s = pl.Series("x", [1, 0, 1, 2, 0], dtype=pl.UInt8)
>>> s.to_torch()
tensor([1, 0, 1, 2, 0], dtype=torch.uint8)
>>> s = pl.Series("x", [5.5, -10.0, 2.5], dtype=pl.Float32)
>>> s.to_torch()
tensor([ 5.5000, -10.0000, 2.5000])
"""
torch = import_optional("torch")

Expand Down

0 comments on commit 362b8d9

Please sign in to comment.