Skip to content

Commit

Permalink
feat(python): rename flavor arg back to future
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihe774 committed Jul 5, 2024
1 parent c9f3c55 commit ea92723
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
38 changes: 19 additions & 19 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ def item(self, row: int | None = None, column: int | str | None = None) -> Any:
)
return s.get_index_signed(row)

def to_arrow(self, *, flavor: Flavor = Flavor.Compatible) -> pa.Table:
def to_arrow(self, *, future: Flavor = Flavor.Compatible) -> pa.Table:
"""
Collect the underlying arrow arrays in an Arrow Table.
Expand All @@ -1397,7 +1397,7 @@ def to_arrow(self, *, flavor: Flavor = Flavor.Compatible) -> pa.Table:
Parameters
----------
flavor
future
Use a specific version of Polars' internal data structures.
Examples
Expand All @@ -1416,10 +1416,10 @@ def to_arrow(self, *, flavor: Flavor = Flavor.Compatible) -> pa.Table:
if not self.width: # 0x0 dataframe, cannot infer schema from batches
return pa.table({})

if isinstance(flavor, Flavor):
flavor = flavor.value # type: ignore[assignment]
if isinstance(future, Flavor):
future = future.value # type: ignore[assignment]

record_batches = self._df.to_arrow(flavor)
record_batches = self._df.to_arrow(future)
return pa.Table.from_batches(record_batches)

@overload
Expand Down Expand Up @@ -3294,7 +3294,7 @@ def write_ipc(
file: None,
*,
compression: IpcCompression = "uncompressed",
flavor: Flavor = Flavor.Future1,
future: Flavor = Flavor.Future1,
) -> BytesIO: ...

@overload
Expand All @@ -3303,15 +3303,15 @@ def write_ipc(
file: str | Path | IO[bytes],
*,
compression: IpcCompression = "uncompressed",
flavor: Flavor = Flavor.Future1,
future: Flavor = Flavor.Future1,
) -> None: ...

def write_ipc(
self,
file: str | Path | IO[bytes] | None,
*,
compression: IpcCompression = "uncompressed",
flavor: Flavor = Flavor.Future1,
future: Flavor = Flavor.Future1,
) -> BytesIO | None:
"""
Write to Arrow IPC binary stream or Feather file.
Expand All @@ -3325,7 +3325,7 @@ def write_ipc(
written. If set to `None`, the output is returned as a BytesIO object.
compression : {'uncompressed', 'lz4', 'zstd'}
Compression method. Defaults to "uncompressed".
flavor
future
Use a specific version of Polars' internal data structures.
Examples
Expand All @@ -3348,13 +3348,13 @@ def write_ipc(
elif isinstance(file, (str, Path)):
file = normalize_filepath(file)

if isinstance(flavor, Flavor):
flavor = flavor.value # type: ignore[assignment]
if isinstance(future, Flavor):
future = future.value # type: ignore[assignment]

if compression is None:
compression = "uncompressed"

self._df.write_ipc(file, compression, flavor)
self._df.write_ipc(file, compression, future)
return file if return_bytes else None # type: ignore[return-value]

@overload
Expand All @@ -3363,7 +3363,7 @@ def write_ipc_stream(
file: None,
*,
compression: IpcCompression = "uncompressed",
flavor: Flavor = Flavor.Future1,
future: Flavor = Flavor.Future1,
) -> BytesIO: ...

@overload
Expand All @@ -3372,15 +3372,15 @@ def write_ipc_stream(
file: str | Path | IO[bytes],
*,
compression: IpcCompression = "uncompressed",
flavor: Flavor = Flavor.Future1,
future: Flavor = Flavor.Future1,
) -> None: ...

def write_ipc_stream(
self,
file: str | Path | IO[bytes] | None,
*,
compression: IpcCompression = "uncompressed",
flavor: Flavor = Flavor.Future1,
future: Flavor = Flavor.Future1,
) -> BytesIO | None:
"""
Write to Arrow IPC record batch stream.
Expand All @@ -3394,7 +3394,7 @@ def write_ipc_stream(
be written. If set to `None`, the output is returned as a BytesIO object.
compression : {'uncompressed', 'lz4', 'zstd'}
Compression method. Defaults to "uncompressed".
flavor
future
Use a specific version of Polars' internal data structures.
Examples
Expand All @@ -3417,13 +3417,13 @@ def write_ipc_stream(
elif isinstance(file, (str, Path)):
file = normalize_filepath(file)

if isinstance(flavor, Flavor):
flavor = flavor.value # type: ignore[assignment]
if isinstance(future, Flavor):
future = future.value # type: ignore[assignment]

if compression is None:
compression = "uncompressed"

self._df.write_ipc_stream(file, compression, flavor)
self._df.write_ipc_stream(file, compression, future)
return file if return_bytes else None # type: ignore[return-value]

def write_parquet(
Expand Down
10 changes: 5 additions & 5 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4343,15 +4343,15 @@ def to_torch(self) -> torch.Tensor:
# tensor.rename(self.name)
return tensor

def to_arrow(self, *, flavor: Flavor = Flavor.Compatible) -> pa.Array:
def to_arrow(self, *, future: Flavor = Flavor.Compatible) -> pa.Array:
"""
Return the underlying Arrow array.
If the Series contains only a single chunk this operation is zero copy.
Parameters
----------
flavor
future
Use a specific version of Polars' internal data structures.
Examples
Expand All @@ -4366,9 +4366,9 @@ def to_arrow(self, *, flavor: Flavor = Flavor.Compatible) -> pa.Array:
3
]
"""
if isinstance(flavor, Flavor):
flavor = flavor.value # type: ignore[assignment]
return self._s.to_arrow(flavor)
if isinstance(future, Flavor):
future = future.value # type: ignore[assignment]
return self._s.to_arrow(future)

def to_pandas(
self, *, use_pyarrow_extension_array: bool = False, **kwargs: Any
Expand Down

0 comments on commit ea92723

Please sign in to comment.