From f7f07d5d4fc2b305fb68561654c68dc5d6d94dfb Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 11 Aug 2026 20:32:47 -0700 Subject: [PATCH] Generate pylibcudf stubs with stubgen-pyx --- .pre-commit-config.yaml | 10 + ci/checks/generate_pylibcudf_stubs.py | 113 ++ python/pylibcudf/pylibcudf/aggregation.pyi | 647 ++++++++-- python/pylibcudf/pylibcudf/binaryop.pyi | 116 +- python/pylibcudf/pylibcudf/column.pyi | 653 +++++++--- .../pylibcudf/pylibcudf/column_factories.pyi | 99 +- python/pylibcudf/pylibcudf/concatenate.pyi | 28 +- python/pylibcudf/pylibcudf/context.pyi | 24 +- .../pylibcudf/pylibcudf/contiguous_split.pyi | 240 +++- python/pylibcudf/pylibcudf/copying.pyi | 450 +++++-- python/pylibcudf/pylibcudf/datetime.pyi | 289 +++-- .../pylibcudf/experimental/_join_streams.pyi | 36 +- python/pylibcudf/pylibcudf/expressions.pyi | 200 +-- python/pylibcudf/pylibcudf/filling.pyi | 157 ++- python/pylibcudf/pylibcudf/gpumemoryview.pyi | 67 +- python/pylibcudf/pylibcudf/groupby.pyi | 206 +++- python/pylibcudf/pylibcudf/hashing.pyi | 242 +++- python/pylibcudf/pylibcudf/interop.pyi | 71 +- python/pylibcudf/pylibcudf/io/avro.pyi | 129 +- python/pylibcudf/pylibcudf/io/csv.pyi | 735 +++++++++-- python/pylibcudf/pylibcudf/io/datasource.pyi | 8 +- .../pylibcudf/io/experimental/hybrid_scan.pyi | 549 +++++++-- python/pylibcudf/pylibcudf/io/json.pyi | 765 ++++++++++-- python/pylibcudf/pylibcudf/io/orc.pyi | 597 +++++++-- python/pylibcudf/pylibcudf/io/parquet.pyi | 1096 +++++++++++++++-- .../pylibcudf/io/parquet_metadata.pyi | 404 ++++-- python/pylibcudf/pylibcudf/io/text.pyi | 151 ++- python/pylibcudf/pylibcudf/io/timezone.pyi | 35 +- python/pylibcudf/pylibcudf/io/types.pyi | 413 +++++-- python/pylibcudf/pylibcudf/join.pyi | 576 ++++++--- python/pylibcudf/pylibcudf/json.pyi | 127 +- python/pylibcudf/pylibcudf/labeling.pyi | 54 +- python/pylibcudf/pylibcudf/lists.pyi | 546 +++++--- python/pylibcudf/pylibcudf/merge.pyi | 45 +- python/pylibcudf/pylibcudf/null_mask.pyi | 214 +++- .../pylibcudf/nvtext/byte_pair_encode.pyi | 52 +- .../pylibcudf/nvtext/deduplicate.pyi | 111 +- .../pylibcudf/nvtext/edit_distance.pyi | 36 +- .../pylibcudf/nvtext/generate_ngrams.pyi | 99 +- python/pylibcudf/pylibcudf/nvtext/jaccard.pyi | 42 +- python/pylibcudf/pylibcudf/nvtext/minhash.pyi | 157 ++- .../pylibcudf/nvtext/ngrams_tokenize.pyi | 43 +- .../pylibcudf/pylibcudf/nvtext/normalize.pyi | 74 +- python/pylibcudf/pylibcudf/nvtext/replace.pyi | 78 +- python/pylibcudf/pylibcudf/nvtext/stemmer.pyi | 71 +- .../pylibcudf/pylibcudf/nvtext/tokenize.pyi | 219 +++- .../pylibcudf/nvtext/wordpiece_tokenize.pyi | 55 +- python/pylibcudf/pylibcudf/partitioning.pyi | 121 +- python/pylibcudf/pylibcudf/prefetch.pyi | 18 +- python/pylibcudf/pylibcudf/quantiles.pyi | 114 +- python/pylibcudf/pylibcudf/reduce.pyi | 243 +++- python/pylibcudf/pylibcudf/replace.pyi | 155 ++- python/pylibcudf/pylibcudf/reshape.pyi | 93 +- python/pylibcudf/pylibcudf/rolling.pyi | 219 +++- python/pylibcudf/pylibcudf/round.pyi | 86 +- python/pylibcudf/pylibcudf/scalar.pyi | 173 ++- python/pylibcudf/pylibcudf/search.pyi | 107 +- python/pylibcudf/pylibcudf/sorting.pyi | 364 ++++-- .../pylibcudf/pylibcudf/stream_compaction.pyi | 280 +++-- .../pylibcudf/strings/attributes.pyi | 76 +- .../pylibcudf/strings/capitalize.pyi | 79 +- python/pylibcudf/pylibcudf/strings/case.pyi | 84 +- .../pylibcudf/strings/char_types.pyi | 86 +- .../pylibcudf/pylibcudf/strings/combine.pyi | 137 ++- .../pylibcudf/pylibcudf/strings/contains.pyi | 112 +- .../strings/convert/convert_booleans.pyi | 72 +- .../strings/convert/convert_datetime.pyi | 105 +- .../strings/convert/convert_durations.pyi | 73 +- .../strings/convert/convert_fixed_point.pyi | 94 +- .../strings/convert/convert_floats.pyi | 89 +- .../strings/convert/convert_integers.pyi | 174 ++- .../strings/convert/convert_ipv4.pyi | 83 +- .../strings/convert/convert_lists.pyi | 44 +- .../strings/convert/convert_urls.pyi | 58 +- .../pylibcudf/pylibcudf/strings/extract.pyi | 97 +- python/pylibcudf/pylibcudf/strings/find.pyi | 193 ++- .../pylibcudf/strings/find_multiple.pyi | 64 +- .../pylibcudf/pylibcudf/strings/findall.pyi | 64 +- .../pylibcudf/pylibcudf/strings/padding.pyi | 97 +- .../pylibcudf/strings/regex_flags.pyi | 13 +- .../pylibcudf/strings/regex_program.pyi | 38 +- python/pylibcudf/pylibcudf/strings/repeat.pyi | 41 +- .../pylibcudf/pylibcudf/strings/replace.pyi | 112 +- .../pylibcudf/strings/replace_re.pyi | 74 +- .../pylibcudf/pylibcudf/strings/reverse.pyi | 32 +- .../pylibcudf/pylibcudf/strings/side_type.pyi | 12 +- python/pylibcudf/pylibcudf/strings/slice.pyi | 49 +- .../pylibcudf/strings/split/partition.pyi | 62 +- .../pylibcudf/strings/split/split.pyi | 273 +++- python/pylibcudf/pylibcudf/strings/strip.pyi | 39 +- .../pylibcudf/pylibcudf/strings/translate.pyi | 81 +- python/pylibcudf/pylibcudf/strings/wrap.pyi | 42 +- python/pylibcudf/pylibcudf/table.pyi | 148 ++- python/pylibcudf/pylibcudf/table_equality.pyi | 44 +- python/pylibcudf/pylibcudf/traits.pyi | 124 +- python/pylibcudf/pylibcudf/transform.pyi | 263 +++- python/pylibcudf/pylibcudf/transpose.pyi | 33 +- python/pylibcudf/pylibcudf/types.pyi | 229 ++-- python/pylibcudf/pylibcudf/unary.pyi | 234 ++-- python/pylibcudf/pylibcudf/utilities.pyi | 12 +- python/pylibcudf/pylibcudf/utils.pyi | 11 +- 101 files changed, 13199 insertions(+), 3750 deletions(-) create mode 100644 ci/checks/generate_pylibcudf_stubs.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4102593b0fdd..bc01f8e4a488 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -205,6 +205,14 @@ repos: language: system pass_filenames: false verbose: true + - id: stubgen-pyx-pylibcudf + name: Generate pylibcudf .pyi stubs + entry: python ci/checks/generate_pylibcudf_stubs.py + language: python + files: ^python/pylibcudf/pylibcudf/.*[.](pyx|pxd)$ + pass_filenames: false + additional_dependencies: + - stubgen-pyx==0.2.18 - repo: https://github.com/codespell-project/codespell rev: v2.4.3 hooks: @@ -221,7 +229,9 @@ repos: hooks: - id: ruff args: ["--fix"] + exclude: .*[.]pyi$ - id: ruff-format + exclude: .*[.]pyi$ - repo: https://github.com/rapidsai/pre-commit-hooks rev: v1.6.0 hooks: diff --git a/ci/checks/generate_pylibcudf_stubs.py b/ci/checks/generate_pylibcudf_stubs.py new file mode 100644 index 000000000000..412593683cd0 --- /dev/null +++ b/ci/checks/generate_pylibcudf_stubs.py @@ -0,0 +1,113 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +from __future__ import annotations + +import subprocess +import sys +from pathlib import Path + +PACKAGE_DIR = Path("python/pylibcudf/pylibcudf") + + +def _git_ls_files(pattern: str) -> list[Path]: + result = subprocess.run( + ["git", "ls-files", pattern], + check=True, + stdout=subprocess.PIPE, + text=True, + ) + return [Path(line) for line in result.stdout.splitlines()] + + +def _spdx_header(path: Path) -> str: + if not path.exists(): + return "" + lines = path.read_text().splitlines() + header = [] + for line in lines: + if line.startswith("# SPDX-"): + header.append(line) + continue + if header and line == "": + break + if header: + break + return "\n".join(header) + "\n\n" if header else "" + + +def _stored_spdx_header(path: Path) -> str: + result = subprocess.run( + ["git", "show", f"HEAD:{path.as_posix()}"], + stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL, + text=True, + ) + if result.returncode != 0: + return "" + lines = result.stdout.splitlines() + header = [] + for line in lines: + if line.startswith("# SPDX-"): + header.append(line) + continue + if header and line == "": + break + if header: + break + return "\n".join(header) + "\n\n" if header else "" + + +def _replace_header(path: Path, header: str) -> None: + lines = path.read_text().splitlines() + while lines and lines[0].startswith("# SPDX-"): + lines.pop(0) + if lines and lines[0] == "": + lines.pop(0) + path.write_text(header + "\n".join(lines) + "\n") + + +def _generate_stub(pyx_file: Path, pyi_file: Path) -> int: + header = _spdx_header(pyi_file) or _stored_spdx_header(pyi_file) or _spdx_header(pyx_file) + result = subprocess.run( + [ + "stubgen-pyx", + str(PACKAGE_DIR), + "--file", + pyx_file.relative_to(PACKAGE_DIR).as_posix(), + "--output-file", + str(pyi_file), + "--continue-on-error", + "--include-private", + ], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + text=True, + ) + if result.returncode == 0: + _replace_header(pyi_file, header) + else: + print(result.stdout, end="") + print(result.stderr, end="", file=sys.stderr) + return result.returncode + + +def main() -> int: + failures = [] + for pyi_file in _git_ls_files(str(PACKAGE_DIR / "**/*.pyi")): + pyx_file = pyi_file.with_suffix(".pyx") + if not pyx_file.exists(): + continue + if _generate_stub(pyx_file, pyi_file) != 0: + failures.append(pyx_file) + + if failures: + print("Failed to generate pylibcudf stubs for:", file=sys.stderr) + for path in failures: + print(f" {path}", file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/python/pylibcudf/pylibcudf/aggregation.pyi b/python/pylibcudf/pylibcudf/aggregation.pyi index 6735478e52f6..b9a0adaab00a 100644 --- a/python/pylibcudf/pylibcudf/aggregation.pyi +++ b/python/pylibcudf/pylibcudf/aggregation.pyi @@ -1,114 +1,543 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum - -from pylibcudf.types import ( - DataType, - Interpolation, - NanEquality, - NullEquality, - NullOrder, - NullPolicy, - Order, -) - -class Kind(IntEnum): - SUM = ... - PRODUCT = ... - MIN = ... - MAX = ... - COUNT_VALID = ... - COUNT_ALL = ... - ANY = ... - ALL = ... - SUM_OF_SQUARES = ... - MEAN = ... - VARIANCE = ... - STD = ... - MEDIAN = ... - QUANTILE = ... - ARGMAX = ... - ARGMIN = ... - NUNIQUE = ... - NTH_ELEMENT = ... - RANK = ... - COLLECT_LIST = ... - COLLECT_SET = ... - PTX = ... - CUDA = ... - CORRELATION = ... - COVARIANCE = ... - -class CorrelationType(IntEnum): - PEARSON = ... - KENDALL = ... - SPEARMAN = ... - -class EWMHistory(IntEnum): - INFINITE = ... - FINITE = ... - -class RankMethod(IntEnum): - FIRST = ... - AVERAGE = ... - MIN = ... - MAX = ... - DENSE = ... - -class RankPercentage(IntEnum): - NONE = ... - ZERO_NORMALIZED = ... - ONE_NORMALIZED = ... - -class UdfType(IntEnum): - CUDA = ... - PTX = ... +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/aggregation.pyx + +from pylibcudf.libcudf.aggregation import Kind +from pylibcudf.libcudf.aggregation import bitwise_op +from pylibcudf.libcudf.aggregation import bitwise_op as BitwiseOp +from pylibcudf.libcudf.aggregation import correlation_type +from pylibcudf.libcudf.aggregation import correlation_type as CorrelationType +from pylibcudf.libcudf.aggregation import ewm_history +from pylibcudf.libcudf.aggregation import ewm_history as EWMHistory +from pylibcudf.libcudf.aggregation import rank_method +from pylibcudf.libcudf.aggregation import rank_method as RankMethod +from pylibcudf.libcudf.aggregation import rank_percentage +from pylibcudf.libcudf.aggregation import rank_percentage as RankPercentage +from pylibcudf.libcudf.types import (interpolation, nan_equality, + null_equality, null_order, null_policy, + order, size_type) +from pylibcudf.libcudf.types import udf_source_type as UdfSourceType + +from .types import DataType + +__all__ = ['Aggregation', 'BitwiseOp', 'CorrelationType', 'EWMHistory', 'Kind', 'RankMethod', 'RankPercentage', 'UdfSourceType', 'all', 'any', 'argmax', 'argmin', 'bitwise', 'collect_list', 'collect_set', 'correlation', 'count', 'covariance', 'ewma', 'histogram', 'is_valid_aggregation', 'lag', 'lead', 'm2', 'max', 'mean', 'median', 'merge_histogram', 'merge_lists', 'merge_m2', 'merge_sets', 'merge_tdigest', 'min', 'nth_element', 'nunique', 'product', 'quantile', 'rank', 'row_number', 'std', 'sum', 'sum_of_squares', 'tdigest', 'udf', 'variance'] class Aggregation: + """A type of aggregation to perform. + + Aggregations are passed to APIs like + :py:func:`~pylibcudf.groupby.GroupBy.aggregate` to indicate what + operations to perform. Using a class for aggregations provides a unified + API for handling parametrizable aggregations. This class should never be + instantiated directly, only via one of the factory functions. + + For details, see :cpp:class:`cudf::aggregation`. + """ def __init__(self): ... - def kind(self) -> Kind: ... - -def sum() -> Aggregation: ... -def product() -> Aggregation: ... -def min() -> Aggregation: ... -def max() -> Aggregation: ... -def count(null_handling: NullPolicy = NullPolicy.INCLUDE) -> Aggregation: ... -def any() -> Aggregation: ... -def all() -> Aggregation: ... -def sum_of_squares() -> Aggregation: ... -def mean() -> Aggregation: ... -def variance(ddof: int = 1) -> Aggregation: ... -def std(ddof: int = 1) -> Aggregation: ... -def median() -> Aggregation: ... -def quantile( - quantiles: list[float], interp: Interpolation = Interpolation.LINEAR -) -> Aggregation: ... -def argmax() -> Aggregation: ... -def argmin() -> Aggregation: ... -def ewma(center_of_mass: float, history: EWMHistory) -> Aggregation: ... -def nunique(null_handling: NullPolicy = NullPolicy.EXCLUDE) -> Aggregation: ... -def nth_element( - n: int, null_handling: NullPolicy = NullPolicy.INCLUDE -) -> Aggregation: ... -def collect_list( - null_handling: NullPolicy = NullPolicy.INCLUDE, -) -> Aggregation: ... -def collect_set( - null_handling: NullPolicy = NullPolicy.INCLUDE, - nulls_equal: NullEquality = NullEquality.EQUAL, - nans_equal: NanEquality = NanEquality.ALL_EQUAL, -) -> Aggregation: ... -def udf(operation: str, output_type: DataType) -> Aggregation: ... -def correlation(type: CorrelationType, min_periods: int) -> Aggregation: ... -def covariance(min_periods: int, ddof: int) -> Aggregation: ... -def rank( - method: RankMethod, - column_order: Order = Order.ASCENDING, - null_handling: NullPolicy = NullPolicy.EXCLUDE, - null_precedence: NullOrder = NullOrder.AFTER, - percentage: RankPercentage = RankPercentage.NONE, -) -> Aggregation: ... -def m2() -> Aggregation: ... -def merge_m2() -> Aggregation: ... -def is_valid_aggregation(source: DataType, agg: Aggregation) -> bool: ... + def __eq__(self, other): ... + def __hash__(self): ... + def kind(self): + """Get the kind of the aggregation.""" + def __repr__(self): ... + +def sum() -> Aggregation: + """Create a sum aggregation. + + For details, see :cpp:func:`make_sum_aggregation`. + + Returns + ------- + Aggregation + The sum aggregation. + """ +def product() -> Aggregation: + """Create a product aggregation. + + For details, see :cpp:func:`make_product_aggregation`. + + Returns + ------- + Aggregation + The product aggregation. + """ +def min() -> Aggregation: + """Create a min aggregation. + + For details, see :cpp:func:`make_min_aggregation`. + + Returns + ------- + Aggregation + The min aggregation. + """ +def max() -> Aggregation: + """Create a max aggregation. + + For details, see :cpp:func:`make_max_aggregation`. + + Returns + ------- + Aggregation + The max aggregation. + """ +def ewma(center_of_mass: float, history: ewm_history) -> Aggregation: + """Create a EWMA aggregation. + + For details, see :cpp:func:`make_ewma_aggregation`. + + Parameters + ---------- + center_of_mass : float + The decay in terms of the center of mass + history : ewm_history + Whether or not to treat the history as infinite. + + Returns + ------- + Aggregation + The EWMA aggregation. + """ +def count(null_handling: null_policy=null_policy.EXCLUDE) -> Aggregation: + """Create a count aggregation. + + For details, see :cpp:func:`make_count_aggregation`. + + Parameters + ---------- + null_handling : null_policy, default EXCLUDE + Whether or not nulls should be included. + + Returns + ------- + Aggregation + The count aggregation. + """ +def any() -> Aggregation: + """Create an any aggregation. + + For details, see :cpp:func:`make_any_aggregation`. + + Returns + ------- + Aggregation + The any aggregation. + """ +def all() -> Aggregation: + """Create an all aggregation. + + For details, see :cpp:func:`make_all_aggregation`. + + Returns + ------- + Aggregation + The all aggregation. + """ +def sum_of_squares() -> Aggregation: + """Create a sum_of_squares aggregation. + + For details, see :cpp:func:`make_sum_of_squares_aggregation`. + + Returns + ------- + Aggregation + The sum_of_squares aggregation. + """ +def mean() -> Aggregation: + """Create a mean aggregation. + + For details, see :cpp:func:`make_mean_aggregation`. + + Returns + ------- + Aggregation + The mean aggregation. + """ +def variance(ddof: size_type=1) -> Aggregation: + """Create a variance aggregation. + + For details, see :cpp:func:`make_variance_aggregation`. + + Parameters + ---------- + ddof : int, default 1 + Delta degrees of freedom. + + Returns + ------- + Aggregation + The variance aggregation. + """ +def std(ddof: size_type=1) -> Aggregation: + """Create a std aggregation. + + For details, see :cpp:func:`make_std_aggregation`. + + Parameters + ---------- + ddof : int, default 1 + Delta degrees of freedom. The default value is 1. + + Returns + ------- + Aggregation + The std aggregation. + """ +def median() -> Aggregation: + """Create a median aggregation. + + For details, see :cpp:func:`make_median_aggregation`. + + Returns + ------- + Aggregation + The median aggregation. + """ +def quantile(quantiles: list, interp: interpolation=interpolation.LINEAR) -> Aggregation: + """Create a quantile aggregation. + + For details, see :cpp:func:`make_quantile_aggregation`. + + Parameters + ---------- + quantiles : list + List of quantiles to compute, should be between 0 and 1. + interp : interpolation, default LINEAR + Interpolation technique to use when the desired quantile lies between + two data points. + + Returns + ------- + Aggregation + The quantile aggregation. + """ +def argmax() -> Aggregation: + """Create an argmax aggregation. + + For details, see :cpp:func:`make_argmax_aggregation`. + + Returns + ------- + Aggregation + The argmax aggregation. + """ +def argmin() -> Aggregation: + """Create an argmin aggregation. + + For details, see :cpp:func:`make_argmin_aggregation`. + + Returns + ------- + Aggregation + The argmin aggregation. + """ +def nunique(null_handling: null_policy=null_policy.EXCLUDE) -> Aggregation: + """Create a nunique aggregation. + + For details, see :cpp:func:`make_nunique_aggregation`. + + Parameters + ---------- + null_handling : null_policy, default EXCLUDE + Whether or not nulls should be included. + + Returns + ------- + Aggregation + The nunique aggregation. + """ +def nth_element(n: size_type, null_handling: null_policy=null_policy.INCLUDE) -> Aggregation: + """Create a nth_element aggregation. + + For details, see :cpp:func:`make_nth_element_aggregation`. + + Parameters + ---------- + null_handling : null_policy, default INCLUDE + Whether or not nulls should be included. + + Returns + ------- + Aggregation + The nth_element aggregation. + """ +def collect_list(null_handling: null_policy=null_policy.INCLUDE) -> Aggregation: + """Create a collect_list aggregation. + + For details, see :cpp:func:`make_collect_list_aggregation`. + + Parameters + ---------- + null_handling : null_policy, default INCLUDE + Whether or not nulls should be included. + + Returns + ------- + Aggregation + The collect_list aggregation. + """ +def collect_set(null_handling=null_policy.INCLUDE, nulls_equal=null_equality.EQUAL, nans_equal=nan_equality.ALL_EQUAL) -> Aggregation: + """Create a collect_set aggregation. + + For details, see :cpp:func:`make_collect_set_aggregation`. + + Parameters + ---------- + null_handling : null_policy, default INCLUDE + Whether or not nulls should be included. + nulls_equal : null_equality, default EQUAL + Whether or not nulls should be considered equal. + nans_equal : nan_equality, default ALL_EQUAL + Whether or not NaNs should be considered equal. + + Returns + ------- + Aggregation + The collect_set aggregation. + """ +def udf(operation: str, output_type: DataType) -> Aggregation: + """Create a udf aggregation. + + For details, see :cpp:func:`make_udf_aggregation`. + + Parameters + ---------- + operation : str + The operation to perform as a string of PTX code. + output_type : DataType + The output type of the aggregation. + + Returns + ------- + Aggregation + The udf aggregation. + """ +def correlation(type: correlation_type, min_periods: size_type) -> Aggregation: + """Create a correlation aggregation. + + For details, see :cpp:func:`make_correlation_aggregation`. + + Parameters + ---------- + type : correlation_type + The type of correlation to compute. + min_periods : int + The minimum number of observations to consider for computing the + correlation. + + Returns + ------- + Aggregation + The correlation aggregation. + """ +def covariance(min_periods: size_type, ddof: size_type) -> Aggregation: + """Create a covariance aggregation. + + For details, see :cpp:func:`make_covariance_aggregation`. + + Parameters + ---------- + min_periods : int + The minimum number of observations to consider for computing the + covariance. + ddof : int + Delta degrees of freedom. + + Returns + ------- + Aggregation + The covariance aggregation. + """ +def rank(method: rank_method, column_order: order=order.ASCENDING, null_handling: null_policy=null_policy.EXCLUDE, null_precedence: null_order=null_order.AFTER, percentage: rank_percentage=rank_percentage.NONE) -> Aggregation: + """Create a rank aggregation. + + For details, see :cpp:func:`make_rank_aggregation`. + + Parameters + ---------- + method : rank_method + The method to use for ranking. + column_order : order, default ASCENDING + The order in which to sort the column. + null_handling : null_policy, default EXCLUDE + Whether or not nulls should be included. + null_precedence : null_order, default AFTER + Whether nulls should come before or after non-nulls. + percentage : rank_percentage, default NONE + Whether or not ranks should be converted to percentages, and if so, + the type of normalization to use. + + Returns + ------- + Aggregation + The rank aggregation. + """ +def histogram() -> Aggregation: + """Create a histogram aggregation. + + For details, see :cpp:func:`make_histogram_aggregation`. + + Returns + ------- + Aggregation + The histogram aggregation. + """ +def m2() -> Aggregation: + """Create a M2 aggregation. + + For details, see :cpp:func:`make_m2_aggregation`. + + Returns + ------- + Aggregation + The M2 aggregation. + """ +def merge_m2() -> Aggregation: + """Create a merge M2 aggregation. + + For details, see :cpp:func:`make_merge_m2_aggregation`. + + Returns + ------- + Aggregation + The merge M2 aggregation. + """ +def merge_histogram() -> Aggregation: + """Create a merge histogram aggregation. + + For details, see :cpp:func:`make_merge_histogram_aggregation`. + + Returns + ------- + Aggregation + The merge histogram aggregation. + """ +def merge_lists() -> Aggregation: + """Create a merge lists aggregation. + + For details, see :cpp:func:`make_merge_lists_aggregation`. + + Returns + ------- + Aggregation + The merge lists aggregation. + """ +def merge_sets(nulls_equal: null_equality=null_equality.EQUAL, nans_equal: nan_equality=nan_equality.ALL_EQUAL) -> Aggregation: + """Create a merge sets aggregation. + + For details, see :cpp:func:`make_merge_sets_aggregation`. + + Parameters + ---------- + nulls_equal : null_equality, default EQUAL + Whether or not nulls should be considered equal. + nans_equal : nan_equality, default ALL_EQUAL + Whether or not NaNs should be considered equal. + + Returns + ------- + Aggregation + The merge sets aggregation. + """ +def merge_tdigest(max_centroids: int) -> Aggregation: + """Create a merge TDIGEST aggregation. + + For details, see :cpp:func:`make_merge_tdigest_aggregation`. + + Parameters + ---------- + max_centroids : int + Parameter controlling compression level and accuracy + on subsequent queries on the output tdigest data. + + Returns + ------- + Aggregation + The merge TDIGEST aggregation. + """ +def tdigest(max_centroids: int) -> Aggregation: + """Create a TDIGEST aggregation. + + For details, see :cpp:func:`make_tdigest_aggregation`. + + Parameters + ---------- + max_centroids : int + Parameter controlling compression level and accuracy + on subsequent queries on the output tdigest data. + + Returns + ------- + Aggregation + The TDIGEST aggregation. + """ +def bitwise(op: bitwise_op) -> Aggregation: + """Create a bitwise aggregation. + + For details, see :cpp:func:`make_bitwise_aggregation`. + + Parameters + ---------- + op : BitwiseOp + The bitwise operation to perform on the input column + + Returns + ------- + Aggregation + The bitwise aggregation. + """ +def lag(offset: size_type) -> Aggregation: + """Create a lag aggregation. + + For details, see :cpp:func:`make_lag_aggregation`. + + Parameters + ---------- + offset : int + The number of rows to lag the input + + Returns + ------- + Aggregation + The lag aggregation. + """ +def lead(offset: size_type) -> Aggregation: + """Create a lead aggregation. + + For details, see :cpp:func:`make_lead_aggregation`. + + Parameters + ---------- + offset : int + The number of rows to lead the input + + Returns + ------- + Aggregation + The lead aggregation. + """ +def row_number() -> Aggregation: + """Create a row_number aggregation. + + For details, see :cpp:func:`make_row_number_aggregation`. + + Returns + ------- + Aggregation + The row_number aggregation. + """ +def is_valid_aggregation(source: DataType, agg: Aggregation) -> bool: + """ + Return if an aggregation is supported for a given datatype. + + Parameters + ---------- + source + The type of the column the aggregation is being performed on. + agg + The aggregation. + + Returns + ------- + True if the aggregation is supported. + """ diff --git a/python/pylibcudf/pylibcudf/binaryop.pyi b/python/pylibcudf/pylibcudf/binaryop.pyi index 1f3c9a2cb64f..a8d9ade83c99 100644 --- a/python/pylibcudf/pylibcudf/binaryop.pyi +++ b/python/pylibcudf/pylibcudf/binaryop.pyi @@ -1,60 +1,66 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/binaryop.pyx +from pylibcudf.libcudf.binaryop import binary_operator +from pylibcudf.libcudf.binaryop import binary_operator as BinaryOperator from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.scalar import Scalar -from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -class BinaryOperator(IntEnum): - ADD = ... - SUB = ... - MUL = ... - DIV = ... - TRUE_DIV = ... - FLOOR_DIV = ... - MOD = ... - PMOD = ... - PYMOD = ... - POW = ... - INT_POW = ... - LOG_BASE = ... - ATAN2 = ... - SHIFT_LEFT = ... - SHIFT_RIGHT = ... - SHIFT_RIGHT_UNSIGNED = ... - BITWISE_AND = ... - BITWISE_OR = ... - BITWISE_XOR = ... - LOGICAL_AND = ... - LOGICAL_OR = ... - EQUAL = ... - NOT_EQUAL = ... - LESS = ... - GREATER = ... - LESS_EQUAL = ... - GREATER_EQUAL = ... - NULL_EQUALS = ... - NULL_MAX = ... - NULL_MIN = ... - NULL_NOT_EQUALS = ... - GENERIC_BINARY = ... - NULL_LOGICAL_AND = ... - NULL_LOGICAL_OR = ... - INVALID_BINARY = ... - -def binary_operation( - lhs: Column | Scalar, - rhs: Column | Scalar, - op: BinaryOperator, - output_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_supported_operation( - out: DataType, lhs: DataType, rhs: DataType, op: BinaryOperator -) -> bool: ... +from .column import Column +from .scalar import Scalar +from .types import DataType + +__all__ = ['BinaryOperator', 'binary_operation', 'is_supported_operation'] + +def binary_operation(lhs: Column | Scalar, rhs: Column | Scalar, op: binary_operator, output_type: DataType, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a binary operation between a column and another column or scalar. + + ``lhs`` and ``rhs`` may be a + :py:class:`~pylibcudf.column.Column` or a + :py:class:`~pylibcudf.scalar.Scalar`, but at least one must be a + :py:class:`~pylibcudf.column.Column`. + + For details, see :cpp:func:`binary_operation`. + + Parameters + ---------- + lhs : Union[Column, Scalar] + The left hand side argument. + rhs : Union[Column, Scalar] + The right hand side argument. + op : BinaryOperator + The operation to perform. + output_type : DataType + The data type to use for the output. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + The result of the binary operation + """ +def is_supported_operation(out: DataType, lhs: DataType, rhs: DataType, op: binary_operator) -> bool: + """Check if an operation is supported for the given data types. + + For details, see :cpp:func:`is_supported_operation`. + + Parameters + ---------- + out : DataType + The output data type. + lhs : DataType + The left hand side data type. + rhs : DataType + The right hand side data type. + op : BinaryOperator + The operation to check. + + Returns + ------- + bool + True if the operation is supported, False otherwise + """ diff --git a/python/pylibcudf/pylibcudf/column.pyi b/python/pylibcudf/pylibcudf/column.pyi index 53513aec8ac1..2b450ba89977 100644 --- a/python/pylibcudf/pylibcudf/column.pyi +++ b/python/pylibcudf/pylibcudf/column.pyi @@ -1,162 +1,539 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Iterable, Sequence -from typing import Any, Protocol, TypedDict +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/column.pyx +from typing import Iterable + +from pylibcudf.libcudf.types import size_type from rmm.pylibrmm.device_buffer import DeviceBuffer from rmm.pylibrmm.memory_resource import DeviceMemoryResource +from rmm.pylibrmm.stream import Stream + +from ._interop_helpers import ArrowLike, ColumnMetadata +from .scalar import Scalar +from .types import DataType + +__all__ = ['Column', 'ListsColumnView', 'StructsColumnView', 'is_c_contiguous'] -from pylibcudf._interop_helpers import ArrowLike, ColumnMetadata -from pylibcudf.scalar import Scalar -from pylibcudf.span import Span -from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -class ArrayInterfaceBase(TypedDict): - shape: tuple[int, ...] - typestr: str - data: None | tuple[int, bool] - version: int - strides: None | tuple[int, ...] - descr: None | list[tuple[Any, ...]] - -class ArrayInterface(ArrayInterfaceBase): - mask: None | "SupportsArrayInterface" - -class CudaArrayInterface(ArrayInterfaceBase): - stream: None | int - mask: None | "SupportsCudaArrayInterface" - -# Numpy doesn't use a typed dict for their type stubs, they just annotate -# as dict[str, Any]. So do the same here but with a union type so it's -# clearer. -class SupportsCudaArrayInterface(Protocol): +class _ArrowColumnHolder: + """A holder for an Arrow column for gpumemoryview lifetime management.""" + +class OwnerWithCAI: + """An interface for column view's data with gpumemoryview via CAI.""" @property - def __cuda_array_interface__( - self, - ) -> CudaArrayInterface | dict[str, Any]: ... + def __cuda_array_interface__(self): ... -class SupportsArrayInterface(Protocol): +class OwnerMaskWithCAI: + """An interface for column view's null mask with gpumemoryview via CAI.""" @property - def __array_interface__(self) -> ArrayInterface | dict[str, Any]: ... + def __cuda_array_interface__(self): ... + +class ArrayInterfaceWrapper: + def __init__(self, iface): ... class Column: - def __init__( - self, - data_type: DataType, - size: int, - data: Span | None, - mask: Span | None, - null_count: int, - offset: int, - children: Iterable[Column], - validate: bool = True, - ) -> None: ... - def type(self) -> DataType: ... - def child(self, index: int) -> Column: ... - def size(self) -> int: ... - def null_count(self) -> int: ... - def offset(self) -> int: ... - def data(self) -> Span | None: ... - def null_mask(self) -> Span | None: ... - def children(self) -> list[Column]: ... - def num_children(self) -> int: ... - def copy( - self, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Column: ... - def device_buffer_size(self) -> int: ... - def with_mask( - self, mask: Span | None, null_count: int, validate: bool = True - ) -> Column: ... - def list_view(self) -> ListsColumnView: ... - def struct_view(self) -> StructsColumnView: ... + """A container of nullable device data as a column of elements. + + This class is an implementation of `Arrow columnar data specification + `__ for data stored on + GPUs. It relies on Python memoryview-like semantics to maintain shared + ownership of the data it is constructed with, so any input data may also be + co-owned by other data structures. The Column is designed to be operated on + using algorithms backed by libcudf. + + Parameters + ---------- + data_type : DataType + The type of data in the column. + size : size_type + The number of rows in the column. + data : gpumemoryview + The data the column will refer to. + mask : gpumemoryview + The null mask for the column. + null_count : int + The number of null rows in the column. + offset : int + The offset into the data buffer where the column's data begins. + children : Iterable[Column] + The children of this column if it is a compound column type. + validate : bool, default True + Whether to validate that data and mask satisfy Span protocol. + """ + __hash__ = None + + def __init__(self, data_type: DataType, size: size_type, data: object, mask: object, null_count: size_type, offset: size_type, children, validate: bool=True): ... + def to_arrow(self, metadata: ColumnMetadata | str | None=None, stream: Stream | None=None) -> ArrowLike: + """Create a pyarrow array from a pylibcudf column. + + Parameters + ---------- + metadata : ColumnMetadata | str | None + The metadata to attach to the column. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pyarrow.Array + """ @staticmethod - def from_scalar( - scalar: Scalar, - size: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Column: ... - def to_scalar( - self, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Scalar: ... + def from_arrow(obj: ArrowLike, dtype: DataType | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> ArrowLike: + """ + Create a Column from an Arrow-like object using the Arrow C Data Interface. + + This method supports host and device Arrow arrays or streams. It detects + the type of Arrow object provided and constructs a `pylibcudf.Column` + accordingly using the appropriate Arrow C pointer-based interface. + + Parameters + ---------- + obj : Arrow-like + An object implementing one of the following: + - `__arrow_c_array__` (host Arrow array) + - `__arrow_c_device_array__` (device Arrow array) + - `__arrow_c_stream__` (host Arrow stream) + - `__arrow_c_device_stream__` (device Arrow stream) + dtype : DataType | None + The pylibcudf data type. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource for allocations. + + Returns + ------- + Column + A `pylibcudf.Column` representing the Arrow data. + + Raises + ------ + NotImplementedError + If the Arrow-like object is a device stream (`__arrow_c_device_stream__`). + If the dtype argument is not None. + ValueError + If the object does not implement a known Arrow C interface. + + Notes + ----- + - This method supports zero-copy construction for device arrays. + """ @staticmethod - def all_null_like( - like: Column, - size: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Column: ... + def from_rmm_buffer(buff: DeviceBuffer, dtype: DataType, size: size_type, children): + """ + Create a Column from an RMM DeviceBuffer. + + Parameters + ---------- + buff : DeviceBuffer + The data rmm.DeviceBuffer. + size : size_type + The number of rows in the column. + dtype : DataType + The type of the data in the buffer. + children : Iterable[Column] + The child columns. + + Notes + ----- + To provide a mask and null count, use `Column.with_mask` after + this method. + """ + def with_mask(self, mask: object, null_count: size_type, validate: bool=True) -> Column: + """Augment this column with a new null mask. + + Parameters + ---------- + mask : Span-like or None + New mask (or None to unset the mask). Must satisfy Span protocol. + null_count : int + New null count. If this is incorrect, bad things happen. + validate : bool, default True + Whether to validate that mask satisfies Span protocol. + + Returns + ------- + New Column object sharing data with self (except for the mask which is new). + """ @staticmethod - def from_rmm_buffer( - buff: DeviceBuffer, - dtype: DataType, - size: int, - children: Iterable[Column], - ) -> Column: ... - def to_arrow( - self, - metadata: ColumnMetadata | str | None = None, - stream: CudaStreamLike | None = None, - ) -> ArrowLike: ... - # Private methods below are included because polars is currently using them, - # but we want to remove stubs for these private methods eventually - def _to_schema(self, metadata: Any = None) -> Any: ... - def _to_host_array(self, stream: CudaStreamLike) -> Any: ... + def from_scalar(slr: Scalar, size: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Create a Column from a Scalar. + + Parameters + ---------- + slr : Scalar + The scalar to create a column from. + size : size_type + The number of elements in the column. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A Column containing the scalar repeated `size` times. + """ + def to_scalar(self, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Scalar: + """ + Return the first value of 1-element column as a Scalar. + + Raises + ------ + ValueError + If the column has more than one row. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned scalar's device memory. + + Returns + ------- + Scalar + A Scalar representing the only value in the column, including nulls. + """ @staticmethod - def from_arrow( - obj: ArrowLike, - dtype: DataType | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Column: ... + def all_null_like(like: Column, size: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Create an all null column from a template. + + Parameters + ---------- + like : Column + Column whose type we should mimic + size : int + Number of rows in the resulting column. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + An all-null column of `size` rows and type matching `like`. + """ @classmethod - def from_cuda_array_interface( - cls, - obj: SupportsCudaArrayInterface, - stream: CudaStreamLike | None = None, - ) -> Column: ... + def from_array_interface(cls, obj, stream: object | None=None): + """ + Create a Column from an object implementing the NumPy Array Interface. + + If the object provides a raw memory pointer via the "data" field, + we use that pointer directly and avoid copying. Otherwise, a ValueError + is raised. + + Parameters + ---------- + obj : Any + Must implement the ``__array_interface__`` protocol. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A Column containing the data from the array interface. + + Raises + ------ + TypeError + If the object does not implement ``__array_interface__``. + ValueError + If the array is not 1D or 2D, or is not C-contiguous. + If the number of rows exceeds size_type limit. + If the 'data' field is invalid. + NotImplementedError + If the object has a mask. + """ @classmethod - def from_array_interface( - cls, obj: SupportsArrayInterface, stream: CudaStreamLike | None = None - ) -> Column: ... + def from_cuda_array_interface(cls, obj, stream: object | None=None): + """ + Create a Column from an object implementing the CUDA Array Interface. + + Parameters + ---------- + obj : Any + Must implement the ``__cuda_array_interface__`` protocol. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A Column containing the data from the CUDA array interface. + + Raises + ------ + TypeError + If the object does not support ``__cuda_array_interface__``. + ValueError + If the object is not 1D or 2D, or is not C-contiguous. + If the number of rows exceeds size_type limit. + NotImplementedError + If the object has a mask. + """ @classmethod - def from_array( - cls, - obj: SupportsCudaArrayInterface | SupportsArrayInterface, - stream: CudaStreamLike | None = None, - ) -> Column: ... - @staticmethod - def struct_from_children(children: Sequence[Column]) -> Column: ... + def from_array(cls, obj, stream: object | None=None): + """ + Create a Column from any object which supports the NumPy + or CUDA array interface. + + Parameters + ---------- + obj : object + The input array to be converted into a `pylibcudf.Column`. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + + Raises + ------ + TypeError + If the input does not implement a supported array interface. + + Notes + ----- + - Only C-contiguous host and device ndarrays are supported. + For device arrays, the data is not copied. + + Examples + -------- + >>> import pylibcudf as plc + >>> import cupy as cp + >>> cp_arr = cp.array([[1,2],[3,4]]) + >>> col = plc.Column.from_array(cp_arr) + """ @staticmethod - def from_iterable_of_py( - obj: Iterable, - dtype: DataType | None = None, - stream: CudaStreamLike | None = None, - ) -> Column: ... - def to_pylist(self) -> list: ... + def from_iterable_of_py(obj: Iterable, dtype: DataType | None=None, stream: object | None=None) -> Column: + """ + Create a Column from a Python iterable of scalar values or nested iterables. + + Parameters + ---------- + obj : Iterable + An iterable of Python scalar values (int, float, bool, str) or nested lists. + dtype : DataType | None + The type of the leaf elements. If not specified, the type is inferred. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A Column containing the data from the input iterable. + + Raises + ------ + TypeError + If the input contains unsupported scalar types. + ValueError + If the iterable is empty and dtype is not provided. + + Notes + ----- + - Only scalar types int, float, bool, and str are supported. + - Nested iterables must be materialized as lists. + - Jagged nested lists are not supported. Inner lists must have the same shape. + - Nulls (None) are not currently supported in input values. + - dtype must match the inferred or actual type of the scalar values + - Large strings are supported, meaning the combined length of all strings + (in bytes) can exceed the maximum 32-bit integer value. In that case, + the offsets column is automatically promoted to use 64-bit integers. + """ + def to_pylist(self) -> list: + """ + Convert the Column to a Python list. + + Only supports fixed-width and string columns. + + Returns + ------- + list + A list of Python objects representing the column data. + + Raises + ------ + NotImplementedError + If the column type is not fixed-width or string. + """ + @classmethod + def struct_from_children(cls, children: Iterable[Column]): + """ + Create a struct Column from a list of child columns. + + Parameters + ---------- + children : Iterable[Column] + A list of child columns. + + Returns + ------- + Column + A struct Column with the provided the child columns. + + Notes + ----- + The null count and null mask is taken from the first child column. + Use `Column.with_mask` on the result of struct_from_children to reset + the null count and mask. + """ + def type(self) -> DataType: + """The type of data in the column.""" + def child(self, index: size_type) -> Column: + """Get a child column of this column. + + Parameters + ---------- + index : size_type + The index of the child column to get. + + Returns + ------- + Column + The child column. + """ + def num_children(self) -> size_type: + """The number of children of this column.""" + def list_view(self) -> ListsColumnView: + """Accessor for methods of a Column that are specific to lists.""" + def struct_view(self) -> StructsColumnView: + """Accessor for methods of a Column that are specific to structs.""" + def data(self) -> object: + """The data buffer of the column.""" + def null_mask(self) -> object: + """The null mask of the column.""" + def size(self) -> size_type: + """The number of elements in the column.""" + def offset(self) -> size_type: + """The offset of the column.""" + def null_count(self) -> size_type: + """The number of null elements in the column.""" + def set_null_count(self, null_count: size_type) -> None: + """Set the null count of the column. + + Parameters + ---------- + null_count : size_type + The new null count of the column. + """ + def children(self) -> list: + """The children of the column.""" + def copy(self, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a copy of the column.""" + def device_buffer_size(self) -> int: + """ + The total size of the device buffers used by the Column. + + Notes + ----- + Since Columns rely on Python memoryview-like semantics to maintain + shared ownership of the data, the device buffers underlying this column + might be shared between other data structures including other columns. + + Returns + ------- + Number of bytes. + """ + def _create_nested_column_metadata(self): ... + def _to_schema(self, metadata=None): + """Create an Arrow schema from this Column.""" + def _to_host_array(self, stream: object): ... + def _to_device_array(self): ... + def __arrow_c_array__(self, requested_schema=None): ... + def __arrow_c_device_array__(self, requested_schema=None, **kwargs): ... class ListsColumnView: - def __init__(self, column: Column): ... - def child(self) -> Column: ... - def offsets(self) -> Column: ... - def get_sliced_child( - self, stream: CudaStreamLike | None = None - ) -> Column: ... + """Accessor for methods of a Column that are specific to lists.""" + __hash__ = None + + def __init__(self, col: Column): ... + def child(self): + """The data column of the underlying list column.""" + def offsets(self): + """The offsets column of the underlying list column.""" + def get_sliced_child(self, stream: object | None=None) -> Column: + """ + Get the list elements child properly sliced to match parent's view. + + Parameters + ---------- + stream : Stream, optional + CUDA stream to use + + Returns + ------- + Column + The sliced elements column + """ class StructsColumnView: - def __init__(self, column: Column): ... - def child(self) -> Column: ... - def offsets(self) -> Column: ... - def get_sliced_child( - self, index: int, stream: CudaStreamLike | None = None - ) -> Column: ... - -def is_c_contiguous( - shape: Sequence[int], strides: Sequence[int] | None, itemsize: int -) -> bool: ... + """Accessor for methods of a Column that are specific to structs.""" + __hash__ = None + + def __init__(self, col: Column): ... + def get_sliced_child(self, index: int, stream: object | None=None) -> Column: + """ + Get the struct elements child properly sliced to match parent's view. + + Parameters + ---------- + index : int + The index of the child to get. + stream : Stream, optional + CUDA stream to use + + Returns + ------- + Column + The sliced elements column + """ + +def _infer_list_depth_and_dtype(obj: list) -> tuple[int, type]: + """Infer the nesting depth and final scalar type.""" +def _flatten_nested_list(obj: list, depth: int) -> tuple[list, tuple[int, ...]]: + """Flatten a nested list and compute the shape""" +def _infer_shape(obj: list, depth: int) -> tuple[int, ...]: ... +def _flatten(obj: list, out: list, offset: int) -> int: ... +def _prepare_array_metadata(iface: dict) -> tuple[int, int, tuple[int, ...], tuple[int, ...] | None, DataType]: + """ + Parse and validate a CUDA or NumPy array interface dictionary. + + Parameters + ---------- + iface : dict + A dictionary conforming to the __cuda_array_interface__ + or __array_interface__ spec. + + Returns + ------- + tuple + - data pointer (int) + - total number of bytes (int) + - shape (tuple[int, ...]) + - strides (tuple[int, ...] | None) + - data type (pylibcudf.DataType) + + Raises + ------ + ValueError + If the interface is invalid, big-endian, non-contiguous, + or exceed the size_type limit. + """ +def is_c_contiguous(shape: ..., strides: ..., itemsize: int) -> bool: + """Determine if shape and strides are C-contiguous + + Parameters + ---------- + shape : Sequence[int] + Number of elements in each dimension. + strides : None | Sequence[int] + The stride of each dimension in bytes. + If None, the memory layout is C-contiguous. + itemsize : int + Size of an element in bytes. + + Returns + ------- + bool + The boolean answer. + """ diff --git a/python/pylibcudf/pylibcudf/column_factories.pyi b/python/pylibcudf/pylibcudf/column_factories.pyi index a9e92c5f8238..eeb5320225b9 100644 --- a/python/pylibcudf/pylibcudf/column_factories.pyi +++ b/python/pylibcudf/pylibcudf/column_factories.pyi @@ -1,53 +1,52 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 + +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/column_factories.pyx + from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.types import DataType, MaskState, TypeId -from pylibcudf.utils import CudaStreamLike - -def make_numeric_column( - type_: DataType, - size: int, - mstate: MaskState, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def make_fixed_point_column( - type_: DataType, - size: int, - mstate: MaskState, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def make_timestamp_column( - type_: DataType, - size: int, - mstate: MaskState, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def make_duration_column( - type_: DataType, - size: int, - mstate: MaskState, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def make_fixed_width_column( - type_: DataType, - size: int, - mstate: MaskState, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def make_empty_column( - type_or_id: DataType | TypeId, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def make_empty_lists_column( - child_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column +from .types import DataType, size_type + +__all__ = ['make_duration_column', 'make_empty_column', 'make_fixed_point_column', 'make_fixed_width_column', 'make_numeric_column', 'make_timestamp_column', 'make_empty_lists_column'] + +def make_empty_column(type_or_id: object, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Creates an empty column of the specified type. + + For details, see :cpp:func:`make_empty_column`. + + Parameters + ---------- + type_or_id : Union[DataType, type_id, object] + The column data type. + + Returns + ------- + Column + An empty Column + """ +def make_numeric_column(type_: DataType, size: size_type, mstate: object, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Creates an empty numeric column. + + For details, see :cpp:func:`make_numeric_column`. + + """ +def make_fixed_point_column(type_: DataType, size: size_type, mstate: object, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: ... +def make_timestamp_column(type_: DataType, size: size_type, mstate: object, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: ... +def make_duration_column(type_: DataType, size: size_type, mstate: object, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: ... +def make_fixed_width_column(type_: DataType, size: size_type, mstate: object, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: ... +def make_empty_lists_column(child_type: DataType, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Creates an empty column of the specified type. + + For details, see :cpp:func:`make_empty_lists_column`. + + Parameters + ---------- + child_type : DataType + The child column data type for the list column. + + Returns + ------- + Column + An empty Column + """ diff --git a/python/pylibcudf/pylibcudf/concatenate.pyi b/python/pylibcudf/pylibcudf/concatenate.pyi index 8a6b0cfbc39b..3081e9b3cd4d 100644 --- a/python/pylibcudf/pylibcudf/concatenate.pyi +++ b/python/pylibcudf/pylibcudf/concatenate.pyi @@ -1,16 +1,26 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Sequence +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/concatenate.pyx from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike +__all__ = ['concatenate'] -def concatenate[ColumnOrTable: (Column, Table)]( - objects: Sequence[ColumnOrTable], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> ColumnOrTable: ... +def concatenate(objects, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Concatenate columns or tables. + + Parameters + ---------- + objects : Sequence[Column] | Sequence[Table] + The Columns or Tables to concatenate. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned object's device memory. + + Returns + ------- + Union[Column, Table] + The concatenated Column or Table. + """ diff --git a/python/pylibcudf/pylibcudf/context.pyi b/python/pylibcudf/pylibcudf/context.pyi index 515e5eeb79ac..6b17e7ded054 100644 --- a/python/pylibcudf/pylibcudf/context.pyi +++ b/python/pylibcudf/pylibcudf/context.pyi @@ -1,5 +1,23 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -def enable_jit_cache(enable: bool) -> None: ... -def clear_jit_cache() -> None: ... +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/context.pyx + +__all__ = ['clear_jit_cache', 'enable_jit_cache'] + +def enable_jit_cache(enable: bool): + """Enable or disable the JIT program cache. + + When disabled, the cache will not be used for storing or retrieving + compiled programs. When enabled, the cache will be used as normal. + + Parameters + ---------- + enable : bool + If ``True``, the JIT program cache is enabled; if ``False``, it is + disabled. + """ +def clear_jit_cache(): + """Clear the JIT program cache, removing all cached programs from memory + and disk. + """ diff --git a/python/pylibcudf/pylibcudf/contiguous_split.pyi b/python/pylibcudf/pylibcudf/contiguous_split.pyi index 6e0e653b5bbf..398d8cf9836c 100644 --- a/python/pylibcudf/pylibcudf/contiguous_split.pyi +++ b/python/pylibcudf/pylibcudf/contiguous_split.pyi @@ -1,46 +1,214 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.mr import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/contiguous_split.pyx -from pylibcudf.gpumemoryview import gpumemoryview -from pylibcudf.span import Span -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +from .table import Table + +__all__ = ['ChunkedPack', 'PackedColumns', 'pack', 'unpack', 'unpack_from_memoryviews'] + +class HostBuffer: + """Owning host buffer that implements the buffer protocol""" + __hash__ = None + + def __getbuffer__(self, buffer: ..., flags: int): ... + def __releasebuffer__(self, buffer: ...): ... class PackedColumns: + """Column data in a serialized format. + + Contains data from an array of columns in two contiguous buffers: + one on host, which contains table metadata and one on device which + contains the table data. + + For details, see :cpp:class:`cudf::packed_columns`. + """ + __hash__ = None + def __init__(self): ... - def release( - self, stream: CudaStreamLike | None = None - ) -> tuple[memoryview[bytes], gpumemoryview]: ... - -def pack( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> PackedColumns: ... -def unpack( - input: PackedColumns, stream: CudaStreamLike | None = None -) -> Table: ... -def unpack_from_memoryviews( - metadata: memoryview[bytes], - gpu_data: Span, - stream: CudaStreamLike | None = None, -) -> Table: ... + def release(self) -> tuple: + """Releases and returns the underlying serialized metadata and gpu data. + + The ownership of the memory are transferred to the returned buffers. After + this call, `self` is empty. + + Returns + ------- + memoryview (of a HostBuffer) + The serialized metadata as contiguous host memory. + gpumemoryview (of a rmm.DeviceBuffer) + The serialized gpu data as contiguous device memory. + """ class ChunkedPack: + """ + A chunked version of :func:`pack`. + + This object can be used to pack (and therefore serialize) a table + piece-by-piece through a user-provided staging buffer. This is + useful when we want the end result to end up in host memory, but + want control over the memory footprint. + """ def __init__(self): ... @staticmethod - def create( - input: Table, - user_buffer_size: int, - stream: CudaStreamLike | None = None, - temp_mr: DeviceMemoryResource | None = None, - ) -> ChunkedPack: ... - def has_next(self) -> bool: ... - def get_total_contiguous_size(self) -> int: ... - def next(self, buf: Span) -> int: ... - def build_metadata(self) -> memoryview[bytes]: ... - def pack_to_host( - self, buf: Span - ) -> tuple[memoryview[bytes], memoryview[bytes]]: ... + def create(input: Table, user_buffer_size: int, stream: object | None=None, temp_mr: DeviceMemoryResource | None=None): + """ + Create a chunked packer. + + Parameters + ---------- + input + The table to pack. + user_buffer_size + Size of the staging buffer to pack into, must be at least 1MB. + stream : Stream | None + Stream used for device memory operations and kernel launches. + temp_mr : DeviceMemoryResource | None + Memory resource for scratch allocations. + + Returns + ------- + New ChunkedPack object. + """ + def has_next(self) -> bool: + """ + Check if the packer has more chunks to pack. + + Returns + ------- + True if the packer has chunks still to pack. + """ + def get_total_contiguous_size(self) -> int: + """ + Get the total size of the packed data. + + Returns + ------- + Size of packed data. + """ + def next(self, buf: object) -> int: + """ + Pack the next chunk into the provided device buffer. + + Parameters + ---------- + buf : Span-like object + The device buffer to use as a staging buffer, must be at + least as large as the `user_buffer_size` used to construct the + packer. + + Returns + ------- + Number of bytes packed. + + Notes + ----- + This is stream-ordered with respect to the stream used when + creating the `ChunkedPack`. + """ + def build_metadata(self) -> memoryview: + """ + Build the metadata for the packed representation. + + Returns + ------- + memoryview of metadata suitable for passing to `unpack_from_memoryviews`. + """ + def pack_to_host(self, buf: object) -> tuple: + """ + Pack the entire table into a host buffer. + + Parameters + ---------- + buf : Span-like object + The device buffer to use as a staging buffer, must be at + least as large as the `user_buffer_size` used to construct the + packer. + + Returns + ------- + tuple of metadata and packed host data (as memoryviews) + + Notes + ----- + This is stream-ordered with respect to the stream used when + creating the `ChunkedPack` and syncs that stream before returning. + + Raises + ------ + RuntimeError + If the copy to host fails or an incorrectly sized buffer + is provided. + """ + +def pack(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> PackedColumns: + """Deep-copy a table into a serialized contiguous memory format. + + Later use `unpack` or `unpack_from_memoryviews` to unpack the serialized + data back into the table. + + Parameters + ---------- + input : Table + Table to pack. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + PackedColumns + The packed columns. + + Examples + -------- + >>> packed = pylibcudf.contiguous_split.pack(...) + >>> # Either unpack the whole `PackedColumns` at once. + >>> pylibcudf.contiguous_split.unpack(packed) + >>> # Or unpack the two serialized buffers in `PackedColumns`. + >>> metadata, gpu_data = packed.release() + >>> pylibcudf.contiguous_split.unpack_from_memoryviews(metadata, gpu_data) + + For details, see :cpp:func:`pack`. + """ +def unpack(input: PackedColumns, stream: object | None=None) -> Table: + """Deserialize the result of `pack`. + + Copies the result of a serialized table into a table. + + For details, see :cpp:func:`unpack`. + + Parameters + ---------- + input : PackedColumns + The packed columns to unpack. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + Copy of the packed columns. + """ +def unpack_from_memoryviews(metadata: memoryview, gpu_data: object, stream: object | None=None) -> Table: + """Deserialize the result of `pack`. + + Copies the result of a serialized table into a table. + + For details, see :cpp:func:`unpack`. + + Parameters + ---------- + metadata : memoryview + The packed metadata to unpack. + gpu_data : Span-like object + The packed gpu_data to unpack. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + Copy of the packed columns. + """ diff --git a/python/pylibcudf/pylibcudf/copying.pyi b/python/pylibcudf/pylibcudf/copying.pyi index bdff6cddad57..d1ed4cd597c2 100644 --- a/python/pylibcudf/pylibcudf/copying.pyi +++ b/python/pylibcudf/pylibcudf/copying.pyi @@ -1,104 +1,358 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/copying.pyx + from typing import TypeVar +from pylibcudf.libcudf.copying import mask_allocation_policy +from pylibcudf.libcudf.copying import \ + mask_allocation_policy as MaskAllocationPolicy +from pylibcudf.libcudf.copying import out_of_bounds_policy +from pylibcudf.libcudf.copying import out_of_bounds_policy as OutOfBoundsPolicy +from pylibcudf.libcudf.copying import \ + sample_with_replacement as SampleWithReplacement +from pylibcudf.libcudf.types import size_type from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.scalar import Scalar -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -class MaskAllocationPolicy(IntEnum): - NEVER = ... - RETAIN = ... - ALWAYS = ... - -class OutOfBoundsPolicy(IntEnum): - NULLIFY = ... - DONT_CHECK = ... - -ColumnOrTable = TypeVar("ColumnOrTable", Column, Table) - -def gather( - source_table: Table, - gather_map: Column, - bounds_policy: OutOfBoundsPolicy, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def scatter( - source: Table | list[Scalar], - scatter_map: Column, - target_table: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def empty_like( - input: ColumnOrTable, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> ColumnOrTable: ... -def allocate_like( - input_column: Column, - policy: MaskAllocationPolicy, - size: int | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def copy_range_in_place( - input_column: Column, - target_column: Column, - input_begin: int, - input_end: int, - target_begin: int, - stream: CudaStreamLike | None = None, -) -> Column: ... -def copy_range( - input_column: Column, - target_column: Column, - input_begin: int, - input_end: int, - target_begin: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def shift( - input: Column, - offset: int, - fill_value: Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def slice( - input: ColumnOrTable, - indices: list[int], - stream: CudaStreamLike | None = None, -) -> list[ColumnOrTable]: ... -def split( - input: ColumnOrTable, - splits: list[int], - stream: CudaStreamLike | None = None, -) -> list[ColumnOrTable]: ... -def copy_if_else( - lhs: Column | Scalar, - rhs: Column | Scalar, - boolean_mask: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def boolean_mask_scatter( - input: Table | list[Scalar], - target: Table, - boolean_mask: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def get_element( - input_column: Column, - index: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Scalar: ... +from .column import Column +from .scalar import Scalar +from .table import Table + +ColumnOrTable = TypeVar('ColumnOrTable', Table, Column) +__all__ = ['MaskAllocationPolicy', 'OutOfBoundsPolicy', 'SampleWithReplacement', 'allocate_like', 'boolean_mask_scatter', 'copy_if_else', 'copy_range', 'copy_range_in_place', 'empty_like', 'gather', 'get_element', 'scatter', 'shift', 'slice', 'split'] + +def gather(source_table: Table, gather_map: Column, bounds_policy: out_of_bounds_policy, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Select rows from source_table according to the provided gather_map. + + For details, see :cpp:func:`gather`. + + Parameters + ---------- + source_table : Table + The table object from which to pull data. + gather_map : Column + The list of row indices to pull out of the source table. + bounds_policy : out_of_bounds_policy + Controls whether out of bounds indices are checked and nullified in the + output or if indices are assumed to be in bounds. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Table + The result of the gather + + Raises + ------ + ValueError + If the gather_map contains nulls. + """ +def scatter(source: Table | list, scatter_map: Column, target_table: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Scatter from source into target_table according to scatter_map. + + If source is a table, it specifies rows to scatter. If source is a list, + each scalar is scattered into the corresponding column in the ``target_table``. + + For details, see :cpp:func:`scatter`. + + Parameters + ---------- + source : Union[Table, List[Scalar]] + The table object or list of scalars from which to pull data. + scatter_map : Column + A mapping from rows in source to rows in target_table. + target_table : Table + The table object into which to scatter data. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + The result of the scatter + + Raises + ------ + ValueError + If any of the following occur: + - scatter_map contains null values. + - source is a Table and the number of columns in source does not match the + number of columns in target. + - source is a Table and the number of rows in source does not match the + number of elements in scatter_map. + - source is a List[Scalar] and the number of scalars does not match the + number of columns in target. + TypeError + If data types of the source and target columns do not match. + """ +def empty_like(input: ColumnOrTable, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> ColumnOrTable: + """Create an empty column or table with the same type as ``input``. + + For details, see :cpp:func:`empty_like`. + + Parameters + ---------- + input : Union[Column, Table] + The column or table to use as a template for the output. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Union[Column, Table] + An empty column or table with the same type(s) as ``input``. + """ +def allocate_like(input_column: Column, policy: mask_allocation_policy, size=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Allocate a column with the same type as input_column. + + For details, see :cpp:func:`allocate_like`. + + Parameters + ---------- + input_column : Column + The column to use as a template for the output. + policy : mask_allocation_policy + Controls whether the output column has a valid mask. + size : int, optional + The number of elements to allocate in the output column. If not + specified, the size of the input column is used. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A column with the same type and size as input. + """ +def copy_range_in_place(input_column: Column, target_column: Column, input_begin: size_type, input_end: size_type, target_begin: size_type, stream: object | None=None) -> Column: + """Copy a range of elements from input_column to target_column. + + The target_column is overwritten in place. + + For details on the implementation, see :cpp:func:`copy_range_in_place`. + + Parameters + ---------- + input_column : Column + The column from which to copy elements. + target_column : Column + The column into which to copy elements. + input_begin : int + The index of the first element in input_column to copy. + input_end : int + The index of the last element in input_column to copy. + target_begin : int + The index of the first element in target_column to overwrite. + stream : Stream | None + CUDA stream on which to perform the operation. + + Raises + ------ + TypeError + If the operation is attempted on non-fixed width types since those would require + memory reallocations, or if the input and target columns have different types. + IndexError + If the indices accessed by the ranges implied by input_begin, input_end, and + target_begin are out of bounds. + ValueError + If source has null values and target is not nullable. + """ +def copy_range(input_column: Column, target_column: Column, input_begin: size_type, input_end: size_type, target_begin: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Copy a range of elements from input_column to target_column. + + For details on the implementation, see :cpp:func:`copy_range`. + + Parameters + ---------- + input_column : Column + The column from which to copy elements. + target_column : Column + The column into which to copy elements. + input_begin : int + The index of the first element in input_column to copy. + input_end : int + The index of the last element in input_column to copy. + target_begin : int + The index of the first element in target_column to overwrite. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A copy of target_column with the specified range overwritten. + + Raises + ------ + IndexError + If the indices accessed by the ranges implied by input_begin, input_end, and + target_begin are out of bounds. + TypeError + If target and source have different types. + """ +def shift(input: Column, offset: size_type, fill_value: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Shift the elements of input by offset. + + For details on the implementation, see :cpp:func:`shift`. + + Parameters + ---------- + input : Column + The column to shift. + offset : int + The number of elements to shift by. + fill_values : Scalar + The value to use for elements that are shifted in from outside the + bounds of the input column. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A copy of input shifted by offset. + + Raises + ------ + TypeError + If the fill_value is not of the same type as input, or if the input type is not + of fixed width or string type. + """ +def slice(input: Table | Column, indices: list, stream: object | None=None) -> list: + """Slice input according to indices. + + For details on the implementation, see :cpp:func:`slice`. + + Parameters + ---------- + input_column : Union[Column, Table] + The column or table to slice. + indices : List[int] + The indices to select from input. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + List[Union[Column, Table]] + The result of slicing ``input``. + + Raises + ------ + ValueError + If indices size is not even or the values in any pair of lower/upper bounds are + strictly decreasing. + IndexError + When any of the indices don't belong to the range ``[0, input_column.size())``. + """ +def split(input: Table | Column, splits: list, stream: object | None=None) -> list: + """Split input into multiple. + + For details on the implementation, see :cpp:func:`split`. + + Parameters + ---------- + input : Union[Column, Table] + The column to split. + splits : List[int] + The indices at which to split the column. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + List[Union[Column, Table]] + The result of splitting input. + """ +def copy_if_else(lhs: Column | Scalar, rhs: Column | Scalar, boolean_mask: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Copy elements from lhs or rhs into a new column according to boolean_mask. + + For details on the implementation, see :cpp:func:`copy_if_else`. + + Parameters + ---------- + lhs : Union[Column, Scalar] + The column or scalar to copy from if the corresponding element in + boolean_mask is True. + rhs : Union[Column, Scalar] + The column or scalar to copy from if the corresponding element in + boolean_mask is False. + boolean_mask : Column + The boolean mask to use to select elements from lhs and rhs. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + The result of copying elements from lhs and rhs according to boolean_mask. + + Raises + ------ + TypeError + If lhs and rhs are not of the same type or if the boolean mask is not of type + bool. + ValueError + If boolean mask is not of the same length as lhs and rhs (whichever are + columns), or if lhs and rhs are not of the same length (if both are columns). + """ +def boolean_mask_scatter(input: Table | list, target: Table, boolean_mask: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Scatter rows from input into target according to boolean_mask. + + If source is a table, it specifies rows to scatter. If source is a list, + each scalar is scattered into the corresponding column in the ``target_table``. + + For details on the implementation, see :cpp:func:`boolean_mask_scatter`. + + Parameters + ---------- + input : Union[Table, List[Scalar]] + The table object from which to pull data. + target : Table + The table object into which to scatter data. + boolean_mask : Column + A mapping from rows in input to rows in target. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + The result of the scatter + + Raises + ------ + ValueError + If input.num_columns() != target.num_columns(), boolean_mask.size() != + target.num_rows(), or if input is a Table and the number of `true` in + `boolean_mask` > input.num_rows(). + TypeError + If any input type does not match the corresponding target column's type, or + if boolean_mask.type() is not bool. + """ +def get_element(input_column: Column, index: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Scalar: + """Get the element at index from input_column. + + For details on the implementation, see :cpp:func:`get_element`. + + Parameters + ---------- + input_column : Column + The column from which to get the element. + index : int + The index of the element to get. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Scalar + The element at index from input_column. + + Raises + ------ + IndexError + If index is out of bounds. + """ diff --git a/python/pylibcudf/pylibcudf/datetime.pyi b/python/pylibcudf/pylibcudf/datetime.pyi index e671d2d18cfa..76a5afff166b 100644 --- a/python/pylibcudf/pylibcudf/datetime.pyi +++ b/python/pylibcudf/pylibcudf/datetime.pyi @@ -1,87 +1,212 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum - -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/datetime.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.datetime import datetime_component +from pylibcudf.libcudf.datetime import datetime_component as DatetimeComponent +from pylibcudf.libcudf.datetime import rounding_frequency +from pylibcudf.libcudf.datetime import rounding_frequency as RoundingFrequency from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -class DatetimeComponent(IntEnum): - YEAR = ... - MONTH = ... - DAY = ... - WEEKDAY = ... - HOUR = ... - MINUTE = ... - SECOND = ... - MILLISECOND = ... - MICROSECOND = ... - NANOSECOND = ... - -class RoundingFrequency(IntEnum): - DAY = ... - HOUR = ... - MINUTE = ... - SECOND = ... - MILLISECOND = ... - MICROSECOND = ... - NANOSECOND = ... - -def extract_datetime_component( - input: Column, - component: DatetimeComponent, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def ceil_datetimes( - input: Column, - freq: RoundingFrequency, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def floor_datetimes( - input: Column, - freq: RoundingFrequency, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def round_datetimes( - input: Column, - freq: RoundingFrequency, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def add_calendrical_months( - input: Column, - months: Column | Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def day_of_year( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_leap_year( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def last_day_of_month( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def extract_quarter( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def days_in_month( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['DatetimeComponent', 'RoundingFrequency', 'add_calendrical_months', 'ceil_datetimes', 'day_of_year', 'days_in_month', 'extract_datetime_component', 'extract_quarter', 'floor_datetimes', 'is_leap_year', 'last_day_of_month', 'round_datetimes'] + +def extract_datetime_component(input: Column, component: datetime_component, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Extract a datetime component from a datetime column. + + For details, see :cpp:func:`extract_datetime_component`. + + Parameters + ---------- + input : Column + The column to extract the component from. + component : DatetimeComponent + The datetime component to extract. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column with the extracted component. + """ +def ceil_datetimes(input: Column, freq: rounding_frequency, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Round datetimes up to the nearest multiple of the given frequency. + + For details, see :cpp:func:`ceil_datetimes`. + + Parameters + ---------- + input : Column + The column of input datetime values. + freq : rounding_frequency + The frequency to round up to. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of the same datetime resolution as the input column. + """ +def floor_datetimes(input: Column, freq: rounding_frequency, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Round datetimes down to the nearest multiple of the given frequency. + + For details, see :cpp:func:`floor_datetimes`. + + Parameters + ---------- + input : Column + The column of input datetime values. + freq : rounding_frequency + The frequency to round down to. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of the same datetime resolution as the input column. + """ +def round_datetimes(input: Column, freq: rounding_frequency, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Round datetimes to the nearest multiple of the given frequency. + + For details, see :cpp:func:`round_datetimes`. + + Parameters + ---------- + input : Column + The column of input datetime values. + freq : rounding_frequency + The frequency to round to. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of the same datetime resolution as the input column. + """ +def add_calendrical_months(input: Column, months: Column | Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Adds or subtracts a number of months from the datetime + type and returns a timestamp column that is of the same + type as the input timestamps column. + + For details, see :cpp:func:`add_calendrical_months`. + + Parameters + ---------- + input : Column + The column of input timestamp values. + months : ColumnOrScalar + The number of months to add. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of computed timestamps. + """ +def day_of_year(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Computes the day number since the start of + the year from the datetime. The value is between + [1, {365-366}]. + + For details, see :cpp:func:`day_of_year`. + + Parameters + ---------- + input : Column + The column of input datetime values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of day numbers. + """ +def is_leap_year(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Check if the year of the given date is a leap year. + + For details, see :cpp:func:`is_leap_year`. + + Parameters + ---------- + input : Column + The column of input datetime values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of bools indicating whether the given year + is a leap year. + """ +def last_day_of_month(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Computes the last day of the month. + + For details, see :cpp:func:`last_day_of_month`. + + Parameters + ---------- + input : Column + The column of input datetime values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of ``TIMESTAMP_DAYS`` representing the last day + of the month. + """ +def extract_quarter(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the quarter (ie. a value from {1, 2, 3, 4}) + that the date is in. + + For details, see :cpp:func:`extract_quarter`. + + Parameters + ---------- + input : Column + The column of input datetime values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column indicating which quarter the date is in. + """ +def days_in_month(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Extract the number of days in the month. + + For details, see :cpp:func:`days_in_month`. + + Parameters + ---------- + input : Column + The column of input datetime values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of the number of days in the given month. + """ diff --git a/python/pylibcudf/pylibcudf/experimental/_join_streams.pyi b/python/pylibcudf/pylibcudf/experimental/_join_streams.pyi index c9c2ba79e364..f507d8c5994f 100644 --- a/python/pylibcudf/pylibcudf/experimental/_join_streams.pyi +++ b/python/pylibcudf/pylibcudf/experimental/_join_streams.pyi @@ -1,8 +1,34 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from pylibcudf.utils import CudaStreamLike +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/experimental/_join_streams.pyx -def join_streams( - streams: list[CudaStreamLike], stream: CudaStreamLike -) -> None: ... +__all__ = ['join_streams'] + +def join_streams(streams: list, stream: object) -> None: + """Synchronize a stream to an event on a set of streams. + + This function synchronizes the joined stream with the waited-on streams + by placing events on each of the waited-on streams and having the joined + stream wait on those events. + + Parameters + ---------- + streams : list + A list of Stream objects to wait on. + stream : Stream + The joined stream that synchronizes with the waited-on streams. + + Examples + -------- + >>> import pylibcudf as plc + >>> from rmm.pylibrmm.stream import Stream + >>> # Create streams + >>> stream1 = Stream() + >>> stream2 = Stream() + >>> join_stream = Stream() + >>> # ... do work on stream1 and stream2 ... + >>> # Wait for both streams before continuing work on join_stream + >>> plc.experimental.join_streams([stream1, stream2], join_stream) + >>> # ... continue work on join_stream ... + """ diff --git a/python/pylibcudf/pylibcudf/expressions.pyi b/python/pylibcudf/pylibcudf/expressions.pyi index 6a7d1b689fb9..e8f89c3ed85e 100644 --- a/python/pylibcudf/pylibcudf/expressions.pyi +++ b/python/pylibcudf/pylibcudf/expressions.pyi @@ -1,82 +1,142 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum - -from pylibcudf.scalar import Scalar - -class TableReference(IntEnum): - LEFT = ... - RIGHT = ... - -class ASTOperator(IntEnum): - ADD = ... - SUB = ... - MUL = ... - DIV = ... - TRUE_DIV = ... - FLOOR_DIV = ... - MOD = ... - PYMOD = ... - POW = ... - EQUAL = ... - NULL_EQUAL = ... - NOT_EQUAL = ... - LESS = ... - GREATER = ... - LESS_EQUAL = ... - GREATER_EQUAL = ... - BITWISE_AND = ... - BITWISE_OR = ... - BITWISE_XOR = ... - NULL_LOGICAL_AND = ... - LOGICAL_AND = ... - NULL_LOGICAL_OR = ... - LOGICAL_OR = ... - IDENTITY = ... - IS_NULL = ... - SIN = ... - COS = ... - TAN = ... - ARCSIN = ... - ARCCOS = ... - ARCTAN = ... - SINH = ... - COSH = ... - TANH = ... - ARCSINH = ... - ARCCOSH = ... - ARCTANH = ... - EXP = ... - LOG = ... - SQRT = ... - CBRT = ... - CEIL = ... - FLOOR = ... - ABS = ... - RINT = ... - BIT_INVERT = ... - NOT = ... + +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/expressions.pyx + +import ast +import functools +from typing import TypeAlias + +from pylibcudf.libcudf.expressions import ast_operator +from pylibcudf.libcudf.expressions import ast_operator as ASTOperator +from pylibcudf.libcudf.expressions import table_reference +from pylibcudf.libcudf.expressions import table_reference as TableReference +from pylibcudf.libcudf.types import size_type + +from .scalar import Scalar + +expression_ptr: TypeAlias = ... +__all__ = ['ASTOperator', 'ColumnNameReference', 'ColumnReference', 'Expression', 'Literal', 'Operation', 'TableReference', 'to_expression'] +_python_cudf_operator_map = {ast.Add: ASTOperator.ADD, ast.Sub: ASTOperator.SUB, ast.Mult: ASTOperator.MUL, ast.Div: ASTOperator.DIV, ast.FloorDiv: ASTOperator.FLOOR_DIV, ast.Mod: ASTOperator.PYMOD, ast.Pow: ASTOperator.POW, ast.Eq: ASTOperator.EQUAL, ast.NotEq: ASTOperator.NOT_EQUAL, ast.Lt: ASTOperator.LESS, ast.Gt: ASTOperator.GREATER, ast.LtE: ASTOperator.LESS_EQUAL, ast.GtE: ASTOperator.GREATER_EQUAL, ast.BitXor: ASTOperator.BITWISE_XOR, ast.BitAnd: ASTOperator.BITWISE_AND, ast.BitOr: ASTOperator.BITWISE_OR, ast.And: ASTOperator.LOGICAL_AND, ast.Or: ASTOperator.LOGICAL_OR, ast.Invert: ASTOperator.BIT_INVERT, ast.Not: ASTOperator.NOT} +_python_cudf_function_map = {'isnull': ASTOperator.IS_NULL, 'isna': ASTOperator.IS_NULL, 'sin': ASTOperator.SIN, 'cos': ASTOperator.COS, 'tan': ASTOperator.TAN, 'arcsin': ASTOperator.ARCSIN, 'arccos': ASTOperator.ARCCOS, 'arctan': ASTOperator.ARCTAN, 'sinh': ASTOperator.SINH, 'cosh': ASTOperator.COSH, 'tanh': ASTOperator.TANH, 'arcsinh': ASTOperator.ARCSINH, 'arccosh': ASTOperator.ARCCOSH, 'arctanh': ASTOperator.ARCTANH, 'exp': ASTOperator.EXP, 'log': ASTOperator.LOG, 'sqrt': ASTOperator.SQRT, 'abs': ASTOperator.ABS, 'ceil': ASTOperator.CEIL, 'floor': ASTOperator.FLOOR} class Expression: - def __init__(self): ... + """ + The base class for all expression types. + This class cannot be instantiated directly, please + instantiate one of its child classes instead. + + For details, see :cpp:class:`cudf::ast::expression`. + """ + __hash__ = None class Literal(Expression): + """ + A literal value used in an abstract syntax tree. + + For details, see :cpp:class:`cudf::ast::literal`. + + Parameters + ---------- + value : Scalar + The Scalar value of the Literal. + Must be either numeric, string, or a timestamp/duration scalar. + """ def __init__(self, value: Scalar): ... class ColumnReference(Expression): - def __init__( - self, index: int, table_source: TableReference = TableReference.LEFT - ): ... + """ + An expression referring to data from a column in a table. + + For details, see :cpp:class:`cudf::ast::column_reference`. + + Parameters + ---------- + index : size_type + The index of this column in the table + (provided when the expression is evaluated). + table_source : TableReference, default TableReferenece.LEFT + Which table to use in cases with two tables (e.g. joins) + """ + def __init__(self, index: size_type, table_source: table_reference=table_reference.LEFT): ... + +class Operation(Expression): + """ + An operation expression holds an operator and zero or more operands. + + For details, see :cpp:class:`cudf::ast::operation`. + + Parameters + ---------- + op : Operator + left : Expression + Left input expression (left operand) + right: Expression, default None + Right input expression (right operand). + You should only pass this if the input expression is a binary operation. + """ + def __init__(self, op: ast_operator, left: Expression, right: Expression | None=None): ... class ColumnNameReference(Expression): + """ + An expression referring to data from a column in a table. + + For details, see :cpp:class:`cudf::ast::column_name_reference`. + + Parameters + ---------- + column_name : str + Name of this column in the table metadata + (provided when the expression is evaluated). + """ def __init__(self, name: str): ... -class Operation(Expression): - def __init__( - self, - op: ASTOperator, - left: Expression, - right: Expression | None = None, - ): ... - -def to_expression(expr: str, column_names: tuple[str, ...]) -> Expression: ... +class ExpressionTransformer: + """A NodeVisitor specialized for constructing a libcudf expression tree. + + This visitor is designed to handle AST nodes that have libcudf equivalents. + It constructs column references from names and literals from constants, + then builds up operations. The resulting expression is returned by the + `visit` method + + Parameters + ---------- + column_mapping : dict[str, ColumnNameReference | ColumnReference] + Mapping from names to column references or column name references. + The former can be used for `compute_column` the latter in IO filters. + """ + def __init__(self, column_mapping: dict): ... + def generic_visit(self, node): ... + def visit_Module(self, node): ... + def visit_Expr(self, node): ... + def visit_Name(self, node): ... + def visit_Constant(self, node): ... + def visit_UnaryOp(self, node): ... + def visit_BinOp(self, node): ... + def visit_BoolOp(self, node): ... + def visit_Compare(self, node): ... + def visit_Call(self, node): ... + +@functools.lru_cache(256) +def to_expression(expr: str, column_names: tuple): + """ + Create an expression for `pylibcudf.transform.compute_column`. + + Parameters + ---------- + expr : str + The expression to evaluate. In (restricted) Python syntax. + column_names : tuple[str] + Ordered tuple of names. When calling `compute_column` on the resulting + expression, the provided table must have columns in the same order + as given here. + + Notes + ----- + This function keeps a small cache of recently used expressions. + + Returns + ------- + Expression + Expression for the given expr and col_names + """ diff --git a/python/pylibcudf/pylibcudf/filling.pyi b/python/pylibcudf/pylibcudf/filling.pyi index 2789ecd5aca4..7a1b24725cf5 100644 --- a/python/pylibcudf/pylibcudf/filling.pyi +++ b/python/pylibcudf/pylibcudf/filling.pyi @@ -1,33 +1,128 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from pylibcudf.column import Column -from pylibcudf.scalar import Scalar -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -def fill( - destination: Column, - begin: int, - end: int, - value: Scalar, - stream: CudaStreamLike | None = None, -) -> Column: ... -def fill_in_place( - destination: Column, - begin: int, - end: int, - value: Scalar, - stream: CudaStreamLike | None = None, -) -> None: ... -def sequence( - size: int, init: Scalar, step: Scalar, stream: CudaStreamLike | None = None -) -> Column: ... -def repeat( - input_table: Table, - count: Column | int, - stream: CudaStreamLike | None = None, -) -> Table: ... -def calendrical_month_sequence( - n: int, init: Scalar, months: int, stream: CudaStreamLike | None = None -) -> Column: ... +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/filling.pyx + +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +from .column import Column +from .scalar import Scalar +from .table import Table + +__all__ = ['fill', 'fill_in_place', 'repeat', 'sequence', 'calendrical_month_sequence'] + +def fill(destination: Column, begin: size_type, end: size_type, value: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Fill destination column from begin to end with value. + + For details, see :cpp:func:`fill`. + + Parameters + ---------- + destination : Column + The column to be filled + begin : size_type + The index to begin filling from. + end : size_type + The index at which to stop filling. + value : Scalar + The value to fill with. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + The result of the filling operation + """ +def fill_in_place(destination: Column, begin: size_type, end: size_type, value: Scalar, stream: object | None=None) -> None: + """Fill destination column in place from begin to end with value. + + For details, see :cpp:func:`fill_in_place`. + + Parameters + ---------- + destination : Column + The column to be filled + begin : size_type + The index to begin filling from. + end : size_type + The index at which to stop filling. + value : Scalar + The value to fill with. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + None + """ +def sequence(size: size_type, init: Scalar, step: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a sequence column of size ``size`` with initial value ``init`` and step + ``step``. + + For details, see :cpp:func:`sequence`. + + Parameters + ---------- + size : int + The size of the sequence + init : Scalar + The initial value of the sequence + step : Scalar + The step of the sequence + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + The result of the sequence operation + """ +def repeat(input_table: Table, count: Column | size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Repeat rows of a Table. + + If an integral value is specified for ``count``, every row is repeated ``count`` + times. If ``count`` is a column, the number of repetitions of each row is defined + by the value at the corresponding index of ``count``. + + For details, see :cpp:func:`repeat`. + + Parameters + ---------- + input_table : Table + The table to be repeated + count : Union[Column, size_type] + Integer value to repeat each row by or + non-nullable column of an integral type + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Table + The result of the repeat operation + """ +def calendrical_month_sequence(n: size_type, init: Scalar, months: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Fill destination column from begin to end with value. + + For details, see :cpp:func:`calendrical_month_sequence`. + + Parameters + ---------- + n : size_type + Number of timestamps to generate + init : Scalar + The initial timestamp + months : size_type + Months to increment + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + Timestamps column with sequences of months + """ diff --git a/python/pylibcudf/pylibcudf/gpumemoryview.pyi b/python/pylibcudf/pylibcudf/gpumemoryview.pyi index 81c9a4779839..84f44c2572d1 100644 --- a/python/pylibcudf/pylibcudf/gpumemoryview.pyi +++ b/python/pylibcudf/pylibcudf/gpumemoryview.pyi @@ -1,22 +1,59 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Mapping -from typing import Any +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/gpumemoryview.pyx + +import functools + +__all__ = ['gpumemoryview'] class gpumemoryview: - def __init__(self, data: Any): ... - @property - def __cuda_array_interface__(self) -> Mapping[str, Any]: ... - def __len__(self) -> int: ... - def byte_slice(self, s: slice) -> gpumemoryview: ... - @property - def ptr(self) -> int: ... - @property - def obj(self) -> Any: ... - @property - def cai(self) -> dict[str, Any]: ... + """Minimal representation of a memory buffer. + + This class aspires to be a GPU equivalent of :py:class:`memoryview` for any + objects exposing a `CUDA Array Interface + `__. + It will be expanded to encompass more memoryview functionality over time. + """ + __hash__ = None + ptr: int + obj: object + cai: dict + nbytes: int + + def __init__(self, obj: object): ... @property - def nbytes(self) -> int: ... + def __cuda_array_interface__(self): ... @property - def size(self) -> int: ... + def size(self) -> int: + """ + Size of the memory region in bytes (Span protocol). + + This is an alias for nbytes to satisfy the Span protocol. + """ + def __len__(self): ... + def byte_slice(self, s): + """Return a byte-range sub-view of this buffer. + + Parameters + ---------- + s : slice + Byte-based slice. + + Returns + ------- + gpumemoryview + A ``|u1`` view of the requested byte range. The returned view + holds a reference to the parent buffer, keeping it alive. + + Raises + ------ + TypeError + If ``s`` is not a slice. + ValueError + If the slice step is not 1. Out-of-range or reversed ranges + return a zero-length view rather than raising. + """ + +@functools.cache +def _datatype_from_dtype_desc(desc): ... diff --git a/python/pylibcudf/pylibcudf/groupby.pyi b/python/pylibcudf/pylibcudf/groupby.pyi index 01c732175f4d..d6d657b08ff5 100644 --- a/python/pylibcudf/pylibcudf/groupby.pyi +++ b/python/pylibcudf/pylibcudf/groupby.pyi @@ -1,60 +1,162 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/groupby.pyx + from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.aggregation import Aggregation -from pylibcudf.column import Column -from pylibcudf.replace import ReplacePolicy -from pylibcudf.scalar import Scalar -from pylibcudf.table import Table -from pylibcudf.types import NullOrder, NullPolicy, Order, Sorted -from pylibcudf.utils import CudaStreamLike +from .column import Column +from .table import Table +from .types import null_policy, sorted + +__all__ = ['GroupBy', 'GroupByRequest'] class GroupByRequest: - def __init__( - self, values: Column, aggregations: list[Aggregation] - ) -> None: ... + """A request for a groupby aggregation or scan. + + This class is functionally polymorphic and can represent either an + aggregation or a scan depending on the algorithm it is used with. For + details on the libcudf types it converts to, see + :cpp:class:`cudf::groupby::aggregation_request` and + :cpp:class:`cudf::groupby::scan_request`. + + Parameters + ---------- + values : Column + The column to aggregate. + aggregations : List[Aggregation] + The list of aggregations to perform. + """ + __hash__ = None + + def __init__(self, values: Column, aggregations: list): ... class GroupBy: - def __init__( - self, - keys: Table, - null_handling: NullPolicy = NullPolicy.EXCLUDE, - keys_are_sorted: Sorted = Sorted.NO, - column_order: list[Order] | None = None, - null_precedence: list[NullOrder] | None = None, - ) -> None: ... - def aggregate( - self, - requests: list[GroupByRequest], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> tuple[Table, list[Table]]: ... - def scan( - self, - requests: list[GroupByRequest], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> tuple[Table, list[Table]]: ... - def shift( - self, - values: Table, - offset: list[int], - fill_values: list[Scalar], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> tuple[Table, Table]: ... - def replace_nulls( - self, - value: Table, - replace_policies: list[ReplacePolicy], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> tuple[Table, Table]: ... - def get_groups( - self, - values: Table | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> tuple[list[int], Table, Table]: ... + """Group values by keys and compute various aggregate quantities. + + For details, see :cpp:class:`cudf::groupby::groupby`. + + Parameters + ---------- + keys : Table + The columns to group by. + null_handling : null_policy, optional + Whether or not to include null rows in `keys`. + Default is ``null_policy.EXCLUDE``. + keys_are_sorted : sorted, optional + Whether the keys are already sorted. Default is ``sorted.NO``. + column_order : list[order] + Indicates the order of each column. Default is ``order.ASCENDING``. + Ignored if `keys_are_sorted` is ``sorted.NO``. + null_precedence : list[null_order] + Indicates the ordering of null values in each column. + Default is ``null_order.AFTER``. Ignored if `keys_are_sorted` is ``sorted.NO``. + """ + __hash__ = None + + def __init__(self, keys: Table, null_handling: null_policy=null_policy.EXCLUDE, keys_are_sorted: sorted=sorted.NO, column_order: list | None=None, null_precedence: list | None=None): ... + def aggregate(self, requests: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Compute aggregations on columns. + + For details, see :cpp:func:`cudf::groupby::groupby::aggregate`. + + Parameters + ---------- + requests : List[GroupByRequest] + The list of `~.pylibcudf.groupby.GroupByRequest` , each + representing a set of aggregations to perform on a given column of values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Tuple[Table, List[Table, ...]] + A tuple whose first element is the unique keys and whose second + element is a table of aggregation results. One table is returned + for each aggregation request, with the columns corresponding to the + sequence of aggregations in the request. + """ + def scan(self, requests: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Compute scans on columns. + + For details, see :cpp:func:`cudf::groupby::groupby::scan`. + + Parameters + ---------- + requests : List[GroupByRequest] + The list of `~.pylibcudf.groupby.GroupByRequest` , each + representing a set of aggregations to perform on a given column of values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Tuple[Table, List[Table, ...]] + A tuple whose first element is the unique keys and whose second + element is a table of aggregation results. One table is returned + for each aggregation request, with the columns corresponding to the + sequence of aggregations in the request. + """ + def shift(self, values: Table, offset: list, fill_values: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Compute shifts on columns. + + For details, see :cpp:func:`cudf::groupby::groupby::shift`. + + Parameters + ---------- + values : Table + The columns to shift. + offset : List[int] + The offsets to shift by. + fill_values : List[Scalar] + The values to use to fill in missing values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Tuple[Table, Table] + A tuple whose first element is the group's keys and whose second + element is a table of shifted values. + """ + def replace_nulls(self, value: Table, replace_policies: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Replace nulls in columns. + + For details, see :cpp:func:`cudf::groupby::groupby::replace_nulls`. + + Parameters + ---------- + values : Table + The columns to replace nulls in. + replace_policies : List[replace_policy] + The policies to use to replace nulls. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Tuple[Table, Table] + A tuple whose first element is the group's keys and whose second + element is a table of values with nulls replaced. + """ + def get_groups(self, values: Table | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Get the grouped keys and values labels for each row. + + For details, see :cpp:func:`cudf::groupby::groupby::get_groups`. + + Parameters + ---------- + values : Table, optional + The columns to get group labels for. If not specified, + `None` is returned for the group values. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Tuple[List[int], Table, Table] + A tuple of tables containing three items: + - A list of integer offsets into the group keys/values + - A table of group keys + - A table of group values or None + """ diff --git a/python/pylibcudf/pylibcudf/hashing.pyi b/python/pylibcudf/pylibcudf/hashing.pyi index dae03796b9cc..739f5e4416ef 100644 --- a/python/pylibcudf/pylibcudf/hashing.pyi +++ b/python/pylibcudf/pylibcudf/hashing.pyi @@ -1,67 +1,185 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from typing import Final +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/hashing.pyx +from pylibcudf.libcudf.hash import DEFAULT_HASH_SEED from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -LIBCUDF_DEFAULT_HASH_SEED: Final[int] - -def murmurhash3_x86_32( - input: Table, - seed: int = ..., - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def murmurhash3_x64_128( - input: Table, - seed: int = ..., - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def xxhash_32( - input: Table, - seed: int = ..., - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def xxhash_64( - input: Table, - seed: int = ..., - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def md5( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def sha1( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def sha224( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def sha256( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def sha384( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def sha512( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column +from .table import Table + +__all__ = ['LIBCUDF_DEFAULT_HASH_SEED', 'md5', 'murmurhash3_x64_128', 'murmurhash3_x86_32', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'xxhash_32', 'xxhash_64'] +LIBCUDF_DEFAULT_HASH_SEED = DEFAULT_HASH_SEED + +def murmurhash3_x86_32(input: Table, seed: int=DEFAULT_HASH_SEED, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the MurmurHash3 32-bit hash value of each row in the given table. + + For details, see :cpp:func:`murmurhash3_x86_32`. + + Parameters + ---------- + input : Table + The table of columns to hash + seed : uint32_t + Optional seed value to use for the hash function + + Returns + ------- + pylibcudf.Column + A column where each row is the hash of a row from the input + """ +def murmurhash3_x64_128(input: Table, seed: int=DEFAULT_HASH_SEED, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Computes the MurmurHash3 64-bit hash value of each row in the given table. + + For details, see :cpp:func:`murmurhash3_x64_128`. + + Parameters + ---------- + input : Table + The table of columns to hash + seed : uint64_t + Optional seed value to use for the hash function + + Returns + ------- + pylibcudf.Table + A table of two UINT64 columns + """ +def xxhash_32(input: Table, seed: int=DEFAULT_HASH_SEED, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the xxHash 32-bit hash value of each row in the given table. + + For details, see :cpp:func:`xxhash_32`. + + Parameters + ---------- + input : Table + The table of columns to hash + seed : uint32_t + Optional seed value to use for the hash function + + Returns + ------- + pylibcudf.Column + A column where each row is the hash of a row from the input + """ +def xxhash_64(input: Table, seed: int=DEFAULT_HASH_SEED, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the xxHash 64-bit hash value of each row in the given table. + + For details, see :cpp:func:`xxhash_64`. + + Parameters + ---------- + input : Table + The table of columns to hash + seed : uint64_t + Optional seed value to use for the hash function + + Returns + ------- + pylibcudf.Column + A column where each row is the hash of a row from the input + """ +def md5(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the MD5 hash value of each row in the given table. + + For details, see :cpp:func:`md5`. + + Parameters + ---------- + input : Table + The table of columns to hash + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A column where each row is the md5 hash of a row from the input + + """ +def sha1(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the SHA-1 hash value of each row in the given table. + + For details, see :cpp:func:`sha1`. + + Parameters + ---------- + input : Table + The table of columns to hash + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A column where each row is the hash of a row from the input + """ +def sha224(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the SHA-224 hash value of each row in the given table. + + For details, see :cpp:func:`sha224`. + + Parameters + ---------- + input : Table + The table of columns to hash + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A column where each row is the hash of a row from the input + """ +def sha256(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the SHA-256 hash value of each row in the given table. + + For details, see :cpp:func:`sha256`. + + Parameters + ---------- + input : Table + The table of columns to hash + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A column where each row is the hash of a row from the input + """ +def sha384(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the SHA-384 hash value of each row in the given table. + + For details, see :cpp:func:`sha384`. + + Parameters + ---------- + input : Table + The table of columns to hash + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A column where each row is the hash of a row from the input + """ +def sha512(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the SHA-512 hash value of each row in the given table. + + For details, see :cpp:func:`sha512`. + + Parameters + ---------- + input : Table + The table of columns to hash + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + A column where each row is the hash of a row from the input + """ diff --git a/python/pylibcudf/pylibcudf/interop.pyi b/python/pylibcudf/pylibcudf/interop.pyi index 3e3666219f44..2edd8973acce 100644 --- a/python/pylibcudf/pylibcudf/interop.pyi +++ b/python/pylibcudf/pylibcudf/interop.pyi @@ -1,28 +1,53 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from dataclasses import dataclass -from typing import Any +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/interop.pyx +from pylibcudf.table import Table from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -@dataclass -class ColumnMetadata: - name: str = ... - timezone: str = ... - precision: int | None = ... - children_meta: list[ColumnMetadata] = ... - -def from_dlpack( - managed_tensor: Any, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def to_dlpack( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Any: ... +from ._interop_helpers import ColumnMetadata + +__all__ = ['ColumnMetadata', 'from_dlpack', 'to_dlpack'] + +def from_dlpack(managed_tensor: object, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Convert a DLPack DLTensor into a cudf table. + + For details, see :cpp:func:`from_dlpack` + + Parameters + ---------- + managed_tensor : PyCapsule + A 1D or 2D column-major (Fortran order) tensor. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + Table + Table with a copy of the tensor data. + """ +def to_dlpack(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> object: + """ + Convert a cudf table into a DLPack DLTensor. + + For details, see :cpp:func:`to_dlpack` + + Parameters + ---------- + input : Table + A 1D or 2D column-major (Fortran order) tensor. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned DLPack tensor's device + memory. + + Returns + ------- + PyCapsule + 1D or 2D DLPack tensor with a copy of the table data, or nullptr. + """ diff --git a/python/pylibcudf/pylibcudf/io/avro.pyi b/python/pylibcudf/pylibcudf/io/avro.pyi index 7e41c39a2bee..c6c803792a4d 100644 --- a/python/pylibcudf/pylibcudf/io/avro.pyi +++ b/python/pylibcudf/pylibcudf/io/avro.pyi @@ -1,26 +1,121 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/avro.pyx from pylibcudf.io.types import SourceInfo, TableWithMetadata -from pylibcudf.utils import CudaStreamLike +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource -__all__ = ["AvroReaderOptions", "AvroReaderOptionsBuilder", "read_avro"] +__all__ = ['read_avro', 'AvroReaderOptions', 'AvroReaderOptionsBuilder'] class AvroReaderOptions: - def set_columns(self, col_names: list[str]) -> None: ... - def set_source(self, src: SourceInfo) -> None: ... + """ + The settings to use for ``read_avro`` + For details, see :cpp:class:`cudf::io::avro_reader_options` + """ @staticmethod - def builder(source: SourceInfo) -> AvroReaderOptionsBuilder: ... + def builder(source: SourceInfo): + """ + Create a AvroWriterOptionsBuilder object + + For details, see :cpp:func:`cudf::io::avro_reader_options::builder` + + Parameters + ---------- + sink : SourceInfo + The source to read the Avro file from. + + Returns + ------- + AvroReaderOptionsBuilder + Builder to build AvroReaderOptions + """ + def set_columns(self, col_names: list) -> None: + """ + Set names of the column to be read. + + Parameters + ---------- + col_names : list[str] + List of column names + + Returns + ------- + None + """ + def set_source(self, src: SourceInfo) -> None: + """ + Set a new source info location. + + Parameters + ---------- + src : SourceInfo + New source information, replacing existing information. + + Returns + ------- + None + """ class AvroReaderOptionsBuilder: - def columns(self, col_names: list[str]) -> AvroReaderOptionsBuilder: ... - def skip_rows(self, skip_rows: int) -> AvroReaderOptionsBuilder: ... - def num_rows(self, num_rows: int) -> AvroReaderOptionsBuilder: ... - def build(self) -> AvroReaderOptions: ... - -def read_avro( - options: AvroReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> TableWithMetadata: ... + def columns(self, col_names: list) -> AvroReaderOptionsBuilder: + """ + Set names of the column to be read. + + Parameters + ---------- + col_names : list + List of column names + + Returns + ------- + AvroReaderOptionsBuilder + """ + def skip_rows(self, skip_rows: size_type) -> AvroReaderOptionsBuilder: + """ + Sets number of rows to skip. + + Parameters + ---------- + skip_rows : size_type + Number of rows to skip from start + + Returns + ------- + AvroReaderOptionsBuilder + """ + def num_rows(self, num_rows: size_type) -> AvroReaderOptionsBuilder: + """ + Sets number of rows to read. + + Parameters + ---------- + num_rows : size_type + Number of rows to read after skip + + Returns + ------- + AvroReaderOptionsBuilder + """ + def build(self) -> AvroReaderOptions: + """Create a AvroReaderOptions object""" + +def read_avro(options: AvroReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> TableWithMetadata: + """ + Read from Avro format. + + The source to read from and options are encapsulated + by the `options` object. + + For details, see :cpp:func:`read_avro`. + + Parameters + ---------- + options: AvroReaderOptions + Settings for controlling reading behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned table's device memory. + """ diff --git a/python/pylibcudf/pylibcudf/io/csv.pyi b/python/pylibcudf/pylibcudf/io/csv.pyi index 6c315bf7c625..abd9bbf43b89 100644 --- a/python/pylibcudf/pylibcudf/io/csv.pyi +++ b/python/pylibcudf/pylibcudf/io/csv.pyi @@ -1,89 +1,678 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from typing import Self +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/csv.pyx -from rmm.pylibrmm.memory_resource import DeviceMemoryResource - -from pylibcudf.io.types import ( - CompressionType, - QuoteStyle, - SinkInfo, - SourceInfo, - TableWithMetadata, -) +from pylibcudf.io.types import SinkInfo, SourceInfo, TableWithMetadata +from pylibcudf.libcudf.io.types import compression_type, quote_style +from pylibcudf.libcudf.types import size_type from pylibcudf.table import Table from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['read_csv', 'write_csv', 'CsvWriterOptions', 'CsvWriterOptionsBuilder', 'CsvReaderOptions', 'CsvReaderOptionsBuilder'] class CsvReaderOptions: - def __init__(self): ... - def set_header(self, header: int): ... - def set_names(self, col_names: list[str]): ... - def set_prefix(self, prefix: str): ... - def set_use_cols_indexes(self, col_indices: list[int]): ... - def set_use_cols_names(self, col_names: list[str]): ... - def set_delimiter(self, delimiter: str): ... - def set_thousands(self, thousands: str): ... - def set_comment(self, comment: str): ... - def set_parse_dates(self, val: list[int | str]): ... - def set_parse_hex(self, val: list[int | str]): ... - def set_dtypes(self, types: dict[str, DataType] | list[DataType]): ... - def set_true_values(self, true_values: list[str]): ... - def set_false_values(self, false_values: list[str]): ... - def set_na_values(self, na_values: list[str]): ... - def set_source(self, src: SourceInfo) -> None: ... + """The settings to use for ``read_csv`` + For details, see :cpp:class:`cudf::io::csv_reader_options` + """ @staticmethod - def builder(source: SourceInfo) -> CsvReaderOptionsBuilder: ... + def builder(source: SourceInfo): + """ + Create a CsvWriterOptionsBuilder object + + For details, see :cpp:func:`cudf::io::csv_reader_options::builder` + + Parameters + ---------- + sink : SourceInfo + The source to read the CSV file from. + + Returns + ------- + CsvReaderOptionsBuilder + Builder to build CsvReaderOptions + """ + def set_header(self, header: size_type) -> None: + """ + Sets header row index. + + Parameters + ---------- + header : size_type + Index where header row is located + + Returns + ------- + None + """ + def set_names(self, col_names: list) -> None: + """ + Sets names of the column. + + Parameters + ---------- + col_names : list[str] + List of column names + + Returns + ------- + None + """ + def set_prefix(self, prefix: str) -> None: + """ + Sets prefix to be used for column ID. + + Parameters + ---------- + prefix : str + String used as prefix in for each column name + + Returns + ------- + None + """ + def set_use_cols_indexes(self, col_indices: list) -> None: + """ + Sets indexes of columns to read. + + Parameters + ---------- + col_indices : list[int] + List of column indices that are needed + + Returns + ------- + None + """ + def set_use_cols_names(self, col_names: list) -> None: + """ + Sets names of the columns to be read. + + Parameters + ---------- + col_names : list[str] + List of column indices that are needed + + Returns + ------- + None + """ + def set_delimiter(self, delimiter: str) -> None: + """ + Sets field delimiter. + + Parameters + ---------- + delimiter : str + A character to indicate delimiter + + Returns + ------- + None + """ + def set_thousands(self, thousands: str) -> None: + """ + Sets numeric data thousands separator. + + Parameters + ---------- + thousands : str + A character that separates thousands + + Returns + ------- + None + """ + def set_comment(self, comment: str) -> None: + """ + Sets comment line start character. + + Parameters + ---------- + comment : str + A character that indicates comment + + Returns + ------- + None + """ + def set_parse_dates(self, val: list) -> None: + """ + Sets indexes or names of columns to read as datetime. + + Parameters + ---------- + val : list[int | str] + List column indices or names to infer as datetime. + + Returns + ------- + None + """ + def set_parse_hex(self, val: list) -> None: + """ + Sets indexes or names of columns to parse as hexadecimal. + + Parameters + ---------- + val : list[int | str] + List of column indices or names to parse as hexadecimal + + Returns + ------- + None + """ + def set_dtypes(self, types: object) -> None: + """ + Sets per-column types. + + Parameters + ---------- + types : dict[str, data_type] | list[data_type] + Column name to data type map specifying the columns' target data types. + Or a list specifying the columns' target data types. + + Returns + ------- + None + """ + def set_true_values(self, true_values: list) -> None: + """ + Sets additional values to recognize as boolean true values. + + Parameters + ---------- + true_values : list[str] + List of values to be considered to be true + + Returns + ------- + None + """ + def set_false_values(self, false_values: list) -> None: + """ + Sets additional values to recognize as boolean false values. + + Parameters + ---------- + false_values : list[str] + List of values to be considered to be false + + Returns + ------- + None + """ + def set_na_values(self, na_values: list) -> None: + """ + Sets additional values to recognize as null values. + + Parameters + ---------- + na_values : list[str] + List of values to be considered to be null + + Returns + ------- + None + """ + def set_source(self, src: SourceInfo) -> None: + """ + Set a new source info location. + + Parameters + ---------- + src : SourceInfo + New source information, replacing existing information. + + Returns + ------- + None + """ class CsvReaderOptionsBuilder: - def __init__(self): ... - def compression(self, compression: CompressionType) -> Self: ... - def mangle_dupe_cols(self, mangle_dupe_cols: bool) -> Self: ... - def byte_range_offset(self, byte_range_offset: int) -> Self: ... - def byte_range_size(self, byte_range_size: int) -> Self: ... - def nrows(self, nrows: int) -> Self: ... - def skiprows(self, skiprows: int) -> Self: ... - def skipfooter(self, skipfooter: int) -> Self: ... - def quoting(self, quoting: QuoteStyle) -> Self: ... - def lineterminator(self, lineterminator: str) -> Self: ... - def quotechar(self, quotechar: str) -> Self: ... - def decimal(self, decimal: str) -> Self: ... - def delim_whitespace(self, delim_whitespace: bool) -> Self: ... - def skipinitialspace(self, skipinitialspace: bool) -> Self: ... - def skip_blank_lines(self, skip_blank_lines: bool) -> Self: ... - def doublequote(self, doublequote: bool) -> Self: ... - def keep_default_na(self, keep_default_na: bool) -> Self: ... - def na_filter(self, na_filter: bool) -> Self: ... - def dayfirst(self, dayfirst: bool) -> Self: ... - def delimiter(self, delimiter: str) -> Self: ... - def build(self) -> CsvReaderOptions: ... - -def read_csv( - options: CsvReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> TableWithMetadata: ... -def write_csv( - options: CsvWriterOptions, stream: CudaStreamLike | None = None -): ... + """ + Builder to build options for ``read_csv`` + + For details, see :cpp:class:`cudf::io::csv_reader_options_builder` + """ + def compression(self, compression: compression_type) -> CsvReaderOptionsBuilder: + """ + Sets compression format of the source. + + Parameters + ---------- + compression : compression_type + Compression type + + Returns + ------- + CsvReaderOptionsBuilder + """ + def mangle_dupe_cols(self, mangle_dupe_cols: bool) -> CsvReaderOptionsBuilder: + """ + Sets whether to rename duplicate column names. + + Parameters + ---------- + mangle_dupe_cols : bool + Boolean value to enable/disable + + Returns + ------- + CsvReaderOptionsBuilder + """ + def byte_range_offset(self, byte_range_offset: int) -> CsvReaderOptionsBuilder: + """ + Sets number of bytes to skip from source start. + + Parameters + ---------- + byte_range_offset : size_t + Number of bytes of offset + + Returns + ------- + CsvReaderOptionsBuilder + """ + def byte_range_size(self, byte_range_size: int) -> CsvReaderOptionsBuilder: + """ + Sets number of bytes to read. + + Parameters + ---------- + byte_range_offset : size_t + Number of bytes to read + + Returns + ------- + CsvReaderOptionsBuilder + """ + def nrows(self, nrows: size_type) -> CsvReaderOptionsBuilder: + """ + Sets number of rows to read. + + Parameters + ---------- + nrows : size_type + Number of rows to read + + Returns + ------- + CsvReaderOptionsBuilder + """ + def skiprows(self, skiprows: size_type) -> CsvReaderOptionsBuilder: + """ + Sets number of rows to skip from start. + + Parameters + ---------- + skiprows : size_type + Number of rows to skip + + Returns + ------- + CsvReaderOptionsBuilder + """ + def skipfooter(self, skipfooter: size_type) -> CsvReaderOptionsBuilder: + """ + Sets number of rows to skip from end. + + Parameters + ---------- + skipfooter : size_type + Number of rows to skip + + Returns + ------- + CsvReaderOptionsBuilder + """ + def quoting(self, quoting: quote_style) -> CsvReaderOptionsBuilder: + """ + Sets quoting style. + + Parameters + ---------- + quoting : quote_style + Quoting style used + + Returns + ------- + CsvReaderOptionsBuilder + """ + def lineterminator(self, lineterminator: str) -> CsvReaderOptionsBuilder: + """ + Sets line terminator. + + Parameters + ---------- + quoting : str + A character to indicate line termination + + Returns + ------- + CsvReaderOptionsBuilder + """ + def quotechar(self, quotechar: str) -> CsvReaderOptionsBuilder: + """ + Sets quoting character. + + Parameters + ---------- + quotechar : str + A character to indicate quoting + + Returns + ------- + CsvReaderOptionsBuilder + """ + def decimal(self, decimal: str) -> CsvReaderOptionsBuilder: + """ + Sets decimal point character. + + Parameters + ---------- + quotechar : str + A character that indicates decimal values + + Returns + ------- + CsvReaderOptionsBuilder + """ + def delim_whitespace(self, delim_whitespace: bool) -> CsvReaderOptionsBuilder: + """ + Sets whether to treat whitespace as field delimiter. + + Parameters + ---------- + delim_whitespace : bool + Boolean value to enable/disable + + Returns + ------- + CsvReaderOptionsBuilder + """ + def skipinitialspace(self, skipinitialspace: bool) -> CsvReaderOptionsBuilder: + """ + Sets whether to skip whitespace after the delimiter. + + Parameters + ---------- + skipinitialspace : bool + Boolean value to enable/disable + + Returns + ------- + CsvReaderOptionsBuilder + """ + def skip_blank_lines(self, skip_blank_lines: bool) -> CsvReaderOptionsBuilder: + """ + Sets whether to ignore empty lines or parse line values as invalid. + + Parameters + ---------- + skip_blank_lines : bool + Boolean value to enable/disable + + Returns + ------- + CsvReaderOptionsBuilder + """ + def doublequote(self, doublequote: bool) -> CsvReaderOptionsBuilder: + """ + Sets a quote inside a value is double-quoted. + + Parameters + ---------- + doublequote : bool + Boolean value to enable/disable + + Returns + ------- + CsvReaderOptionsBuilder + """ + def keep_default_na(self, keep_default_na: bool) -> CsvReaderOptionsBuilder: + """ + Sets whether to keep the built-in default NA values. + + Parameters + ---------- + keep_default_na : bool + Boolean value to enable/disable + + Returns + ------- + CsvReaderOptionsBuilder + """ + def na_filter(self, na_filter: bool) -> CsvReaderOptionsBuilder: + """ + Sets whether to disable null filter. + + Parameters + ---------- + na_filter : bool + Boolean value to enable/disable + + Returns + ------- + CsvReaderOptionsBuilder + """ + def dayfirst(self, dayfirst: bool) -> CsvReaderOptionsBuilder: + """ + Sets whether to parse dates as DD/MM versus MM/DD. + + Parameters + ---------- + dayfirst : bool + Boolean value to enable/disable + + Returns + ------- + CsvReaderOptionsBuilder + """ + def delimiter(self, delimiter: str) -> CsvReaderOptionsBuilder: + """ + Sets field delimiter. + + Parameters + ---------- + delimiter : str + A character to indicate delimiter + + Returns + ------- + CsvReaderOptionsBuilder + """ + def build(self) -> CsvReaderOptions: + """Create a CsvReaderOptions object""" class CsvWriterOptions: - def __init__(self): ... + """The settings to use for ``write_csv`` + + For details, see :cpp:class:`cudf::io::csv_writer_options` + """ @staticmethod - def builder(sink: SinkInfo, table: Table) -> CsvWriterOptionsBuilder: ... + def builder(sink: SinkInfo, table: Table): + """Create a CsvWriterOptionsBuilder object + + For details, see :cpp:func:`cudf::io::csv_writer_options::builder` + + Parameters + ---------- + sink : SinkInfo + The sink used for writer output + table : Table + Table to be written to output + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ class CsvWriterOptionsBuilder: - def __init__(self): ... - def names(self, names: list) -> Self: ... - def na_rep(self, val: str) -> Self: ... - def include_header(self, val: bool) -> Self: ... - def rows_per_chunk(self, val: int) -> Self: ... - def line_terminator(self, term: str) -> Self: ... - def inter_column_delimiter(self, delim: str) -> Self: ... - def true_value(self, val: str) -> Self: ... - def false_value(self, val: str) -> Self: ... - def quoting(self, style: QuoteStyle) -> Self: ... - def build(self) -> CsvWriterOptions: ... - -def is_supported_write_csv(type: DataType) -> bool: ... + """Builder to build options for ``write_csv`` + + For details, see :cpp:class:`cudf::io::csv_writer_options_builder` + """ + def names(self, names: list) -> CsvWriterOptionsBuilder: + """Sets optional column names. + + Parameters + ---------- + names : list[str] + Column names + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def na_rep(self, val: str) -> CsvWriterOptionsBuilder: + """Sets string to used for null entries. + + Parameters + ---------- + val : str + String to represent null value + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def include_header(self, val: bool) -> CsvWriterOptionsBuilder: + """Enables/Disables headers being written to csv. + + Parameters + ---------- + val : bool + Boolean value to enable/disable + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def rows_per_chunk(self, val: int) -> CsvWriterOptionsBuilder: + """Sets maximum number of rows to process for each file write. + + Parameters + ---------- + val : int + Number of rows per chunk + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def line_terminator(self, term: str) -> CsvWriterOptionsBuilder: + """Sets character used for separating lines. + + Parameters + ---------- + term : str + Character to represent line termination + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def inter_column_delimiter(self, delim: str) -> CsvWriterOptionsBuilder: + """Sets character used for separating column values. + + Parameters + ---------- + delim : str + Character to delimit column values + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def true_value(self, val: str) -> CsvWriterOptionsBuilder: + """Sets string used for values != 0 + + Parameters + ---------- + val : str + String to represent values != 0 + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def false_value(self, val: str) -> CsvWriterOptionsBuilder: + """Sets string used for values == 0 + + Parameters + ---------- + val : str + String to represent values == 0 + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def quoting(self, style: quote_style) -> CsvWriterOptionsBuilder: + """Sets quoting style for string columns. + + Parameters + ---------- + style : quote_style + Quoting style (MINIMAL or NONE). + MINIMAL: Quote only fields containing special characters. + NONE: Never quote fields. + + Returns + ------- + CsvWriterOptionsBuilder + Builder to build CsvWriterOptions + """ + def build(self) -> CsvWriterOptions: + """Create a CsvWriterOptions object""" + +def read_csv(options: CsvReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> TableWithMetadata: + """ + Read from CSV format. + + The source to read from and options are encapsulated + by the `options` object. + + For details, see :cpp:func:`read_csv`. + + Parameters + ---------- + options: CsvReaderOptions + Settings for controlling reading behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned table's device memory. + """ +def write_csv(options: CsvWriterOptions, stream: object | None=None) -> None: + """ + Write to CSV format. + + The table to write, output paths, and options are encapsulated + by the `options` object. + + For details, see :cpp:func:`write_csv`. + + Parameters + ---------- + options: CsvWriterOptions + Settings for controlling writing behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + """ +def is_supported_write_csv(type: DataType) -> bool: + """Check if the dtype is supported for CSV writing + + For details, see :cpp:func:`is_supported_write_type`. + """ diff --git a/python/pylibcudf/pylibcudf/io/datasource.pyi b/python/pylibcudf/pylibcudf/io/datasource.pyi index 5478d5889483..495cf7a3cb6b 100644 --- a/python/pylibcudf/pylibcudf/io/datasource.pyi +++ b/python/pylibcudf/pylibcudf/io/datasource.pyi @@ -1,5 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/datasource.pyx + +__all__ = ['Datasource'] + class Datasource: - def __init__(self): ... + __hash__ = None diff --git a/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi b/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi index f95dc8b054d3..dbf10b77a126 100644 --- a/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi +++ b/python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi @@ -1,144 +1,427 @@ # SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum - -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyx +import pylibcudf.libcudf.io.hybrid_scan from pylibcudf.column import Column from pylibcudf.io.parquet import ParquetReaderOptions from pylibcudf.io.parquet_metadata import FileMetaData -from pylibcudf.io.text import ByteRangeInfo -from pylibcudf.io.types import TableWithMetadata -from pylibcudf.utils import CudaStreamLike - -try: - from collections.abc import Buffer -except ImportError: - from typing_extensions import Buffer +from pylibcudf.io.parquet_metadata import FileMetaData as c_FileMetaData +from pylibcudf.libcudf.io.hybrid_scan import \ + use_data_page_mask as cpp_use_data_page_mask +from rmm.pylibrmm.memory_resource import DeviceMemoryResource -class UseDataPageMask(IntEnum): - YES = 1 - NO = 0 +UseDataPageMask = pylibcudf.libcudf.io.hybrid_scan.use_data_page_mask +__all__ = ['FileMetaData', 'HybridScanReader', 'UseDataPageMask'] class HybridScanReader: - def __init__( - self, footer_bytes: Buffer, options: ParquetReaderOptions - ) -> None: ... + """Experimental Parquet reader optimized for highly selective filters. + + This class implements a hybrid scan operation for reading Parquet files + with highly selective filters. It reads in two passes: first reading + filter columns to build a row mask, then reading payload columns using + that mask for optimization. + + For details, see :cpp:class:`cudf::io::parquet::experimental::hybrid_scan_reader` + + Parameters + ---------- + footer_bytes : Buffer + Parquet file footer bytes + options : ParquetReaderOptions + Parquet reader options + + Examples + -------- + >>> import pylibcudf as plc + >>> # Create reader from footer bytes + >>> reader = plc.io.hybrid_scan.HybridScanReader(footer_bytes, options) + >>> # Get metadata + >>> metadata = reader.parquet_metadata() + >>> # Get all row groups + >>> row_groups = reader.all_row_groups(options) + """ + def __init__(self, footer_bytes: memoryview, options: ParquetReaderOptions): ... @staticmethod - def from_parquet_metadata( - metadata: FileMetaData, options: ParquetReaderOptions - ) -> HybridScanReader: ... - def parquet_metadata(self) -> FileMetaData: ... - def page_index_byte_range(self) -> ByteRangeInfo: ... - def setup_page_index(self, page_index_bytes: Buffer) -> None: ... - def all_row_groups(self, options: ParquetReaderOptions) -> list[int]: ... - def total_rows_in_row_groups( - self, row_group_indices: list[int] - ) -> int: ... - def reset_column_selection(self) -> None: ... - def filter_row_groups_with_stats( - self, - row_group_indices: list[int], - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - ) -> list[int]: ... - def secondary_filters_byte_ranges( - self, row_group_indices: list[int], options: ParquetReaderOptions - ) -> tuple[list[ByteRangeInfo], list[ByteRangeInfo]]: ... - def filter_row_groups_with_dictionary_pages( - self, - dictionary_page_data: list, - row_group_indices: list[int], - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - ) -> list[int]: ... - def filter_row_groups_with_bloom_filters( - self, - bloom_filter_data: list, - row_group_indices: list[int], - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - ) -> list[int]: ... - def build_row_mask_with_page_index_stats( - self, - row_group_indices: list[int], - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Column: ... - def filter_column_chunks_byte_ranges( - self, row_group_indices: list[int], options: ParquetReaderOptions - ) -> list[ByteRangeInfo]: ... - def materialize_filter_columns( - self, - row_group_indices: list[int], - column_chunk_data: list, - row_mask: Column, - mask_data_pages: UseDataPageMask, - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> TableWithMetadata: ... - def payload_column_chunks_byte_ranges( - self, row_group_indices: list[int], options: ParquetReaderOptions - ) -> list[ByteRangeInfo]: ... - def materialize_payload_columns( - self, - row_group_indices: list[int], - column_chunk_data: list, - row_mask: Column, - mask_data_pages: UseDataPageMask, - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> TableWithMetadata: ... - def all_column_chunks_byte_ranges( - self, row_group_indices: list[int], options: ParquetReaderOptions - ) -> list[ByteRangeInfo]: ... - def materialize_all_columns( - self, - row_group_indices: list[int], - column_chunk_data: list, - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> TableWithMetadata: ... - def setup_chunking_for_filter_columns( - self, - chunk_read_limit: int, - pass_read_limit: int, - row_group_indices: list[int], - row_mask: Column, - mask_data_pages: UseDataPageMask, - column_chunk_data: list, - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> None: ... - def materialize_filter_columns_chunk( - self, - row_mask: Column, - ) -> TableWithMetadata: ... - def setup_chunking_for_payload_columns( - self, - chunk_read_limit: int, - pass_read_limit: int, - row_group_indices: list[int], - row_mask: Column, - mask_data_pages: UseDataPageMask, - column_chunk_data: list, - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> None: ... - def materialize_payload_columns_chunk( - self, - row_mask: Column, - ) -> TableWithMetadata: ... - def construct_row_group_passes( - self, - row_group_indices: list[int], - pass_read_limit: int, - ) -> list[list[int]]: ... - def has_next_table_chunk(self) -> bool: ... + def from_parquet_metadata(metadata: c_FileMetaData, options: ParquetReaderOptions): + """Create a HybridScanReader from pre-populated metadata. + + Parameters + ---------- + metadata : FileMetaData + Pre-populated Parquet file metadata + options : ParquetReaderOptions + Parquet reader options + + Returns + ------- + HybridScanReader + """ + def parquet_metadata(self): + """Get the Parquet file footer metadata. + + Returns + ------- + FileMetaData + Parquet file footer metadata + """ + def page_index_byte_range(self): + """Get the byte range of the page index. + + Returns + ------- + ByteRangeInfo + Byte range of the page index + """ + def setup_page_index(self, page_index_bytes: memoryview): + """Setup the page index within the Parquet file metadata. + + Parameters + ---------- + page_index_bytes : Buffer + Parquet page index buffer bytes + """ + def all_row_groups(self, options: ParquetReaderOptions): + """Get all available row groups from the parquet file. + + Parameters + ---------- + options : ParquetReaderOptions + Parquet reader options + + Returns + ------- + list[int] + List of row group indices + """ + def total_rows_in_row_groups(self, row_group_indices: list): + """Get the total number of top-level rows in the row groups. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + + Returns + ------- + int + Total number of top-level rows + """ + def reset_column_selection(self): + """Reset the column selection state. + + Resets the internal column selection state forcing re-selection of columns in + subsequent filter and read operations + """ + def filter_row_groups_with_stats(self, row_group_indices: list, options: ParquetReaderOptions, stream: object | None=None): + """Filter row groups using column chunk statistics. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + + Returns + ------- + list[int] + Filtered row group indices + """ + def secondary_filters_byte_ranges(self, row_group_indices: list, options: ParquetReaderOptions): + """Get byte ranges of bloom filters and dictionary pages. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + options : ParquetReaderOptions + Parquet reader options + + Returns + ------- + tuple[list[ByteRangeInfo], list[ByteRangeInfo]] + Tuple of (bloom_filter_ranges, dictionary_page_ranges) + """ + def filter_row_groups_with_dictionary_pages(self, dictionary_page_data: list, row_group_indices: list, options: ParquetReaderOptions, stream: object | None=None): + """Filter row groups using column chunk dictionary pages. + + Parameters + ---------- + dictionary_page_data : list + Span-like objects containing dictionary page data + row_group_indices : list[int] + Input row group indices + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + + Returns + ------- + list[int] + Filtered row group indices + """ + def filter_row_groups_with_bloom_filters(self, bloom_filter_data: list, row_group_indices: list, options: ParquetReaderOptions, stream: object | None=None): + """Filter row groups using column chunk bloom filters. + + Parameters + ---------- + bloom_filter_data : list + Span-like objects containing bloom filter data + row_group_indices : list[int] + Input row group indices + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + + Returns + ------- + list[int] + Filtered row group indices + """ + def build_row_mask_with_page_index_stats(self, row_group_indices: list, options: ParquetReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Build a boolean column indicating surviving rows from page stats. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + mr : DeviceMemoryResource, optional + Device memory resource + + Returns + ------- + Column + Boolean column indicating surviving rows + """ + def filter_column_chunks_byte_ranges(self, row_group_indices: list, options: ParquetReaderOptions): + """Get byte ranges of column chunks of filter columns. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + options : ParquetReaderOptions + Parquet reader options + + Returns + ------- + list[ByteRangeInfo] + Byte ranges to column chunks of filter columns + """ + def materialize_filter_columns(self, row_group_indices: list, column_chunk_data: list, row_mask: Column, mask_data_pages: cpp_use_data_page_mask, options: ParquetReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Materialize filter columns and update the row mask. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + column_chunk_data : list + Span-like objects containing column chunk data of filter columns + row_mask : Column + Mutable boolean column indicating surviving rows + mask_data_pages : UseDataPageMask + Whether to use a data page mask + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + mr : DeviceMemoryResource, optional + Device memory resource + + Returns + ------- + TableWithMetadata + Table of materialized filter columns and metadata + """ + def payload_column_chunks_byte_ranges(self, row_group_indices: list, options: ParquetReaderOptions): + """Get byte ranges of column chunks of payload columns. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + options : ParquetReaderOptions + Parquet reader options + + Returns + ------- + list[ByteRangeInfo] + Byte ranges to column chunks of payload columns + """ + def materialize_payload_columns(self, row_group_indices: list, column_chunk_data: list, row_mask: Column, mask_data_pages: cpp_use_data_page_mask, options: ParquetReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Materialize payload columns and apply the row mask. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + column_chunk_data : list + Span-like objects containing column chunk data of payload columns + row_mask : Column + Boolean column indicating surviving rows + mask_data_pages : UseDataPageMask + Whether to use a data page mask + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + mr : DeviceMemoryResource, optional + Device memory resource + + Returns + ------- + TableWithMetadata + Table of materialized payload columns and metadata + """ + def all_column_chunks_byte_ranges(self, row_group_indices: list, options: ParquetReaderOptions): + """Get byte ranges of column chunks of all columns. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + options : ParquetReaderOptions + Parquet reader options + + Returns + ------- + list[ByteRangeInfo] + Byte ranges to column chunks of all columns + """ + def materialize_all_columns(self, row_group_indices: list, column_chunk_data: list, options: ParquetReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Materialize all columns. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + column_chunk_data : list + Span-like objects containing column chunk data of all columns + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + mr : DeviceMemoryResource, optional + Device memory resource + + Returns + ------- + TableWithMetadata + Table of materialized all columns and metadata + """ + def setup_chunking_for_filter_columns(self, chunk_read_limit: int, pass_read_limit: int, row_group_indices: list, row_mask: Column, mask_data_pages: cpp_use_data_page_mask, column_chunk_data: list, options: ParquetReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Setup chunking information for filter columns. + + Parameters + ---------- + chunk_read_limit : int + Limit on bytes returned per chunk (0 for no limit) + pass_read_limit : int + Limit on memory for reading/decompressing (0 for no limit) + row_group_indices : list[int] + Input row group indices + row_mask : Column + Boolean column indicating surviving rows + mask_data_pages : UseDataPageMask + Whether to use a data page mask + column_chunk_data : list + Span-like objects containing column chunk data of filter columns + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + mr : DeviceMemoryResource, optional + Device memory resource + """ + def materialize_filter_columns_chunk(self, row_mask: Column): + """Materialize a chunk of filter columns. + + Parameters + ---------- + row_mask : Column + Mutable boolean column indicating surviving rows + Returns + ------- + TableWithMetadata + Table chunk of materialized filter columns and metadata + """ + def setup_chunking_for_payload_columns(self, chunk_read_limit: int, pass_read_limit: int, row_group_indices: list, row_mask: Column, mask_data_pages: cpp_use_data_page_mask, column_chunk_data: list, options: ParquetReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """Setup chunking information for payload columns. + + Parameters + ---------- + chunk_read_limit : int + Limit on bytes returned per chunk (0 for no limit) + pass_read_limit : int + Limit on memory for reading/decompressing (0 for no limit) + row_group_indices : list[int] + Input row group indices + row_mask : Column + Boolean column indicating surviving rows + mask_data_pages : UseDataPageMask + Whether to use a data page mask + column_chunk_data : list + Span-like objects containing column chunk data of payload columns + options : ParquetReaderOptions + Parquet reader options + stream : Stream, optional + CUDA stream + mr : DeviceMemoryResource, optional + Device memory resource + """ + def materialize_payload_columns_chunk(self, row_mask: Column): + """Materialize a chunk of payload columns. + + Parameters + ---------- + row_mask : Column + Boolean column indicating surviving rows + Returns + ------- + TableWithMetadata + Table chunk of materialized payload columns and metadata + """ + def construct_row_group_passes(self, row_group_indices: list, pass_read_limit: int): + """Partition row groups into passes such that the GPU memory required to + materialize a pass is bounded by the specified limit. + + Note that ``pass_read_limit`` is a hint, not an absolute limit. i.e. if + a row group cannot fit within the limit, it will still constitute a valid + pass. + + Parameters + ---------- + row_group_indices : list[int] + Input row group indices + pass_read_limit : int + Limit on the amount of memory used for reading and decompressing data + or 0 if there is no limit. + + Returns + ------- + list[list[int]] + Lists of row group indices, one per pass. + + Raises + ------ + ValueError + If ``row_group_indices`` is empty. + """ + def has_next_table_chunk(self): + """Check if there is any parquet data left to read. + + Returns + ------- + bool + True if there is data left to read + """ diff --git a/python/pylibcudf/pylibcudf/io/json.pyi b/python/pylibcudf/pylibcudf/io/json.pyi index a03d8ef407cc..9e33aabbd186 100644 --- a/python/pylibcudf/pylibcudf/io/json.pyi +++ b/python/pylibcudf/pylibcudf/io/json.pyi @@ -1,39 +1,145 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Mapping -from typing import Self, TypeAlias -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/json.pyx from pylibcudf.column import Column -from pylibcudf.io.types import ( - CompressionType, - JSONRecoveryMode, - SinkInfo, - SourceInfo, - TableWithMetadata, -) +from pylibcudf.io.types import (SinkInfo, SourceInfo, TableWithMetadata, + compression_type) +from pylibcudf.libcudf.io.json import json_recovery_mode_t +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar from pylibcudf.table import Table from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -ChildNameToTypeMap: TypeAlias = Mapping[str, ChildNameToTypeMap] +from rmm.pylibrmm.memory_resource import DeviceMemoryResource -NameAndType: TypeAlias = tuple[str, DataType, list[NameAndType]] +__all__ = ['chunked_read_json', 'read_json', 'read_json_from_string_column', 'write_json', 'JsonReaderOptions', 'JsonReaderOptionsBuilder', 'JsonWriterOptions', 'JsonWriterOptionsBuilder'] class JsonReaderOptions: - def set_dtypes( - self, types: list[DataType] | list[NameAndType] - ) -> None: ... - def enable_keep_quotes(self, keep_quotes: bool) -> None: ... - def enable_mixed_types_as_string( - self, mixed_types_as_string: bool - ) -> None: ... - def enable_prune_columns(self, prune_columns: bool) -> None: ... - def set_byte_range_offset(self, offset: int) -> None: ... - def set_byte_range_size(self, size: int) -> None: ... - def enable_lines(self, val: bool) -> None: ... + """ + The settings to use for ``read_json`` + + For details, see `:cpp:class:`cudf::io::json_reader_options` + """ + @staticmethod + def builder(source: SourceInfo): + """ + Create a JsonReaderOptionsBuilder object + + For details, see :cpp:func:`cudf::io::json_reader_options::builder` + + Parameters + ---------- + sink : SourceInfo + The source to read the JSON file from. + + Returns + ------- + JsonReaderOptionsBuilder + Builder to build JsonReaderOptions + """ + def set_dtypes(self, types: list) -> None: + """ + Set data types for columns to be read. + + Parameters + ---------- + types : list + List of dtypes or a list of tuples of + column names, dtypes, and list of tuples + (to support nested column hierarchy) + + Returns + ------- + None + """ + def enable_keep_quotes(self, keep_quotes: bool) -> None: + """ + Set whether the reader should keep quotes of string values. + + Parameters + ---------- + keep_quotes : bool + Boolean value to indicate whether the reader should + keep quotes of string values + + Returns + ------- + None + """ + def enable_mixed_types_as_string(self, mixed_types_as_string: bool) -> None: + """ + Set whether to parse mixed types as a string column. + Also enables forcing to read a struct as string column using schema. + + Parameters + ---------- + mixed_types_as_string : bool + Boolean value to enable/disable parsing mixed types + as a string column + + Returns + ------- + None + """ + def enable_prune_columns(self, prune_columns: bool) -> None: + """ + Set whether to prune columns on read, selected + based on the ``set_dtypes`` option. + + Parameters + ---------- + prune_columns : bool + When set as true, if the reader options include + ``set_dtypes``, then the reader will only return those + columns which are mentioned in ``set_dtypes``. If false, + then all columns are returned, independent of the + ``set_dtypes`` setting. + + Returns + ------- + None + """ + def set_byte_range_offset(self, offset: int) -> None: + """ + Set number of bytes to skip from source start. + + Parameters + ---------- + offset : size_t + Number of bytes of offset + + Returns + ------- + None + """ + def set_byte_range_size(self, size: int) -> None: + """ + Set number of bytes to read. + + Parameters + ---------- + size : size_t + Number of bytes to read + + Returns + ------- + None + """ + def enable_lines(self, val: bool) -> None: + """ + Set whether to read the file as a json object per line. + + Parameters + ---------- + val : bool + Boolean value to enable/disable the option + to read each line as a json object + + Returns + ------- + None + """ def set_delimiter(self, val: str) -> None: ... def enable_dayfirst(self, val: bool) -> None: ... def enable_experimental(self, val: bool) -> None: ... @@ -43,87 +149,540 @@ class JsonReaderOptions: def allow_unquoted_control_chars(self, val: bool) -> None: ... def allow_numeric_leading_zeros(self, val: bool) -> None: ... def allow_nonnumeric_numbers(self, val: bool) -> None: ... - def set_na_values(self, vals: list[str]) -> None: ... - def set_source(self, src: SourceInfo) -> None: ... - @staticmethod - def builder(source: SourceInfo) -> JsonReaderOptionsBuilder: ... + def set_na_values(self, vals: list) -> None: ... + def set_source(self, src: SourceInfo) -> None: + """ + Set a new source info location. + + Parameters + ---------- + src : SourceInfo + New source information, replacing existing information. + + Returns + ------- + None + """ class JsonReaderOptionsBuilder: - def byte_range_offset(self, byte_range_offset: int) -> Self: ... - def byte_range_size(self, byte_range_size: int) -> Self: ... - def compression(self, compression_type: CompressionType) -> Self: ... - def dayfirst(self, val: bool) -> Self: ... - def delimiter(self, delimiter: str) -> Self: ... - def dtypes(self, types: list) -> Self: ... - def experimental(self, val: bool) -> Self: ... - def keep_quotes(self, val: bool) -> Self: ... - def lines(self, val: bool) -> Self: ... - def mixed_types_as_string(self, val: bool) -> Self: ... - def na_values(self, vals: list) -> Self: ... - def nonnumeric_numbers(self, val: bool) -> Self: ... - def normalize_single_quotes(self, val: bool) -> Self: ... - def normalize_whitespace(self, val: bool) -> Self: ... - def numeric_leading_zeros(self, val: bool) -> Self: ... - def prune_columns(self, val: bool) -> Self: ... - def recovery_mode(self, recovery_mode: JSONRecoveryMode) -> Self: ... - def strict_validation(self, val: bool) -> Self: ... - def unquoted_control_chars(self, val: bool) -> Self: ... - def utf8_escaped(self, val: bool) -> Self: ... - def build(self) -> JsonReaderOptions: ... - -def read_json( - options: JsonReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> TableWithMetadata: ... -def read_json_from_string_column( - input: Column, - separator: Scalar, - narep: Scalar, - dtypes: list | None = None, - compression: CompressionType = CompressionType.NONE, - recovery_mode: JSONRecoveryMode = JSONRecoveryMode.RECOVER_WITH_NULL, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> TableWithMetadata: ... + def byte_range_offset(self, byte_range_offset: int) -> JsonReaderOptionsBuilder: + """ + Set number of bytes to skip from source start. + + Parameters + ---------- + byte_range_offset : size_t + Number of bytes of offset + + Returns + ------- + Self + """ + def byte_range_size(self, byte_range_size: int) -> JsonReaderOptionsBuilder: + """ + Set number of bytes to read. + + Parameters + ---------- + byte_range_size : size_t + Number of bytes to read + + Returns + ------- + Self + """ + def compression(self, compression: compression_type) -> JsonReaderOptionsBuilder: + """ + Sets compression type. + + Parameters + ---------- + compression : CompressionType + The compression type to use + + Returns + ------- + Self + """ + def dayfirst(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether the reader should parse dates as DD/MM versus MM/DD. + + Parameters + ---------- + val : bool + Boolean value to indicate whether the + reader should enable/disable DD/MM parsing + + Returns + ------- + Self + """ + def delimiter(self, delimiter: str) -> JsonReaderOptionsBuilder: + """ + Set delimiter character separating records in JSON lines inputs + + Parameters + ---------- + delimiter : str + Character to be used as delimiter separating records + + Returns + ------- + Self + """ + def dtypes(self, types: list) -> JsonReaderOptionsBuilder: + """ + Set data type for columns to be read + + Parameters + ---------- + types : list + List of dtypes or a list of tuples of + column names, dtypes, and list of tuples + (to support nested column hierarchy) + + Returns + ------- + Self + """ + def experimental(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether to enable experimental features. + When set to true, experimental features, such as the new column tree + construction, utf-8 matching of field names will be enabled. + + Parameters + ---------- + val : bool + Boolean value to enable/disable experimental features + + Returns + ------- + Self + """ + def keep_quotes(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether the reader should keep quotes of string values. + + Parameters + ---------- + val : bool + Boolean value to indicate whether the + reader should keep quotes of string values + + Returns + ------- + Self + """ + def lines(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether to read the file as a json object per line. + + Parameters + ---------- + val : bool + Boolean value to enable/disable the option + to read each line as a json object + + Returns + ------- + Self + """ + def mixed_types_as_string(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether to parse mixed types as a string column. + Also enables forcing to read a struct as string column using schema. + + Parameters + ---------- + val : bool + Boolean value to enable/disable parsing mixed types as a string column + + Returns + ------- + Self + """ + def na_values(self, vals: list) -> JsonReaderOptionsBuilder: + """ + Sets additional values to recognize as null values. + + Parameters + ---------- + vals : list + Vector of values to be considered to be null + + Returns + ------- + Self + """ + def nonnumeric_numbers(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether unquoted number values should be allowed NaN, +INF, -INF, +Infinity, + Infinity, and -Infinity. Strict validation must be enabled for this to work. + + Parameters + ---------- + val : bool + Boolean value to indicate whether leading zeros are allowed in numeric + values + + Returns + ------- + Self + """ + def normalize_single_quotes(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Sets whether to normalize single quotes around strings. + + Parameters + ---------- + val : bool + Boolean value to enable/disable the option to normalize single quotes + around strings + + Returns + ------- + Self + """ + def normalize_whitespace(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Sets whether to normalize unquoted whitespace characters + + Parameters + ---------- + val : bool + Boolean value to enable/disable the option to normalize unquoted + whitespace characters + + Returns + ------- + Self + """ + def numeric_leading_zeros(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether leading zeros are allowed in numeric values. Strict validation + must be enabled for this to work. + + Parameters + ---------- + val : bool + Boolean value to indicate whether leading zeros are allowed in numeric + values + + Returns + ------- + Self + """ + def prune_columns(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether to prune columns on read, selected based on the @ref dtypes option. + When set as true, if the reader options include @ref dtypes, then + the reader will only return those columns which are mentioned in @ref dtypes. + If false, then all columns are returned, independent of the @ref dtypes setting. + + Parameters + ---------- + val : bool + Boolean value to enable/disable column pruning + + Returns + ------- + Self + """ + def recovery_mode(self, recovery_mode: json_recovery_mode_t) -> JsonReaderOptionsBuilder: + """ + Specifies the JSON reader's behavior on invalid JSON lines. + + Parameters + ---------- + recovery_mode : json_recovery_mode_t + An enum value to indicate the JSON reader's + behavior on invalid JSON lines. + + Returns + ------- + Self + """ + def strict_validation(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether strict validation is enabled or not + + Parameters + ---------- + val : bool + Boolean value to indicate whether strict validation is to be enabled + + Returns + ------- + Self + """ + def unquoted_control_chars(self, val: bool) -> JsonReaderOptionsBuilder: + """ + Set whether in a quoted string should characters greater than or equal to 0 + and less than 32 be allowed without some form of escaping. Strict validation + must be enabled for this to work. + + Parameters + ---------- + val : bool + Boolean value to indicate whether unquoted control chars are allowed + + Returns + ------- + Self + """ + def build(self): + """Create a JsonReaderOptions object""" class JsonWriterOptions: + """ + The settings to use for ``write_json`` + + For details, see :cpp:class:`cudf::io::json_writer_options` + """ @staticmethod - def builder(sink: SinkInfo, table: Table) -> JsonWriterOptionsBuilder: ... - def set_rows_per_chunk(self, val: int) -> None: ... - def set_true_value(self, val: str) -> None: ... - def set_false_value(self, val: str) -> None: ... - def set_compression(self, comptype: CompressionType) -> None: ... + def builder(sink: SinkInfo, table: Table): + """ + Create a JsonWriterOptionsBuilder object + + Parameters + ---------- + sink : SinkInfo + The sink used for writer output + table : Table + Table to be written to output + + Returns + ------- + JsonWriterOptionsBuilder + Builder to build JsonWriterOptions + """ + def set_rows_per_chunk(self, val: size_type) -> None: + """ + Sets string to used for null entries. + + Parameters + ---------- + val : size_type + String to represent null value + + Returns + ------- + None + """ + def set_true_value(self, val: str) -> None: + """ + Sets string used for values != 0 + + Parameters + ---------- + val : str + String to represent values != 0 + + Returns + ------- + None + """ + def set_false_value(self, val: str) -> None: + """ + Sets string used for values == 0 + + Parameters + ---------- + val : str + String to represent values == 0 + + Returns + ------- + None + """ + def set_compression(self, comptype: compression_type) -> None: + """ + Sets compression type to be used + + Parameters + ---------- + comptype : CompressionType + Compression type for sink + + Returns + ------- + None + """ class JsonWriterOptionsBuilder: - def metadata(self, tbl_w_meta: TableWithMetadata) -> Self: ... - def na_rep(self, val: str) -> Self: ... - def include_nulls(self, val: bool) -> Self: ... - def lines(self, val: bool) -> Self: ... - def compression(self, comptype: CompressionType) -> Self: ... - def utf8_escaped(self, val: bool) -> Self: ... - def build(self) -> JsonWriterOptions: ... - -def write_json( - options: JsonWriterOptions, stream: CudaStreamLike | None = None -) -> None: ... -def chunked_read_json( - options: JsonReaderOptions, - chunk_size: int = 100_000_000, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[list[Column], list[str], ChildNameToTypeMap]: ... -def is_supported_write_json(type: DataType) -> bool: ... -def _setup_json_reader_options( - source_info: SourceInfo, - dtypes: list | None, - compression: CompressionType = CompressionType.AUTO, - lines: bool = False, - byte_range_offset: int = 0, - byte_range_size: int = 0, - keep_quotes: bool = False, - mixed_types_as_string: bool = False, - prune_columns: bool = False, - recovery_mode: JSONRecoveryMode = JSONRecoveryMode.FAIL, - extra_parameters: dict | None = None, -) -> JsonReaderOptions: ... + def metadata(self, tbl_w_meta: TableWithMetadata) -> JsonWriterOptionsBuilder: + """ + Sets optional metadata (with column names). + + Parameters + ---------- + tbl_w_meta : TableWithMetadata + Associated metadata + + Returns + ------- + Self + """ + def na_rep(self, val: str) -> JsonWriterOptionsBuilder: + """ + Sets string to used for null entries. + + Parameters + ---------- + val : str + String to represent null value + + Returns + ------- + Self + """ + def include_nulls(self, val: bool) -> JsonWriterOptionsBuilder: + """ + Enables/Disables output of nulls as 'null'. + + Parameters + ---------- + val : bool + Boolean value to enable/disable + + Returns + ------- + Self + """ + def lines(self, val: bool) -> JsonWriterOptionsBuilder: + """ + Enables/Disables JSON lines for records format. + + Parameters + ---------- + val : bool + Boolean value to enable/disable + + Returns + ------- + Self + """ + def compression(self, comptype: compression_type) -> JsonWriterOptionsBuilder: + """ + Sets compression type of output sink. + + Parameters + ---------- + comptype : CompressionType + Compression type used + + Returns + ------- + Self + """ + def utf8_escaped(self, val: bool) -> JsonWriterOptionsBuilder: + """ + Sets whether to write UTF-8 characters in string fields + without escaping them. + + Parameters + ---------- + val : bool + If False, disables escaping of UTF-8 characters in output + + Returns + ------- + Self + """ + def build(self) -> JsonWriterOptions: + """Create a JsonWriterOptions object""" + +def _setup_json_reader_options(source_info: SourceInfo, dtypes: list, compression: compression_type=compression_type.AUTO, lines: bool=False, byte_range_offset: int=0, byte_range_size: int=0, keep_quotes: bool=False, mixed_types_as_string: bool=False, prune_columns: bool=False, recovery_mode: json_recovery_mode_t=json_recovery_mode_t.FAIL, extra_parameters: dict | None=None) -> JsonReaderOptions: ... +def chunked_read_json(options: JsonReaderOptions, chunk_size: int=100000000, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """ + Reads chunks of a JSON file into a :py:class:`~.types.TableWithMetadata`. + + Parameters + ---------- + options : JsonReaderOptions + Settings for controlling reading behavior + chunk_size : int, default 100_000_000 bytes. + The number of bytes to be read in chunks. + The chunk_size should be set to at least row_size. + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + + Returns + ------- + tuple + A tuple of (columns, column_name, child_names) + """ +def read_json(options: JsonReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> TableWithMetadata: + """ + Read from JSON format. + + The source to read from and options are encapsulated + by the `options` object. + + For details, see :cpp:func:`read_json`. + + Parameters + ---------- + options: JsonReaderOptions + Settings for controlling reading behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + + Returns + ------- + TableWithMetadata + The Table and its corresponding metadata (column names) that were read in. + """ +def read_json_from_string_column(input: Column, separator: Scalar, narep: Scalar, dtypes: list | None=None, compression: compression_type=compression_type.NONE, recovery_mode: json_recovery_mode_t=json_recovery_mode_t.RECOVER_WITH_NULL, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> TableWithMetadata: + """ + Joins a column of JSON strings into a device buffer and reads it into + a table using the JSON reader. + + The source to read from is a string column of JSON records. + + For details, see :cpp:func:`join_strings` and :cpp:func:`read_json`. + + Parameters + ---------- + input: Column + String column with json-like strings as rows + separator: Scalar + String scalar used to join the input strings + narep: Scalar + String scalar used to replace null values during join + dtypes: List + Set data types for columns to be read. + compression: CompressionType + Set compression type of the string column contents + recovery_mode: JSONRecoveryMode + Set recovery option for corrupted JSON input in string column + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + + Returns + ------- + TableWithMetadata + The Table and its corresponding metadata (column names) + """ +def write_json(options: JsonWriterOptions, stream: object | None=None) -> None: + """ + Writes a set of columns to JSON format. + + Parameters + ---------- + options : JsonWriterOptions + Settings for controlling writing behavior + stream: Stream + CUDA stream used for device memory operations and kernel launches + + Returns + ------- + None + """ +def is_supported_write_json(type: DataType) -> bool: + """Check if the dtype is supported for JSON writing + + For details, see :cpp:func:`is_supported_write_json`. + """ diff --git a/python/pylibcudf/pylibcudf/io/orc.pyi b/python/pylibcudf/pylibcudf/io/orc.pyi index 3cb6daff2409..ae0c141aa902 100644 --- a/python/pylibcudf/pylibcudf/io/orc.pyi +++ b/python/pylibcudf/pylibcudf/io/orc.pyi @@ -1,110 +1,547 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from typing import Any, Self +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/orc.pyx -from rmm.pylibrmm.memory_resource import DeviceMemoryResource - -from pylibcudf.io.types import ( - CompressionType, - SinkInfo, - SourceInfo, - StatisticsFreq, - TableInputMetadata, - TableWithMetadata, -) +from pylibcudf.io.types import (SinkInfo, SourceInfo, TableInputMetadata, + TableWithMetadata) +from pylibcudf.libcudf.io.types import compression_type, statistics_freq +from pylibcudf.libcudf.types import size_type from pylibcudf.table import Table from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -class OrcReaderOptions: - def set_num_rows(self, nrows: int) -> None: ... - def set_skip_rows(self, skip_rows: int) -> None: ... - def set_stripes(self, stripes: list[list[int]]) -> None: ... - def set_decimal128_columns(self, val: list[str]) -> None: ... - def set_timestamp_type(self, type_: DataType) -> None: ... - def set_columns(self, col_names: list[str]) -> None: ... - def set_source(self, src: SourceInfo) -> None: ... - @staticmethod - def builder(source: SourceInfo) -> OrcReaderOptionsBuilder: ... - -class OrcReaderOptionsBuilder: - def use_index(self, use: bool) -> Self: ... - def build(self) -> OrcReaderOptions: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource -def read_orc( - options: OrcReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> TableWithMetadata: ... +__all__ = ['OrcColumnStatistics', 'ParsedOrcStatistics', 'read_orc', 'read_parsed_orc_statistics', 'write_orc', 'is_supported_read_orc', 'is_supported_write_orc', 'OrcReaderOptions', 'OrcReaderOptionsBuilder', 'OrcWriterOptions', 'OrcWriterOptionsBuilder', 'OrcChunkedWriter', 'ChunkedOrcWriterOptions', 'ChunkedOrcWriterOptionsBuilder'] class OrcColumnStatistics: + __hash__ = None + def __init__(self): ... @property - def number_of_values(self) -> int | None: ... + def number_of_values(self): ... @property - def has_null(self) -> bool | None: ... - def __getitem__(self, item: str) -> Any: ... - def __contains__(self, item: str) -> bool: ... - def get[T](self, item: str, default: None | T = None) -> T | None: ... + def has_null(self): ... + def __getitem__(self, item): ... + def __contains__(self, item): ... + def get(self, item, default=None): ... class ParsedOrcStatistics: - def __init__(self): ... + """ + Holds column names and parsed file-level and stripe-level statistics. + + For details, see :cpp:class:`cudf::io::parsed_orc_statistics` + """ + __hash__ = None + @property - def column_names(self) -> list[str]: ... + def column_names(self): ... @property - def file_stats(self) -> list[OrcColumnStatistics]: ... + def file_stats(self): ... @property - def stripes_stats(self) -> list[OrcColumnStatistics]: ... + def stripes_stats(self): ... + +class OrcReaderOptions: + """ + The settings to use for ``read_orc`` + + For details, see :cpp:class:`cudf::io::orc_reader_options` + """ + @staticmethod + def builder(source: SourceInfo): + """ + Create a OrcReaderOptionsBuilder object + + For details, see :cpp:func:`cudf::io::orc_reader_options::builder` + + Parameters + ---------- + sink : SourceInfo + The source to read the ORC file from. + + Returns + ------- + OrcReaderOptionsBuilder + Builder to build OrcReaderOptions + """ + def set_num_rows(self, nrows: int) -> None: + """ + Sets number of row to read. + + Parameters + ---------- + nrows: int64_t + Number of rows + + Returns + ------- + None + """ + def set_skip_rows(self, skip_rows: int) -> None: + """ + Sets number of rows to skip from the start. + + Parameters + ---------- + skip_rows: int64_t + Number of rows + + Returns + ------- + None + """ + def set_stripes(self, stripes: list) -> None: + """ + Sets list of stripes to read for each input source. + + Parameters + ---------- + stripes: list[list[size_type]] + List of lists, mapping stripes to read to input sources + + Returns + ------- + None + """ + def set_decimal128_columns(self, val: list) -> None: + """ + Set columns that should be read as 128-bit Decimal. + + Parameters + ---------- + val: list[str] + List of fully qualified column names + + Returns + ------- + None + """ + def set_timestamp_type(self, type_: DataType) -> None: + """ + Sets timestamp type to which timestamp column will be cast. -def read_parsed_orc_statistics( - source_info: SourceInfo, - stream: CudaStreamLike | None = None, -) -> ParsedOrcStatistics: ... + Parameters + ---------- + type_: DataType + Type of timestamp + + Returns + ------- + None + """ + def set_columns(self, col_names: list) -> None: + """ + Sets names of the column to read. + + Parameters + ---------- + col_names: list[str] + List of column names + + Returns + ------- + None + """ + def set_source(self, src: SourceInfo) -> None: + """ + Set a new source info location. + + Parameters + ---------- + src : SourceInfo + New source information, replacing existing information. + + Returns + ------- + None + """ + +class OrcReaderOptionsBuilder: + def use_index(self, use: bool) -> OrcReaderOptionsBuilder: + """ + Enable/Disable use of row index to speed-up reading. + + Parameters + ---------- + use : bool + Boolean value to enable/disable row index use + + Returns + ------- + OrcReaderOptionsBuilder + """ + def build(self) -> OrcReaderOptions: + """Create a OrcReaderOptions object""" class OrcWriterOptions: - def __init__(self): ... - def set_stripe_size_bytes(self, size_bytes: int) -> None: ... - def set_stripe_size_rows(self, size_rows: int) -> None: ... - def set_row_index_stride(self, stride: int) -> None: ... + def set_stripe_size_bytes(self, size_bytes: int) -> None: + """ + Sets the maximum stripe size, in bytes. + + For details, see :cpp:func:`cudf::io::orc_writer_options::set_stripe_size_bytes` + + Parameters + ---------- + size_bytes: size_t + Sets the maximum stripe size, in bytes. + + Returns + ------- + None + """ + def set_stripe_size_rows(self, size_rows: size_type) -> None: + """ + Sets the maximum stripe size, in rows. + + If the stripe size is smaller that the row group size, + row group size will be reduced to math the stripe size. + + For details, see :cpp:func:`cudf::io::orc_writer_options::set_stripe_size_rows` + + Parameters + ---------- + size_bytes: size_type + Maximum stripe size, in rows to be set + + Returns + ------- + None + """ + def set_row_index_stride(self, stride: size_type) -> None: + """ + Sets the row index stride. + + Rounded down to a multiple of 8. + + For details, see :cpp:func:`cudf::io::orc_writer_options::set_row_index_stride` + + Parameters + ---------- + size_bytes: size_type + Maximum stripe size, in rows to be set + + Returns + ------- + None + """ @staticmethod - def builder(sink: SinkInfo, table: Table) -> OrcWriterOptionsBuilder: ... + def builder(sink: SinkInfo, table: Table): + """ + Create builder to create OrcWriterOptions. + + For details, see :cpp:func:`cudf::io::orc_writer_options::builder` + + Parameters + ---------- + sink: SinkInfo + The sink used for writer output + table: Table + Table to be written to output + + Returns + ------- + OrcWriterOptionsBuilder + """ class OrcWriterOptionsBuilder: - def __init__(self): ... - def compression(self, comp: CompressionType) -> Self: ... - def enable_statistics(self, val: StatisticsFreq) -> Self: ... - def key_value_metadata(self, kvm: dict[str, str]) -> Self: ... - def metadata(self, meta: TableInputMetadata) -> Self: ... - def build(self) -> OrcWriterOptions: ... - -def write_orc( - options: OrcWriterOptions, stream: CudaStreamLike | None = None -) -> None: ... -def is_supported_read_orc(compression: CompressionType) -> bool: ... -def is_supported_write_orc(compression: CompressionType) -> bool: ... + def compression(self, comp: compression_type) -> OrcWriterOptionsBuilder: + """ + Sets compression type. + + For details, see :cpp:func:`cudf::io::orc_writer_options_builder::compression` + + Parameters + ---------- + comp: CompressionType + The compression type to use + + Returns + ------- + OrcWriterOptionsBuilder + """ + def enable_statistics(self, val: statistics_freq) -> OrcWriterOptionsBuilder: + """ + Choose granularity of column statistics to be written. + + For details, see :cpp:func:`enable_statistics` + + Parameters + ---------- + val: StatisticsFreq + Level of statistics collection + + Returns + ------- + OrcWriterOptionsBuilder + """ + def key_value_metadata(self, kvm: dict) -> OrcWriterOptionsBuilder: + """ + Sets Key-Value footer metadata. + + Parameters + ---------- + kvm: dict + Key-Value footer metadata + + Returns + ------- + OrcWriterOptionsBuilder + """ + def metadata(self, meta: TableInputMetadata) -> OrcWriterOptionsBuilder: + """ + Sets associated metadata. + + For details, see :cpp:func:`cudf::io::orc_writer_options_builder::metadata` + + Parameters + ---------- + meta: TableInputMetadata + Associated metadata + + Returns + ------- + OrcWriterOptionsBuilder + """ + def build(self) -> OrcWriterOptions: + """Moves the ORC writer options builder""" class OrcChunkedWriter: - def __init__(self): ... - def close(self) -> None: ... - def write(self, table: Table) -> None: ... + def close(self) -> None: + """ + Closes the chunked ORC writer. + + Returns + ------- + None + """ + def write(self, table: Table) -> None: + """ + Writes table to output. + + Parameters + ---------- + table: Table + able that needs to be written + + Returns + ------- + None + """ @staticmethod - def from_options( - options: ChunkedOrcWriterOptions, stream: CudaStreamLike | None = None - ) -> OrcChunkedWriter: ... + def from_options(options: ChunkedOrcWriterOptions, stream: object | None=None): + """ + Creates a chunked ORC writer from options + + Parameters + ---------- + options: ChunkedOrcWriterOptions + Settings for controlling writing behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + + Returns + ------- + OrcChunkedWriter + """ class ChunkedOrcWriterOptions: - def __init__(self): ... - def set_stripe_size_bytes(self, size_bytes: int) -> None: ... - def set_stripe_size_rows(self, size_rows: int) -> None: ... - def set_row_index_stride(self, stride: int) -> None: ... + def set_stripe_size_bytes(self, size_bytes: int) -> None: + """ + Sets the maximum stripe size, in bytes. + + Parameters + ---------- + size_bytes: size_t + Sets the maximum stripe size, in bytes. + + Returns + ------- + None + """ + def set_stripe_size_rows(self, size_rows: size_type) -> None: + """ + Sets the maximum stripe size, in rows. + + If the stripe size is smaller that the row group size, + row group size will be reduced to math the stripe size. + + Parameters + ---------- + size_bytes: size_type + Maximum stripe size, in rows to be set + + Returns + ------- + None + """ + def set_row_index_stride(self, stride: size_type) -> None: + """ + Sets the row index stride. + + Rounded down to a multiple of 8. + + Parameters + ---------- + size_bytes: size_type + Maximum stripe size, in rows to be set + + Returns + ------- + None + """ @staticmethod - def builder(sink: SinkInfo) -> ChunkedOrcWriterOptionsBuilder: ... + def builder(sink: SinkInfo): + """ + Create builder to create ChunkedOrcWriterOptions. + + Parameters + ---------- + sink: SinkInfo + The sink used for writer output + table: Table + Table to be written to output + + Returns + ------- + ChunkedOrcWriterOptionsBuilder + """ class ChunkedOrcWriterOptionsBuilder: - def __init__(self): ... - def compression(self, comp: CompressionType) -> Self: ... - def enable_statistics(self, val: StatisticsFreq) -> Self: ... - def key_value_metadata(self, kvm: dict[str, str]) -> Self: ... - def metadata(self, meta: TableInputMetadata) -> Self: ... - def build(self) -> ChunkedOrcWriterOptions: ... + def compression(self, comp: compression_type) -> ChunkedOrcWriterOptionsBuilder: + """ + Sets compression type. + + Parameters + ---------- + comp: CompressionType + The compression type to use + + Returns + ------- + ChunkedOrcWriterOptionsBuilder + """ + def enable_statistics(self, val: statistics_freq) -> ChunkedOrcWriterOptionsBuilder: + """ + Choose granularity of column statistics to be written. + + Parameters + ---------- + val: StatisticsFreq + Level of statistics collection + + Returns + ------- + ChunkedOrcWriterOptionsBuilder + """ + def key_value_metadata(self, kvm: dict) -> ChunkedOrcWriterOptionsBuilder: + """ + Sets Key-Value footer metadata. + + Parameters + ---------- + kvm: dict + Key-Value footer metadata + + Returns + ------- + ChunkedOrcWriterOptionsBuilder + """ + def metadata(self, meta: TableInputMetadata) -> ChunkedOrcWriterOptionsBuilder: + """ + Sets associated metadata. + + Parameters + ---------- + meta: TableInputMetadata + Associated metadata + + Returns + ------- + ChunkedOrcWriterOptionsBuilder + """ + def build(self) -> ChunkedOrcWriterOptions: + """Create a OrcWriterOptions object""" + +def read_orc(options: OrcReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> TableWithMetadata: + """ + Read from ORC format. + + The source to read from and options are encapsulated + by the `options` object. + + For details, see :cpp:func:`read_orc`. + + Parameters + ---------- + options: OrcReaderOptions + Settings for controlling reading behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned table's device memory. + """ +def read_parsed_orc_statistics(source_info: SourceInfo, stream: object | None=None) -> ParsedOrcStatistics: + """ + Read ORC statistics from a source. + + Parameters + ---------- + source_info : SourceInfo + The source to read statistics from. + stream : Stream | None + CUDA stream used for device memory operations and kernel launches. + + Returns + ------- + ParsedOrcStatistics + The parsed ORC statistics. + """ +def write_orc(options: OrcWriterOptions, stream: object | None=None) -> None: + """ + Write to ORC format. + + The table to write, output paths, and options are encapsulated + by the `options` object. + + For details, see :cpp:func:`write_orc`. + + Parameters + ---------- + options: OrcWriterOptions + Settings for controlling writing behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + + Returns + ------- + None + """ +def is_supported_read_orc(compression: compression_type) -> bool: + """Check if the compression type is supported for reading ORC files. + + For details, see :cpp:func:`is_supported_read_orc`. + + Parameters + ---------- + compression : CompressionType + The compression type to check + + Returns + ------- + bool + True if the compression type is supported for reading ORC files + """ +def is_supported_write_orc(compression: compression_type) -> bool: + """Check if the compression type is supported for writing ORC files. + + For details, see :cpp:func:`is_supported_write_orc`. + + Parameters + ---------- + compression : CompressionType + The compression type to check + + Returns + ------- + bool + True if the compression type is supported for writing ORC files + """ diff --git a/python/pylibcudf/pylibcudf/io/parquet.pyi b/python/pylibcudf/pylibcudf/io/parquet.pyi index 8564b270e583..712e62628b5e 100644 --- a/python/pylibcudf/pylibcudf/io/parquet.pyi +++ b/python/pylibcudf/pylibcudf/io/parquet.pyi @@ -1,150 +1,992 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Mapping, Sequence -from typing import Self - -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/parquet.pyx from pylibcudf.expressions import Expression -from pylibcudf.io.parquet_metadata import FileMetaData -from pylibcudf.io.types import ( - CompressionType, - DictionaryPolicy, - PartitionInfo, - SinkInfo, - SourceInfo, - StatisticsFreq, - TableInputMetadata, - TableWithMetadata, -) +from pylibcudf.io.types import (SinkInfo, SourceInfo, TableInputMetadata, + TableWithMetadata, compression_type, + statistics_freq) +from pylibcudf.libcudf.io.types import dictionary_policy as dictionary_policy_t +from pylibcudf.libcudf.types import size_type, type_id from pylibcudf.table import Table -from pylibcudf.types import TypeId -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['ChunkedParquetReader', 'ChunkedParquetWriterOptions', 'ChunkedParquetWriterOptionsBuilder', 'ParquetChunkedWriter', 'ParquetReaderOptions', 'ParquetReaderOptionsBuilder', 'ParquetWriterOptions', 'ParquetWriterOptionsBuilder', 'is_supported_read_parquet', 'is_supported_write_parquet', 'merge_row_group_metadata', 'read_parquet', 'write_parquet'] class ParquetReaderOptions: - def __init__(self): ... - def set_row_groups(self, row_groups: list[list[int]]): ... - def set_num_rows(self, nrows: int): ... - def set_skip_rows(self, skip_rows: int): ... - def set_columns(self, col_names: list[str]): ... - def set_column_names(self, col_names: list[str]): ... - def set_column_indices(self, col_indices: list[int]): ... - def set_column_field_ids(self, column_field_ids: list[int]): ... - def set_filter(self, filter: Expression): ... - def set_source(self, src: SourceInfo) -> None: ... - def is_enabled_use_jit_filter(self) -> bool: ... - def enable_case_sensitive_names(self, val: bool) -> None: ... - def is_enabled_case_sensitive_names(self) -> bool: ... + """The settings to use for ``read_parquet`` + For details, see :cpp:class:`cudf::io::parquet_reader_options` + """ @staticmethod - def builder(source: SourceInfo) -> ParquetReaderOptionsBuilder: ... + def builder(source: SourceInfo): + """ + Create a ParquetReaderOptionsBuilder object + + For details, see :cpp:func:`cudf::io::parquet_reader_options::builder` + + Parameters + ---------- + sink : SourceInfo + The source to read the Parquet file from. + + Returns + ------- + ParquetReaderOptionsBuilder + Builder to build ParquetReaderOptions + """ + def set_row_groups(self, row_groups: list) -> None: + """ + Sets list of individual row groups to read. + + Parameters + ---------- + row_groups : list[list[int]] + Row groups to read, one inner list per input source. + + Notes + ----- + Rows are emitted in input-source order; all rows selected from + source 0 are emitted before rows selected from source 1, and so on. + Within each source, row groups are read in the order provided; + indices are not sorted or deduplicated, and repeated indices are + emitted multiple times. Empty inner lists contribute no rows. + When unset, all row groups are read in source order, then in + on-disk order within each source. Predicate pushdown drops row + groups in place; remaining row groups keep their relative order. + + Returns + ------- + None + """ + def set_num_rows(self, nrows: int) -> None: + """ + Sets number of rows to read. + + Parameters + ---------- + nrows : int64_t + Number of rows to read after skip + + Notes + ----- + Although this allows one to request more than `size_type::max()` + rows, if any single read would produce a table larger than this row + limit, an error is thrown. + + Returns + ------- + None + """ + def set_skip_rows(self, skip_rows: int) -> None: + """ + Sets number of rows to skip. + + Parameters + ---------- + skip_rows : int64_t + Number of rows to skip from start + + Returns + ------- + None + """ + def set_columns(self, col_names: list) -> None: + """ + Sets names of the columns to be read. Deprecated and will be + removed in a future version. Use set_column_names instead. + + Parameters + ---------- + col_names : list + List of column names + + Returns + ------- + None + """ + def set_column_names(self, col_names: list) -> None: + """ + Sets names of the columns to be read. + + Parameters + ---------- + col_names : list + List of column names + + Returns + ------- + None + """ + def set_column_indices(self, col_indices: list) -> None: + """ + Sets indices of the top-level columns to be read. + + Parameters + ---------- + col_indices : list + List of top-level column indices + + Returns + ------- + None + """ + def set_column_field_ids(self, column_field_ids: list) -> None: + """ + Sets Parquet field IDs of the columns/fields to be read. + + Parameters + ---------- + column_field_ids : list + List of Parquet field IDs + + Returns + ------- + None + """ + def set_filter(self, filter: Expression) -> None: + """ + Sets AST based filter for predicate pushdown. + + Parameters + ---------- + filter : Expression + AST expression to use as filter + + Returns + ------- + None + """ + def set_source(self, src: SourceInfo) -> None: + """ + Set a new source info location. + + Parameters + ---------- + src : SourceInfo + New source information, replacing existing information. + + Returns + ------- + None + """ + def is_enabled_use_jit_filter(self) -> bool: + """Returns whether to use JIT compilation for filtering.""" + def enable_case_sensitive_names(self, val: bool) -> None: + """ + Sets whether column names are matched case-sensitively. + + Parameters + ---------- + val : bool + Enables case-sensitive matching + + Returns + ------- + None + """ + def is_enabled_case_sensitive_names(self) -> bool: + """ + Returns whether column name matching is case sensitive. + + Returns + ------- + bool + Whether column names are matched case-sensitively + """ class ParquetReaderOptionsBuilder: - def __init__(self): ... - def convert_strings_to_categories(self, val: bool) -> Self: ... - def use_pandas_metadata(self, val: bool) -> Self: ... - def allow_mismatched_pq_schemas(self, val: bool) -> Self: ... - def ignore_missing_columns(self, val: bool) -> Self: ... - def use_arrow_schema(self, val: bool) -> Self: ... - def columns(self, col_names: list[str]) -> Self: ... - def column_names(self, col_names: list[str]) -> Self: ... - def column_indices(self, col_indices: list[int]) -> Self: ... - def column_field_ids(self, column_field_ids: list[int]) -> Self: ... - def use_jit_filter(self, use_jit_filter: bool) -> Self: ... - def case_sensitive_names(self, val: bool) -> Self: ... - def decimal_width(self, width: TypeId) -> Self: ... - def build(self) -> ParquetReaderOptions: ... + def convert_strings_to_categories(self, val: bool) -> ParquetReaderOptionsBuilder: + """ + Sets enable/disable conversion of strings to categories. + + Parameters + ---------- + val : bool + Boolean value to enable/disable conversion of string columns to categories + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def use_pandas_metadata(self, val: bool) -> ParquetReaderOptionsBuilder: + """ + Sets to enable/disable use of pandas metadata to read. + + Parameters + ---------- + val : bool + Boolean value whether to use pandas metadata + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def allow_mismatched_pq_schemas(self, val: bool) -> ParquetReaderOptionsBuilder: + """ + Sets to enable/disable reading of matching projected and filter + columns from mismatched Parquet sources. + + Parameters + ---------- + val : bool + Boolean value whether to read matching projected and filter + columns from mismatched Parquet sources. + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def ignore_missing_columns(self, val: bool) -> ParquetReaderOptionsBuilder: + """ + Sets to enable/disable ignoring of non-existent projected columns while reading. + + Parameters + ---------- + val : bool + Boolean indicating whether to ignore non-existent projected columns + while reading. + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def use_arrow_schema(self, val: bool) -> ParquetReaderOptionsBuilder: + """ + Sets to enable/disable use of arrow schema to read. + + Parameters + ---------- + val : bool + Boolean value whether to use arrow schema + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def filter(self, filter: Expression) -> ParquetReaderOptionsBuilder: + """ + Sets AST based filter for predicate pushdown. + + Parameters + ---------- + filter : Expression + AST expression to use as filter + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def columns(self, col_names: list) -> ParquetReaderOptionsBuilder: + """ + Sets names of the columns to be read. Deprecated and will be + removed in a future version. Use column_names instead. + + Parameters + ---------- + col_names : list[str] + List of column names + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def column_names(self, col_names: list) -> ParquetReaderOptionsBuilder: + """ + Sets names of the columns to be read. + + Parameters + ---------- + col_names : list[str] + List of column names + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def column_indices(self, col_indices: list) -> ParquetReaderOptionsBuilder: + """ + Sets indices of the top-level columns to be read. + + Parameters + ---------- + col_indices : list[int] + List of top-level column indices + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def column_field_ids(self, column_field_ids: list) -> ParquetReaderOptionsBuilder: + """ + Sets Parquet field IDs of the columns/fields to be read. + + Parameters + ---------- + column_field_ids : list[int] + List of Parquet field IDs + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def use_jit_filter(self, use_jit_filter: bool) -> ParquetReaderOptionsBuilder: + """ + Sets whether to use JIT compilation for filtering. + + Parameters + ---------- + use_jit_filter : bool + Boolean value whether to use JIT filter + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def case_sensitive_names(self, val: bool) -> ParquetReaderOptionsBuilder: + """ + Sets whether column name matching is case sensitive. + + Parameters + ---------- + val : bool + ``True`` to enable case-sensitive matching (default), + ``False`` for case-insensitive matching. + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def decimal_width(self, width: type_id) -> ParquetReaderOptionsBuilder: + """ + Sets the decimal width used to cast all decimal columns. + + Parameters + ---------- + width : TypeId + The decimal type_id (DECIMAL32, DECIMAL64, or DECIMAL128) to which + all decimal columns should be cast. + + Returns + ------- + ParquetReaderOptionsBuilder + """ + def build(self): + """Create a ParquetReaderOptions object""" class ChunkedParquetReader: - def __init__( - self, - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - chunk_read_limit: int = 0, - pass_read_limit: int = 1024000000, - parquet_metadatas: Sequence[FileMetaData] | None = None, - ) -> None: ... - def has_next(self) -> bool: ... - def read_chunk(self) -> TableWithMetadata: ... - -def read_parquet( - options: ParquetReaderOptions, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - parquet_metadatas: Sequence[FileMetaData] | None = None, -) -> TableWithMetadata: ... + """ + Reads chunks of a Parquet file into a :py:class:`~.types.TableWithMetadata`. -class ParquetWriterOptions: - def __init__(self): ... - @staticmethod - def builder( - sink: SinkInfo, table: Table - ) -> ParquetWriterOptionsBuilder: ... - def set_partitions(self, partitions: list[PartitionInfo]) -> None: ... - def set_column_chunks_file_paths( - self, file_paths: Sequence[str] - ) -> None: ... - def set_row_group_size_bytes(self, size_bytes: int) -> None: ... - def set_row_group_size_rows(self, size_rows: int) -> None: ... - def set_max_page_size_bytes(self, size_bytes: int) -> None: ... - def set_max_page_size_rows(self, size_rows: int) -> None: ... - def set_max_dictionary_size(self, size_bytes: int) -> None: ... + For details, see :cpp:class:`chunked_parquet_reader`. -class ParquetWriterOptionsBuilder: - def __init__(self): ... - def metadata(self, metadata: TableInputMetadata) -> Self: ... - def key_value_metadata( - self, metadata: Sequence[Mapping[str, str]] - ) -> Self: ... - def compression(self, compression: CompressionType) -> Self: ... - def stats_level(self, sf: StatisticsFreq) -> Self: ... - def int96_timestamps(self, enabled: bool) -> Self: ... - def write_v2_headers(self, enabled: bool) -> Self: ... - def page_level_compression(self, enabled: bool) -> Self: ... - def dictionary_policy(self, val: DictionaryPolicy) -> Self: ... - def utc_timestamps(self, enabled: bool) -> Self: ... - def write_arrow_schema(self, enabled: bool) -> Self: ... - def row_group_size_rows(self, val: int) -> Self: ... - def max_page_size_bytes(self, val: int) -> Self: ... - def build(self) -> ParquetWriterOptions: ... - -def write_parquet( - options: ParquetWriterOptions, stream: CudaStreamLike | None = None -) -> memoryview: ... -def is_supported_read_parquet(compression: CompressionType) -> bool: ... -def is_supported_write_parquet(compression: CompressionType) -> bool: ... + Parameters + ---------- + options : ParquetReaderOptions + Settings for controlling reading behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned table's device memory. + chunk_read_limit : size_t, default 0 + Limit on total number of bytes to be returned per read, + or 0 if there is no limit. + pass_read_limit : size_t, default 1024000000 + Limit on the amount of memory used for reading and decompressing data + or 0 if there is no limit. + parquet_metadatas : list[FileMetaData], optional + Pre-materialized parquet footer metadata, one for each source. If not + provided, footers are read from the sources internally. + """ + __hash__ = None + + def __init__(self, options: ParquetReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None, chunk_read_limit: int=0, pass_read_limit: int=1024000000, parquet_metadatas: object | None=None): ... + def has_next(self) -> bool: + """ + Returns True if there is another chunk in the Parquet file + to be read. + + Returns + ------- + True if we have not finished reading the file. + """ + def read_chunk(self, mr: DeviceMemoryResource | None=None) -> TableWithMetadata: + """ + Read the next chunk into a :py:class:`~.types.TableWithMetadata` + + Parameters + ---------- + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + TableWithMetadata + The Table and its corresponding metadata (column names) that were read in. + """ class ChunkedParquetWriter: - def __init__(self): ... - def close(self, metadata_file_path: list) -> memoryview: ... - def write(self, table: Table, partitions_info: object = None) -> None: ... + def close(self, metadata_file_path: list) -> memoryview: + """ + Closes the chunked Parquet writer. + + Parameters + ---------- + metadata_file_path: list + Column chunks file path to be set in the raw output metadata + + Returns + ------- + None + """ + def write(self, table: Table, partitions_info: object | None=None) -> None: + """ + Writes table to output. + + Parameters + ---------- + table: Table + Table that needs to be written + partitions_info: object, default None + Optional partitions to divide the table into. + If specified, must be same size as number of sinks. + + Returns + ------- + None + """ @staticmethod - def from_options( - options: ChunkedParquetWriterOptions, - stream: CudaStreamLike | None = None, - ) -> ChunkedParquetWriter: ... + def from_options(options: ChunkedParquetWriterOptions, stream: object | None=None): + """ + Creates a chunked Parquet writer from options + + Parameters + ---------- + options: ChunkedParquetWriterOptions + Settings for controlling writing behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + + Returns + ------- + ChunkedParquetWriter + """ class ChunkedParquetWriterOptions: - def __init__(self): ... - def set_dictionary_policy(self, policy: DictionaryPolicy) -> None: ... @staticmethod - def builder(sink: SinkInfo) -> ChunkedParquetWriterOptionsBuilder: ... + def builder(sink: SinkInfo): + """ + Create builder to create ChunkedParquetWriterOptions. + + Parameters + ---------- + sink: SinkInfo + The sink used for writer output + + Returns + ------- + ChunkedParquetWriterOptionsBuilder + """ + def set_dictionary_policy(self, policy: dictionary_policy_t) -> None: + """ + Sets the policy for dictionary use. + + Parameters + ---------- + policy : DictionaryPolicy + Policy for dictionary use + + Returns + ------- + None + """ class ChunkedParquetWriterOptionsBuilder: - def __init__(self): ... - def metadata(self, metadata: TableInputMetadata) -> Self: ... - def key_value_metadata( - self, metadata: Sequence[Mapping[str, str]] - ) -> Self: ... - def compression(self, compression: CompressionType) -> Self: ... - def stats_level(self, sf: StatisticsFreq) -> Self: ... - def row_group_size_bytes(self, val: int) -> Self: ... - def row_group_size_rows(self, val: int) -> Self: ... - def max_page_size_bytes(self, val: int) -> Self: ... - def max_page_size_rows(self, val: int) -> Self: ... - def max_dictionary_size(self, val: int) -> Self: ... - def write_arrow_schema(self, enabled: bool) -> Self: ... - def build(self) -> ChunkedParquetWriterOptions: ... - -def merge_row_group_metadata(metdata_list: list) -> memoryview: ... + def metadata(self, metadata: TableInputMetadata) -> ChunkedParquetWriterOptionsBuilder: ... + def key_value_metadata(self, metadata) -> ChunkedParquetWriterOptionsBuilder: + """ + Sets Key-Value footer metadata. + + Parameters + ---------- + metadata : list[dict[str, str]] + Key-Value footer metadata + + Returns + ------- + Self + """ + def compression(self, compression: compression_type) -> ChunkedParquetWriterOptionsBuilder: + """ + Sets compression type. + + Parameters + ---------- + compression : CompressionType + The compression type to use + + Returns + ------- + Self + """ + def stats_level(self, sf: statistics_freq) -> ChunkedParquetWriterOptionsBuilder: + """ + Sets the level of statistics. + + Parameters + ---------- + sf : StatisticsFreq + Level of statistics requested in the output file + + Returns + ------- + Self + """ + def row_group_size_bytes(self, val: int) -> ChunkedParquetWriterOptionsBuilder: + """ + Sets the maximum row group size, in bytes. + + Parameters + ---------- + val : size_t + Maximum row group size, in bytes to set + + Returns + ------- + Self + """ + def row_group_size_rows(self, val: size_type) -> ChunkedParquetWriterOptionsBuilder: + """ + Sets the maximum row group size, in rows. + + Parameters + ---------- + val : size_type + Maximum row group size, in rows to set + + Returns + ------- + Self + """ + def max_page_size_bytes(self, val: int) -> ChunkedParquetWriterOptionsBuilder: + """ + Sets the maximum uncompressed page size, in bytes. + + Parameters + ---------- + val : size_t + Maximum uncompressed page size, in bytes to set + + Returns + ------- + Self + """ + def max_page_size_rows(self, val: size_type) -> ChunkedParquetWriterOptionsBuilder: + """ + Sets the maximum page size, in rows. + + Parameters + ---------- + val : size_type + Maximum page size, in rows to set. + + Returns + ------- + Self + """ + def max_dictionary_size(self, val: int) -> ChunkedParquetWriterOptionsBuilder: + """ + Sets the maximum dictionary size, in bytes. + + Parameters + ---------- + val : size_t + Sets the maximum dictionary size, in bytes. + + Returns + ------- + Self + """ + def write_arrow_schema(self, enabled: bool) -> ChunkedParquetWriterOptionsBuilder: + """ + Set to true if arrow schema is to be written. + + Parameters + ---------- + enabled : bool + Boolean value to enable/disable writing of arrow schema. + + Returns + ------- + Self + """ + def build(self) -> ChunkedParquetWriterOptions: + """Create a ChunkedParquetWriterOptions object""" + +class ParquetWriterOptions: + @staticmethod + def builder(sink: SinkInfo, table: Table): + """ + Create builder to create ParquetWriterOptionsBuilder. + + Parameters + ---------- + sink : SinkInfo + The sink used for writer output + + table : Table + Table to be written to output + + Returns + ------- + ParquetWriterOptionsBuilder + """ + def set_partitions(self, partitions: list) -> None: + """ + Sets partitions. + + Parameters + ---------- + partitions : list[Partitions] + Partitions of input table in {start_row, num_rows} pairs. + + Returns + ------- + None + """ + def set_column_chunks_file_paths(self, file_paths) -> None: + """ + Sets column chunks file path to be set in the raw output metadata. + + Parameters + ---------- + file_paths : list[str] + Vector of strings which indicate file paths. + + Returns + ------- + None + """ + def set_row_group_size_bytes(self, size_bytes: int) -> None: + """ + Sets the maximum row group size, in bytes. + + Parameters + ---------- + size_bytes : int + Maximum row group size, in bytes to set + + Returns + ------- + None + """ + def set_row_group_size_rows(self, size_rows: size_type) -> None: + """ + Sets the maximum row group size, in rows. + + Parameters + ---------- + size_rows : int + Maximum row group size, in rows to set + + Returns + ------- + None + """ + def set_max_page_size_bytes(self, size_bytes: int) -> None: + """ + Sets the maximum uncompressed page size, in bytes. + + Parameters + ---------- + size_bytes : int + Maximum uncompressed page size, in bytes to set + + Returns + ------- + None + """ + def set_max_page_size_rows(self, size_rows: size_type) -> None: + """ + Sets the maximum page size, in rows. + + Parameters + ---------- + size_rows : int + Maximum page size, in rows to set. + + Returns + ------- + None + """ + def set_max_dictionary_size(self, size_bytes: int) -> None: + """ + Sets the maximum dictionary size, in bytes. + + Parameters + ---------- + size_bytes : int + Sets the maximum dictionary size, in bytes. + + Returns + ------- + None + """ + +class ParquetWriterOptionsBuilder: + def metadata(self, metadata: TableInputMetadata) -> ParquetWriterOptionsBuilder: + """ + Sets metadata. + + Parameters + ---------- + metadata : TableInputMetadata + Associated metadata + + Returns + ------- + Self + """ + def key_value_metadata(self, metadata) -> ParquetWriterOptionsBuilder: + """ + Sets Key-Value footer metadata. + + Parameters + ---------- + metadata : list[dict[str, str]] + Key-Value footer metadata + + Returns + ------- + Self + """ + def compression(self, compression: compression_type) -> ParquetWriterOptionsBuilder: + """ + Sets compression type. + + Parameters + ---------- + compression : CompressionType + The compression type to use + + Returns + ------- + Self + """ + def stats_level(self, sf: statistics_freq) -> ParquetWriterOptionsBuilder: + """ + Sets the level of statistics. + + Parameters + ---------- + sf : StatisticsFreq + Level of statistics requested in the output file + + Returns + ------- + Self + """ + def int96_timestamps(self, enabled: bool) -> ParquetWriterOptionsBuilder: + """ + Sets whether timestamps are written as int96 or timestamp micros. + + Parameters + ---------- + enabled : bool + Boolean value to enable/disable int96 timestamps + + Returns + ------- + Self + """ + def write_v2_headers(self, enabled: bool) -> ParquetWriterOptionsBuilder: + """ + Set to true to write V2 page headers, otherwise false to write V1 page headers. + + Parameters + ---------- + enabled : bool + Boolean value to enable/disable writing of V2 page headers. + + Returns + ------- + Self + """ + def page_level_compression(self, enabled: bool) -> ParquetWriterOptionsBuilder: + """ + Set to true to enable per-page compression decisions for V2 data pages. + + When enabled, each V2 data page independently decides whether to compress + based on compression ratio. When disabled (default), all V2 data pages + in a chunk follow the same compression decision as dictionary pages. + + Parameters + ---------- + enabled : bool + Boolean value to enable/disable per-page compression decisions. + + Returns + ------- + Self + """ + def dictionary_policy(self, val: dictionary_policy_t) -> ParquetWriterOptionsBuilder: + """ + Sets the policy for dictionary use. + + Parameters + ---------- + val : DictionaryPolicy + Policy for dictionary use. + + Returns + ------- + Self + """ + def utc_timestamps(self, enabled: bool) -> ParquetWriterOptionsBuilder: + """ + Set to true if timestamps are to be written as UTC. + + Parameters + ---------- + enabled : bool + Boolean value to enable/disable writing of timestamps as UTC. + + Returns + ------- + Self + """ + def write_arrow_schema(self, enabled: bool) -> ParquetWriterOptionsBuilder: + """ + Set to true if arrow schema is to be written. + + Parameters + ---------- + enabled : bool + Boolean value to enable/disable writing of arrow schema. + + Returns + ------- + Self + """ + def row_group_size_rows(self, val: size_type) -> ParquetWriterOptionsBuilder: + """ + Sets the maximum row group size, in rows. + + Parameters + ---------- + val : size_type + Maximum row group size, in rows to set + + Returns + ------- + Self + """ + def max_page_size_bytes(self, val: int) -> ParquetWriterOptionsBuilder: + """ + Sets the maximum uncompressed page size, in bytes. + + Parameters + ---------- + val : size_t + Maximum uncompressed page size, in bytes to set + + Returns + ------- + Self + """ + def build(self) -> ParquetWriterOptions: + """ + Create a ParquetWriterOptions from the set options. + + Returns + ------- + ParquetWriterOptions + """ + +def _warn_deprecated(api_name, new_api): ... +def read_parquet(options: ParquetReaderOptions, stream: object | None=None, mr: DeviceMemoryResource | None=None, parquet_metadatas: object | None=None): + """ + Read from Parquet format. + + The source to read from and options are encapsulated + by the `options` object. + + For details, see :cpp:func:`read_parquet`. + + Parameters + ---------- + options: ParquetReaderOptions + Settings for controlling reading behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned table's device memory. + parquet_metadatas : list[FileMetaData], optional + Pre-materialized parquet footer metadata, one for each source. If not + provided, footers are read from the sources internally. + """ +def write_parquet(options: ParquetWriterOptions, stream: object | None=None) -> memoryview: + """ + Writes a set of columns to parquet format. + + Parameters + ---------- + options : ParquetWriterOptions + Settings for controlling writing behavior + stream : Stream | None + CUDA stream used for device memory operations and kernel launches + + Returns + ------- + memoryview + A blob that contains the file metadata + (parquet FileMetadata thrift message) if requested in + parquet_writer_options (empty blob otherwise). + """ +def is_supported_read_parquet(compression: compression_type) -> bool: + """Check if the compression type is supported for reading Parquet files. + + For details, see :cpp:func:`is_supported_read_parquet`. + + Parameters + ---------- + compression : CompressionType + The compression type to check + + Returns + ------- + bool + True if the compression type is supported for reading Parquet files + """ +def is_supported_write_parquet(compression: compression_type) -> bool: + """Check if the compression type is supported for writing Parquet files. + + For details, see :cpp:func:`is_supported_write_parquet`. + + Parameters + ---------- + compression : CompressionType + The compression type to check + + Returns + ------- + bool + True if the compression type is supported for writing Parquet files + """ +def merge_row_group_metadata(metdata_list: list) -> memoryview: + """ + Merges multiple raw metadata blobs that were previously + created by write_parquet into a single metadata blob. + + For details, see :cpp:func:`merge_row_group_metadata`. + + Parameters + ---------- + metdata_list : list + List of input file metadata + + Returns + ------- + memoryview + A parquet-compatible blob that contains the data for all row groups in the list + """ diff --git a/python/pylibcudf/pylibcudf/io/parquet_metadata.pyi b/python/pylibcudf/pylibcudf/io/parquet_metadata.pyi index 6aa9efb19713..f2b17cd0f472 100644 --- a/python/pylibcudf/pylibcudf/io/parquet_metadata.pyi +++ b/python/pylibcudf/pylibcudf/io/parquet_metadata.pyi @@ -1,113 +1,379 @@ # SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/parquet_metadata.pyx + from pylibcudf.io.types import SourceInfo from pylibcudf.types import DataType -try: - from collections.abc import Buffer -except ImportError: - from typing_extensions import Buffer - -__all__ = [ - "ColumnChunk", - "ColumnChunkMetaData", - "FileMetaData", - "ParquetColumnSchema", - "ParquetMetadata", - "ParquetSchema", - "RowGroup", - "SortingColumn", - "read_parquet_footers", - "read_parquet_metadata", -] +const_unique_ptr_datasource = ... +__all__ = ['ColumnChunk', 'ColumnChunkMetaData', 'FileMetaData', 'ParquetColumnSchema', 'ParquetMetadata', 'ParquetSchema', 'RowGroup', 'SortingColumn', 'read_parquet_footers', 'read_parquet_metadata'] class ParquetColumnSchema: - def name(self) -> str: ... - def num_children(self) -> int: ... - def child(self, idx: int) -> ParquetColumnSchema: ... - def children(self) -> list[ParquetColumnSchema]: ... + """ + Schema of a parquet column, including the nested columns. + + Parameters + ---------- + parquet_column_schema + """ + def __init__(self): ... + def name(self) -> str: + """ + Returns parquet column name; can be empty. + + Returns + ------- + str + Column name + """ + def num_children(self) -> int: + """ + Returns the number of child columns. + + Returns + ------- + int + Children count + """ + def child(self, idx: int) -> ParquetColumnSchema: + """ + Returns schema of the child with the given index. + + Parameters + ---------- + idx : int + Child Index + + Returns + ------- + ParquetColumnSchema + Child schema + """ + def children(self) -> list: + """ + Returns schemas of all child columns. + + Returns + ------- + list[ParquetColumnSchema] + Child schemas. + """ + def cudf_type(self) -> DataType: + """ + Returns the cudf data type for this column. + + This is the resolved cudf data type mapped from the parquet + physical/logical types. + + Returns + ------- + DataType + cudf data type + """ class ParquetSchema: - def root(self) -> ParquetColumnSchema: ... - def column_types(self) -> dict[str, DataType]: ... + """ + Schema of a parquet file. + + Parameters + ---------- + parquet_schema + """ + def __init__(self): ... + def root(self) -> ParquetColumnSchema: + """ + Returns the schema of the struct column that contains all columns as fields. + + Returns + ------- + ParquetColumnSchema + Root column schema + """ + def column_types(self) -> dict: + """ + Returns a dictionary mapping column names to their cudf data types. + + Returns + ------- + dict[str, DataType] + Dictionary mapping column names to DataType objects + """ class ParquetMetadata: - def schema(self) -> ParquetSchema: ... - def num_rows(self) -> int: ... - def num_rowgroups(self) -> int: ... - def num_rowgroups_per_file(self) -> list[int]: ... - def metadata(self) -> dict[str, str]: ... - def rowgroup_metadata(self) -> list[dict[str, int]]: ... - def columnchunk_metadata(self) -> dict[str, list[int]]: ... + """ + Information about content of a parquet file. -class FileMetaData: - @classmethod - def from_bytes(cls, footer_bytes: Buffer) -> FileMetaData: ... - @property - def version(self) -> int: ... - @property - def num_rows(self) -> int: ... - @property - def created_by(self) -> str: ... - @property - def row_groups(self) -> list[RowGroup]: ... - @property - def row_group_num_rows(self) -> list[int]: ... - @property - def columnchunk_metadata(self) -> dict[str, list[int]]: ... + Parameters + ---------- + parquet_metadata + """ + def __init__(self): ... + def schema(self) -> ParquetSchema: + """ + Returns the parquet schema. + + Returns + ------- + ParquetSchema + Parquet schema + """ + def num_rows(self) -> int: + """ + Returns the number of rows of the root column. + + Returns + ------- + int + Number of rows + """ + def num_rowgroups(self) -> int: + """ + Returns the total number of rowgroups in the file. + + Returns + ------- + int + Number of row groups. + """ + def num_rowgroups_per_file(self) -> list: + """ + Returns the number of rowgroups in each file. + """ + def metadata(self) -> dict: + """ + Returns the key-value metadata in the file footer. + + Returns + ------- + dict[str, str] + Key value metadata as a map. + """ + def rowgroup_metadata(self) -> list: + """ + Returns the row group metadata in the file footer. + + Returns + ------- + list[dict[str, int]] + Vector of row group metadata as maps. + """ + def columnchunk_metadata(self) -> dict: + """ + Returns a map of leaf column names to lists of `total_uncompressed_size` + metadata from all column chunks in the file footer. + + Returns + ------- + dict[str, list[int]] + Map of leaf column names to lists of `total_uncompressed_size` metadata + from all their column chunks. + """ class SortingColumn: + """Sort metadata for a row group column.""" + def __init__(self): ... @property - def column_idx(self) -> int: ... + def column_idx(self): + """Column index (within the row group).""" @property - def descending(self) -> bool: ... + def descending(self): + """Whether this column is sorted in descending order.""" @property - def nulls_first(self) -> bool: ... + def nulls_first(self): + """Whether null values are ordered before non-null values.""" class ColumnChunk: + """Metadata for a row group's column chunk.""" + def __init__(self): ... @property - def file_path(self) -> str: ... + def file_path(self): + """Relative file path for this column chunk.""" @property - def file_offset(self) -> int: ... + def file_offset(self): + """Deprecated byte offset to column metadata.""" @property - def offset_index_offset(self) -> int: ... + def offset_index_offset(self): + """File offset of the chunk's OffsetIndex.""" @property - def offset_index_length(self) -> int: ... + def offset_index_length(self): + """Size of the chunk's OffsetIndex, in bytes.""" @property - def column_index_offset(self) -> int: ... + def column_index_offset(self): + """File offset of the chunk's ColumnIndex.""" @property - def column_index_length(self) -> int: ... + def column_index_length(self): + """Size of the chunk's ColumnIndex, in bytes.""" @property - def schema_idx(self) -> int: ... + def schema_idx(self): + """Derived index in the flattened schema.""" @property - def meta_data(self) -> ColumnChunkMetaData: ... + def meta_data(self): + """Column metadata for this chunk.""" class ColumnChunkMetaData: + """Metadata payload for a column chunk.""" + def __init__(self): ... @property - def path_in_schema(self) -> list[str]: ... + def path_in_schema(self): + """Column path components in the flattened schema.""" @property - def num_values(self) -> int: ... + def num_values(self): + """Number of values in this chunk.""" @property - def total_uncompressed_size(self) -> int: ... + def total_uncompressed_size(self): + """Total uncompressed page bytes for this chunk.""" @property - def total_compressed_size(self) -> int: ... + def total_compressed_size(self): + """Total compressed page bytes for this chunk.""" class RowGroup: + """Parquet row group metadata.""" + def __init__(self): ... @property - def columns(self) -> list[ColumnChunk]: ... + def columns(self): + """Column chunk metadata for each column in this row group.""" @property - def total_byte_size(self) -> int: ... + def total_byte_size(self): + """Total uncompressed byte size in this row group.""" @property - def num_rows(self) -> int: ... + def num_rows(self): + """Number of rows in this row group.""" @property - def sorting_columns(self) -> list[SortingColumn] | None: ... + def sorting_columns(self): + """Optional row sort order metadata.""" @property - def file_offset(self) -> int | None: ... + def file_offset(self): + """Optional byte offset to first page in this row group.""" @property - def total_compressed_size(self) -> int | None: ... + def total_compressed_size(self): + """Optional total compressed bytes for this row group.""" @property - def ordinal(self) -> int | None: ... + def ordinal(self): + """Optional row group ordinal within the file.""" + +class FileMetaData: + """Parquet file footer metadata. + + For details, see :cpp:class:`cudf::io::parquet::FileMetaData` + + See Also + -------- + read_parquet_footers + Read one ``FileMetaData`` per source directly from + :class:`pylibcudf.io.types.SourceInfo`. + """ + def __init__(self): ... + @property + def version(self): + """Get the file format version.""" + @property + def num_rows(self): + """Get the total number of rows.""" + @property + def created_by(self): + """Get the application that created the file.""" + @property + def row_groups(self): + """Get row group metadata in this file.""" + @property + def row_group_num_rows(self): + """ + Get row counts for each row group in this file. + + Returns + ------- + list + A list with the row count per row group in this file. + + Notes + ----- + Equivalent to, but faster than, checking each row groups' num_rows: + + .. code-block:: python + + >>> [rg.num_rows for rg in file_metadata.row_groups] + """ + @property + def columnchunk_metadata(self): + """ + Get a map of dotted column paths to lists of + `total_uncompressed_size` values from every column chunk in + this file. + + Returns + ------- + dict[str, list[int]] + Map of dotted column paths (``".".join(path_in_schema)``) + to lists of `total_uncompressed_size` metadata from all + their column chunks. + + Notes + ----- + Equivalent to, but faster than, walking each row group's columns: + + .. code-block:: python + + >>> result: dict[str, list[int]] = {} + >>> for rg in file_metadata.row_groups: + ... for col in rg.columns: + ... name = ".".join(col.meta_data.path_in_schema) + ... result.setdefault(name, []).append( + ... col.meta_data.total_uncompressed_size + ... ) + """ + @classmethod + def from_bytes(cls, footer_bytes: memoryview): + """Build ``FileMetaData`` from parquet footer bytes. + + Parameters + ---------- + footer_bytes : Buffer + A contiguous bytes-like object containing parquet footer bytes. + The bytes are forwarded as-is to + :cpp:class:`cudf::io::parquet::experimental::hybrid_scan_reader` + without Python-side preprocessing. This method does not strip the + parquet footer suffix (4-byte footer length + ``PAR1`` magic), so + callers should generally pass only the footer region bytes. + + Returns + ------- + FileMetaData + Parsed parquet file footer metadata. + """ + +def read_parquet_metadata(src_info: SourceInfo) -> ParquetMetadata: + """ + Reads metadata of parquet dataset. + + Parameters + ---------- + src_info : SourceInfo + Dataset source. + + Returns + ------- + ParquetMetadata + Parquet_metadata with parquet schema, number of rows, + number of row groups and key-value metadata. + + See Also + -------- + read_parquet_footers + To read the pre-materialized file footer metadata used + in :func:`pylibcudf.io.parquet.read_parquet`. + """ +def read_parquet_footers(src_info: SourceInfo) -> list: + """ + Read parquet file footers as ``FileMetaData`` objects. + + Parameters + ---------- + src_info : SourceInfo + Dataset source. -def read_parquet_metadata(src_info: SourceInfo) -> ParquetMetadata: ... -def read_parquet_footers(src_info: SourceInfo) -> list[FileMetaData]: ... + Returns + ------- + list[FileMetaData] + One footer metadata object per input source. + """ diff --git a/python/pylibcudf/pylibcudf/io/text.pyi b/python/pylibcudf/pylibcudf/io/text.pyi index 581e45c3194a..247dcfee2c9d 100644 --- a/python/pylibcudf/pylibcudf/io/text.pyi +++ b/python/pylibcudf/pylibcudf/io/text.pyi @@ -1,40 +1,135 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/text.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['ByteRangeInfo', 'DataChunkSource', 'ParseOptions', 'make_source', 'make_source_from_bgzip_file', 'make_source_from_file', 'multibyte_split'] class ByteRangeInfo: - def __init__(self, offset: int, size: int) -> None: ... + """Information about a byte range in a file. + + For details, see :cpp:class:`cudf::io::text::byte_range_info` + + Parameters + ---------- + offset : int + Offset in bytes from the start of the file + size : int + Size of the range in bytes + """ + def __init__(self, offset: int, size: int): ... @property - def offset(self) -> int: ... + def offset(self): + """Get the offset in bytes.""" @property - def size(self) -> int: ... + def size(self): + """Get the size in bytes.""" class ParseOptions: - def __init__( - self, - *, - byte_range: tuple[int, int] | None = None, - strip_delimiters: bool = False, - ) -> None: ... + """ + Parsing options for `multibyte_split` + + Parameters + ---------- + byte_range : list | tuple, default None + Only rows starting inside this byte range will be + part of the output column. + + strip_delimiters : bool, default True + Whether delimiters at the end of rows should + be stripped from the output column. + """ + def __init__(self, *, byte_range=None, strip_delimiters=False): ... class DataChunkSource: - def __init__(self, data: str) -> None: ... - -def make_source(data: str) -> DataChunkSource: ... -def make_source_from_file(filename: str) -> DataChunkSource: ... -def make_source_from_bgzip_file( - filename: str, - virtual_begin: int = -1, - virtual_end: int = -1, -) -> DataChunkSource: ... -def multibyte_split( - source: DataChunkSource, - delimiter: str, - options: ParseOptions | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + """ + Data source for `multibyte_split` + + Parameters + ---------- + data : str + Filename or data itself. + """ + def __init__(self, data: str): ... + +def make_source(data: str) -> DataChunkSource: + """ + Creates a data source capable of producing device-buffered views + of the given string. + + Parameters + ---------- + data : str + The host data to be exposed as a data chunk source. + + Returns + ------- + DataChunkSource + The data chunk source for the provided host data. + """ +def make_source_from_file(filename: str) -> DataChunkSource: + """ + Creates a data source capable of producing device-buffered views of the file. + + Parameters + ---------- + filename : str + The filename of the file to be exposed as a data chunk source. + + Returns + ------- + DataChunkSource + The data chunk source for the provided filename. + """ +def make_source_from_bgzip_file(filename: str, virtual_begin: int=-1, virtual_end: int=-1) -> DataChunkSource: + """ + Creates a data source capable of producing device-buffered views of + a BGZIP compressed file with virtual record offsets. + + Parameters + ---------- + filename : str + The filename of the BGZIP-compressed file to be exposed as a data chunk source. + + virtual_begin : int + The virtual (Tabix) offset of the first byte to be read. Its upper 48 bits + describe the offset into the compressed file, its lower 16 bits describe the + block-local offset. + + virtual_end : int, default None + The virtual (Tabix) offset one past the last byte to be read + + Returns + ------- + DataChunkSource + The data chunk source for the provided filename. + """ +def multibyte_split(source: DataChunkSource, delimiter: str, options: ParseOptions | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Splits the source text into a strings column using a multiple byte delimiter. + + For details, see :cpp:func:`multibyte_split` + + Parameters + ---------- + source : + The source string. + + delimiter : str + UTF-8 encoded string for which to find offsets in the source. + + options : ParseOptions + The parsing options to use (including byte range). + + stream : Stream, optional + CUDA stream for device memory operations and kernel launches + + Returns + ------- + Column + The strings found by splitting the source by the delimiter + within the relevant byte range. + """ diff --git a/python/pylibcudf/pylibcudf/io/timezone.pyi b/python/pylibcudf/pylibcudf/io/timezone.pyi index f87dda70f703..2bf25a5813ea 100644 --- a/python/pylibcudf/pylibcudf/io/timezone.pyi +++ b/python/pylibcudf/pylibcudf/io/timezone.pyi @@ -1,14 +1,31 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/timezone.pyx + from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike +from ..table import Table + +__all__ = ['make_timezone_transition_table'] + +def make_timezone_transition_table(tzif_dir: str, timezone_name: str, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Creates a transition table to convert ORC timestamps to UTC. + + Parameters + ---------- + tzif_dir : str + The directory where the TZif files are located + timezone_name : str + standard timezone name + stream : Stream, optional + CUDA stream for device memory operations and kernel launches + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned table's device memory -def make_timezone_transition_table( - tzif_dir: str, - timezone_name: str, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... + Returns + ------- + Table + The transition table for the given timezone. + """ diff --git a/python/pylibcudf/pylibcudf/io/types.pyi b/python/pylibcudf/pylibcudf/io/types.pyi index bad1931a4582..4ccd83118e4e 100644 --- a/python/pylibcudf/pylibcudf/io/types.pyi +++ b/python/pylibcudf/pylibcudf/io/types.pyi @@ -1,140 +1,331 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -import io + +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/io/types.pyx + import os -from collections.abc import Mapping, Sequence -from enum import IntEnum -from typing import Any, Literal, Self, TypeAlias, overload -from pylibcudf.column import Column -from pylibcudf.io.datasource import Datasource +from pylibcudf.libcudf.io.json import json_recovery_mode_t as JSONRecoveryMode +from pylibcudf.libcudf.io.types import column_encoding +from pylibcudf.libcudf.io.types import column_encoding as ColumnEncoding +from pylibcudf.libcudf.io.types import compression_type as CompressionType +from pylibcudf.libcudf.io.types import dictionary_policy as DictionaryPolicy +from pylibcudf.libcudf.io.types import quote_style as QuoteStyle +from pylibcudf.libcudf.io.types import statistics_freq as StatisticsFreq +from pylibcudf.libcudf.types import size_type from pylibcudf.table import Table -class JSONRecoveryMode(IntEnum): - FAIL = ... - RECOVER_WITH_NULL = ... - -class CompressionType(IntEnum): - NONE = ... - AUTO = ... - SNAPPY = ... - GZIP = ... - BZIP2 = ... - BROTLI = ... - ZIP = ... - XZ = ... - ZLIB = ... - LZ4 = ... - LZO = ... - ZSTD = ... - -class ColumnEncoding(IntEnum): - USE_DEFAULT = ... - DICTIONARY = ... - PLAIN = ... - DELTA_BINARY_PACKED = ... - DELTA_LENGTH_BYTE_ARRAY = ... - DELTA_BYTE_ARRAY = ... - BYTE_STREAM_SPLIT = ... - DIRECT = ... - DIRECT_V2 = ... - DICTIONARY_V2 = ... - -class DictionaryPolicy(IntEnum): - NEVER = ... - ADAPTIVE = ... - ALWAYS = ... - -class StatisticsFreq(IntEnum): - STATISTICS_NONE = ... - STATISTICS_ROWGROUP = ... - STATISTICS_PAGE = ... - STATISTICS_COLUMN = ... - -class QuoteStyle(IntEnum): - MINIMAL = ... - ALL = ... - NONNUMERIC = ... - NONE = ... - -ColumnNameSpec: TypeAlias = tuple[str, list[ColumnNameSpec]] -ChildNameSpec: TypeAlias = Mapping[str, ChildNameSpec] +__all__ = ['ColumnEncoding', 'ColumnInMetadata', 'CompressionType', 'DictionaryPolicy', 'FilepathSource', 'JSONRecoveryMode', 'PartitionInfo', 'QuoteStyle', 'SinkInfo', 'SourceInfo', 'StatisticsFreq', 'TableInputMetadata', 'TableWithMetadata'] class PartitionInfo: - def __init__(self, start_row: int, num_rows: int): ... + """ + Information used while writing partitioned datasets. + + Parameters + ---------- + start_row : int + The start row of the partition. + + num_rows : int + The number of rows in the partition. + """ + def __init__(self, start_row: size_type, num_rows: size_type): ... + +class ColumnInMetadata: + """ + Metadata for a column + """ + def __init__(self): ... + def set_name(self, name: str) -> ColumnInMetadata: + """ + Set the name of this column. + + Parameters + ---------- + name : str + Name of the column + + Returns + ------- + Self + """ + def set_nullability(self, nullable: bool) -> ColumnInMetadata: + """ + Set the nullability of this column. + + Parameters + ---------- + nullable : bool + Whether this column is nullable + + Returns + ------- + Self + """ + def set_list_column_as_map(self) -> ColumnInMetadata: + """ + Specify that this list column should be encoded as a map in the + written file. + + Returns + ------- + Self + """ + def set_int96_timestamps(self, req: bool) -> ColumnInMetadata: + """ + Specifies whether this timestamp column should be encoded using + the deprecated int96. + + Parameters + ---------- + req : bool + True = use int96 physical type. False = use int64 physical type. + + Returns + ------- + Self + """ + def set_decimal_precision(self, precision: int) -> ColumnInMetadata: + """ + Set the decimal precision of this column. + Only valid if this column is a decimal (fixed-point) type. + + Parameters + ---------- + precision : int + The integer precision to set for this decimal column + + Returns + ------- + Self + """ + def child(self, i: size_type) -> ColumnInMetadata: + """ + Get reference to a child of this column. + + Parameters + ---------- + i : int + Index of the child to get. + + Returns + ------- + ColumnInMetadata + """ + def set_output_as_binary(self, binary: bool) -> ColumnInMetadata: + """ + Specifies whether this column should be written as binary or string data. + + Parameters + ---------- + binary : bool + True = use binary data type. False = use string data type + + Returns + ------- + Self + """ + def set_type_length(self, type_length: int) -> ColumnInMetadata: + """ + Sets the length of fixed length data. + + Parameters + ---------- + type_length : int + Size of the data type in bytes + + Returns + ------- + Self + """ + def set_skip_compression(self, skip: bool) -> ColumnInMetadata: + """ + Specifies whether this column should not be compressed + regardless of the compression. + + Parameters + ---------- + skip : bool + If `true` do not compress this column + + Returns + ------- + Self + """ + def set_encoding(self, encoding: column_encoding) -> ColumnInMetadata: + """ + Specifies whether this column should not be compressed + regardless of the compression. + + Parameters + ---------- + encoding : ColumnEncoding + The encoding to use + + Returns + ------- + ColumnInMetadata + """ + def get_name(self) -> str: + """ + Get the name of this column. + + Returns + ------- + str + The name of this column + """ class TableInputMetadata: + """ + Metadata for a table + + Parameters + ---------- + table : Table + The Table to construct metadata for + """ def __init__(self, table: Table): ... @property - def column_metadata(self) -> list[ColumnInMetadata]: ... - -class ColumnInMetadata: - def set_name(self, name: str) -> Self: ... - def set_nullability(self, nullable: bool) -> Self: ... - def set_list_column_as_map(self) -> Self: ... - def set_int96_timestamps(self, req: bool) -> Self: ... - def set_decimal_precision(self, precision: int) -> Self: ... - def child(self, i: int) -> Self: ... - def set_output_as_binary(self, binary: bool) -> Self: ... - def set_type_length(self, type_length: int) -> Self: ... - def set_skip_compression(self, skip: bool) -> Self: ... - def set_encoding(self, encoding: ColumnEncoding) -> Self: ... - def get_name(self) -> str: ... + def column_metadata(self): ... class TableWithMetadata: + """A container holding a table and its associated metadata + (e.g. column names) + + For details, see :cpp:class:`cudf::io::table_with_metadata`. + + Parameters + ---------- + tbl : Table + The input table. + column_names : list + A list of tuples each containing the name of each column + and the names of its child columns (in the same format). + e.g. + [("id", []), ("name", [("first", []), ("last", [])])] + + """ + __hash__ = None tbl: Table - def __init__( - self, tbl: Table, column_names: list[ColumnNameSpec] - ) -> None: ... + + def __init__(self, tbl: Table, column_names: list): ... @property - def columns(self) -> tuple[Column, ...]: ... - @overload - def column_names(self, include_children: Literal[False]) -> list[str]: ... - @overload - def column_names( - self, include_children: Literal[True] - ) -> list[ColumnNameSpec]: ... - @overload - def column_names( - self, include_children: bool = False - ) -> list[str] | list[ColumnNameSpec]: ... + def columns(self): + """ + Return a tuple containing the columns of the table + """ + def column_names(self, include_children=False): + """ + Return a list containing the column names of the table + """ @property - def child_names(self) -> ChildNameSpec: ... + def child_names(self): + """ + Return a dictionary mapping the names of columns with children + to the names of their child columns. Columns without children + get an empty dictionary. + """ @property - def per_file_user_data(self) -> list[Mapping[bytes, bytes]]: ... + def per_file_user_data(self): + """ + Returns a list containing a dict + containing file-format specific metadata, + for each file being read in. + """ @property - def num_rows_per_source(self) -> list[int]: ... + def num_rows_per_source(self): + """ + Returns a list containing the number + of rows for each file being read in. + """ @property - def num_input_row_groups(self) -> int: ... + def num_input_row_groups(self): + """ + Returns the total number of input + Parquet row groups across all data sources. + """ @property - def num_row_groups_after_stats_filter(self) -> int | None: ... + def num_row_groups_after_stats_filter(self): + """ + Returns the number of remaining Parquet row groups + after stats filter. None if no filtering done. + """ @property - def num_row_groups_after_bloom_filter(self) -> int | None: ... + def num_row_groups_after_bloom_filter(self): + """ + Returns the number of remaining Parquet row groups + after bloom filter. None if no filtering done. + """ class FilepathSource: - def __init__( - self, path: str | os.PathLike[Any], size: int | None = None - ): ... - path: str - size: int | None + """ + A file path or URL with an optional known size in bytes. + + When ``size`` is set for a remote URL, libcudf passes it to KvikIO at open + time so the remote server is not queried for file size (avoiding HEAD + requests). An incorrect size will cause read failures. + + Parameters + ---------- + path : str or os.PathLike + Path or URL of the input file. + size : int, optional + Known file size in bytes. Omit to query size via KvikIO (HEAD for remote URLs). + """ + path: object + size: object + + def __init__(self, path, size=None): ... class SourceInfo: - def __init__( - self, - sources: Sequence[str] - | Sequence[os.PathLike[Any]] - | Sequence[FilepathSource] - | Sequence[Datasource], - ) -> None: ... + """ + A class containing details on a source to read from. + + For details, see :cpp:class:`cudf::io::source_info`. + + Parameters + ---------- + sources : List[Union[ + str, + os.PathLike, + FilepathSource, + bytes, + io.BytesIO, + DataSource, + rmm.DeviceBuffer, + ]] + A homogeneous list of sources to read from. Mixing + different types of sources will raise a `ValueError`. + If an empty list, constructs an empty SourceInfo. + """ + __hash__ = None + + def __init__(self, sources): ... @staticmethod - def _is_remote_uri(path: str | os.PathLike[Any]) -> bool: ... + def _is_remote_uri(path: str | os.PathLike) -> bool: ... + def _init_byte_like_sources(self, sources: list, expected_type: type): ... class SinkInfo: - def __init__( - self, - sinks: Sequence[os.PathLike[Any]] - | Sequence[io.StringIO] - | Sequence[io.BytesIO] - | Sequence[io.TextIOBase] - | Sequence[str], - ) -> None: ... + """ + A class containing details about destinations (sinks) to write data to. + + For more details, see :cpp:class:`cudf::io::sink_info`. + + Parameters + ---------- + sinks : list of str, PathLike, or io.IOBase instances + A list of sinks to write data to. Each sink can be: + + - A string representing a filename. + - A PathLike object. + - An instance of a Python I/O class that is a subclass of io.IOBase + (eg., io.BytesIO, io.StringIO). + + The list must be homogeneous in type unless all sinks are instances + of subclasses of io.IOBase. Mixing different types of sinks + (that are not all io.IOBase instances) will raise a ValueError. + """ + __hash__ = None + + def __init__(self, sinks: list): ... diff --git a/python/pylibcudf/pylibcudf/join.pyi b/python/pylibcudf/pylibcudf/join.pyi index 0921cd7e842e..0d3b2b185e6d 100644 --- a/python/pylibcudf/pylibcudf/join.pyi +++ b/python/pylibcudf/pylibcudf/join.pyi @@ -1,158 +1,430 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/join.pyx + +from pylibcudf.libcudf.types import null_equality from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.expressions import Expression -from pylibcudf.table import Table -from pylibcudf.types import NullEquality -from pylibcudf.utils import CudaStreamLike - -def inner_join( - left_keys: Table, - right_keys: Table, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def left_join( - left_keys: Table, - right_keys: Table, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def full_join( - left_keys: Table, - right_keys: Table, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def left_semi_join( - left_keys: Table, - right_keys: Table, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def left_anti_join( - left_keys: Table, - right_keys: Table, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def cross_join( - left: Table, - right: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def conditional_inner_join( - left: Table, - right: Table, - binary_predicate: Expression, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def conditional_left_join( - left: Table, - right: Table, - binary_predicate: Expression, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def conditional_full_join( - left: Table, - right: Table, - binary_predicate: Expression, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def conditional_left_semi_join( - left: Table, - right: Table, - binary_predicate: Expression, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def conditional_left_anti_join( - left: Table, - right: Table, - binary_predicate: Expression, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def mixed_inner_join( - left_keys: Table, - right_keys: Table, - left_conditional: Table, - right_conditional: Table, - binary_predicate: Expression, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def mixed_left_join( - left_keys: Table, - right_keys: Table, - left_conditional: Table, - right_conditional: Table, - binary_predicate: Expression, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def mixed_full_join( - left_keys: Table, - right_keys: Table, - left_conditional: Table, - right_conditional: Table, - binary_predicate: Expression, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... -def mixed_left_semi_join( - left_keys: Table, - right_keys: Table, - left_conditional: Table, - right_conditional: Table, - binary_predicate: Expression, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def mixed_left_anti_join( - left_keys: Table, - right_keys: Table, - left_conditional: Table, - right_conditional: Table, - binary_predicate: Expression, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column +from .expressions import Expression +from .table import Table + +__all__ = ['conditional_full_join', 'conditional_inner_join', 'conditional_left_anti_join', 'conditional_left_join', 'conditional_left_semi_join', 'cross_join', 'FilteredJoin', 'full_join', 'inner_join', 'left_anti_join', 'left_join', 'left_semi_join', 'mixed_full_join', 'mixed_inner_join', 'mixed_left_anti_join', 'mixed_left_join', 'mixed_left_semi_join'] class FilteredJoin: - def __init__( - self, - right: Table, - compare_nulls: NullEquality, - load_factor: float = ..., - stream: CudaStreamLike | None = None, - ) -> None: ... - def semi_join( - self, - left: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Column: ... - def anti_join( - self, - left: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Column: ... + """ + Filtered hash join that builds a hash table from the right (filter) table + on creation and probes results in subsequent join member functions. + + The right table is used as the filter applied to multiple left tables in + subsequent ``semi_join`` or ``anti_join`` calls. For use cases where the + left table should be reused with multiple right tables, use ``MarkJoin`` + instead. + + For details, see :cpp:class:`cudf::filtered_join`. + """ + def __init__(self, right: Table, compare_nulls: null_equality=null_equality.EQUAL, load_factor: float=0.5, stream: object | None=None): + """ + Construct a filtered hash join object for subsequent probe calls. + + Parameters + ---------- + right : Table + The right (filter) table used to build the hash table. + compare_nulls : NullEquality + Controls whether null join-key values should match or not. + load_factor : float, optional + The desired ratio of filled slots to total slots in the hash table, + must be in range (0,1]. Defaults to 0.5. + stream : Stream, optional + CUDA stream used for device memory operations and kernel launches. + """ + def semi_join(self, left: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """ + Returns a column of row indices corresponding to a semi-join + between the right (filter) table and left table. + + For details, see :cpp:func:`cudf::filtered_join::semi_join`. + + Parameters + ---------- + left : Table + The left table. + stream : Stream, optional + CUDA stream used for device memory operations and kernel launches. + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + A column containing the row indices from the left table after the join. + """ + def anti_join(self, left: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None): + """ + Returns a column of row indices corresponding to an anti-join + between the right (filter) table and left table. + + For details, see :cpp:func:`cudf::filtered_join::anti_join`. + + Parameters + ---------- + left : Table + The left table. + stream : Stream, optional + CUDA stream used for device memory operations and kernel launches. + mr : DeviceMemoryResource, optional + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + A column containing the row indices from the left table after the join. + """ + +def inner_join(left_keys: Table, right_keys: Table, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform an inner join between two tables. + + For details, see :cpp:func:`inner_join`. + + Parameters + ---------- + left_keys : Table + The left table to join. + right_keys : Table + The right table to join. + nulls_equal : NullEquality + Should nulls compare equal? + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def left_join(left_keys: Table, right_keys: Table, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform a left join between two tables. + + For details, see :cpp:func:`left_join`. + + Parameters + ---------- + left_keys : Table + The left table to join. + right_keys : Table + The right table to join. + nulls_equal : NullEquality + Should nulls compare equal? + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def full_join(left_keys: Table, right_keys: Table, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform a full join between two tables. + + For details, see :cpp:func:`full_join`. + + Parameters + ---------- + left_keys : Table + The left table to join. + right_keys : Table + The right table to join. + nulls_equal : NullEquality + Should nulls compare equal? + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def left_semi_join(left_keys: Table, right_keys: Table, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a left semi join between two tables. + + For details, see :cpp:class:`cudf::filtered_join`. + + Parameters + ---------- + left_keys : Table + The left table to join. + right_keys : Table + The right table to join. + nulls_equal : NullEquality + Should nulls compare equal? + + Returns + ------- + Column + A column containing the row indices from the left table after the join. + """ +def left_anti_join(left_keys: Table, right_keys: Table, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a left anti join between two tables. + + For details, see :cpp:class:`cudf::filtered_join`. + + Parameters + ---------- + left_keys : Table + The left table to join. + right_keys : Table + The right table to join. + nulls_equal : NullEquality + Should nulls compare equal? + + Returns + ------- + Column + A column containing the row indices from the left table after the join. + """ +def cross_join(left: Table, right: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Perform a cross join on two tables. + + For details see :cpp:func:`cross_join`. + + Parameters + ---------- + left : Table + The left table to join. + right: Table + The right table to join. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + Table + The result of cross joining the two inputs. + """ +def conditional_inner_join(left: Table, right: Table, binary_predicate: Expression, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform a conditional inner join between two tables. + + For details, see :cpp:func:`conditional_inner_join`. + + Parameters + ---------- + left : Table + The left table to join. + right : Table + The right table to join. + binary_predicate : Expression + Condition to join on. + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def conditional_left_join(left: Table, right: Table, binary_predicate: Expression, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform a conditional left join between two tables. + + For details, see :cpp:func:`conditional_left_join`. + + Parameters + ---------- + left : Table + The left table to join. + right : Table + The right table to join. + binary_predicate : Expression + Condition to join on. + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def conditional_full_join(left: Table, right: Table, binary_predicate: Expression, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform a conditional full join between two tables. + + For details, see :cpp:func:`conditional_full_join`. + + Parameters + ---------- + left : Table + The left table to join. + right : Table + The right table to join. + binary_predicate : Expression + Condition to join on. + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def conditional_left_semi_join(left: Table, right: Table, binary_predicate: Expression, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a conditional left semi join between two tables. + + For details, see :cpp:func:`conditional_left_semi_join`. + + Parameters + ---------- + left : Table + The left table to join. + right : Table + The right table to join. + binary_predicate : Expression + Condition to join on. + + Returns + ------- + Column + A column containing the row indices from the left table after the join. + """ +def conditional_left_anti_join(left: Table, right: Table, binary_predicate: Expression, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a conditional left anti join between two tables. + + For details, see :cpp:func:`conditional_left_anti_join`. + + Parameters + ---------- + left : Table + The left table to join. + right : Table + The right table to join. + binary_predicate : Expression + Condition to join on. + + Returns + ------- + Column + A column containing the row indices from the left table after the join. + """ +def mixed_inner_join(left_keys: Table, right_keys: Table, left_conditional: Table, right_conditional: Table, binary_predicate: Expression, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform a mixed inner join between two tables. + + For details, see :cpp:func:`mixed_inner_join`. + + Parameters + ---------- + left_keys : Table + The left table to use for the equality join. + right_keys : Table + The right table to use for the equality join. + left_conditional : Table + The left table to use for the conditional join. + right_conditional : Table + The right table to use for the conditional join. + binary_predicate : Expression + Condition to join on. + nulls_equal : NullEquality + Should nulls compare equal in the equality join? + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def mixed_left_join(left_keys: Table, right_keys: Table, left_conditional: Table, right_conditional: Table, binary_predicate: Expression, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform a mixed left join between two tables. + + For details, see :cpp:func:`mixed_left_join`. + + Parameters + ---------- + left_keys : Table + The left table to use for the equality join. + right_keys : Table + The right table to use for the equality join. + left_conditional : Table + The left table to use for the conditional join. + right_conditional : Table + The right table to use for the conditional join. + binary_predicate : Expression + Condition to join on. + nulls_equal : NullEquality + Should nulls compare equal in the equality join? + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def mixed_full_join(left_keys: Table, right_keys: Table, left_conditional: Table, right_conditional: Table, binary_predicate: Expression, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Perform a mixed full join between two tables. + + For details, see :cpp:func:`mixed_full_join`. + + Parameters + ---------- + left_keys : Table + The left table to use for the equality join. + right_keys : Table + The right table to use for the equality join. + left_conditional : Table + The left table to use for the conditional join. + right_conditional : Table + The right table to use for the conditional join. + binary_predicate : Expression + Condition to join on. + nulls_equal : NullEquality + Should nulls compare equal in the equality join? + + Returns + ------- + Tuple[Column, Column] + A tuple containing the row indices from the left and right tables after the + join. + """ +def mixed_left_semi_join(left_keys: Table, right_keys: Table, left_conditional: Table, right_conditional: Table, binary_predicate: Expression, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a mixed left semi join between two tables. + + For details, see :cpp:func:`mixed_left_semi_join`. + + Parameters + ---------- + left_keys : Table + The left table to use for the equality join. + right_keys : Table + The right table to use for the equality join. + left_conditional : Table + The left table to use for the conditional join. + right_conditional : Table + The right table to use for the conditional join. + binary_predicate : Expression + Condition to join on. + nulls_equal : NullEquality + Should nulls compare equal in the equality join? + + Returns + ------- + Column + A column containing the row indices from the left table after the join. + """ +def mixed_left_anti_join(left_keys: Table, right_keys: Table, left_conditional: Table, right_conditional: Table, binary_predicate: Expression, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a mixed left anti join between two tables. + + For details, see :cpp:func:`mixed_left_anti_join`. + + Parameters + ---------- + left_keys : Table + The left table to use for the equality join. + right_keys : Table + The right table to use for the equality join. + left_conditional : Table + The left table to use for the conditional join. + right_conditional : Table + The right table to use for the conditional join. + binary_predicate : Expression + Condition to join on. + nulls_equal : NullEquality + Should nulls compare equal in the equality join? + + Returns + ------- + Column + A column containing the row indices from the left table after the join. + """ diff --git a/python/pylibcudf/pylibcudf/json.pyi b/python/pylibcudf/pylibcudf/json.pyi index a60bcb36f269..584e293c8946 100644 --- a/python/pylibcudf/pylibcudf/json.pyi +++ b/python/pylibcudf/pylibcudf/json.pyi @@ -1,31 +1,110 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/json.pyx from pylibcudf.column import Column from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['GetJsonObjectOptions', 'get_json_object'] class GetJsonObjectOptions: - def __init__( - self, - *, - allow_single_quotes: bool = False, - strip_quotes_from_single_strings: bool = True, - missing_fields_as_nulls: bool = False, - ) -> None: ... - def get_allow_single_quotes(self) -> bool: ... - def get_strip_quotes_from_single_strings(self) -> bool: ... - def get_missing_fields_as_nulls(self) -> bool: ... - def set_allow_single_quotes(self, val: bool) -> None: ... - def set_strip_quotes_from_single_strings(self, val: bool) -> None: ... - def set_missing_fields_as_nulls(self, val: bool) -> None: ... - -def get_json_object( - col: Column, - json_path: Scalar, - options: GetJsonObjectOptions | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + """Settings for `get_json_object()`""" + __hash__ = None + + def __init__(self, *, allow_single_quotes=False, strip_quotes_from_single_strings=True, missing_fields_as_nulls=False): ... + def get_allow_single_quotes(self): + """ + Returns true/false depending on whether single-quotes for representing strings + are allowed. + + Returns + ------- + bool + true if single-quotes are allowed, false otherwise. + """ + def get_strip_quotes_from_single_strings(self): + """ + Returns true/false depending on whether individually returned string values have + their quotes stripped. + + Returns + ------- + bool + true if individually returned string values have their quotes stripped. + """ + def get_missing_fields_as_nulls(self): + """ + Whether a field not contained by an object is to be interpreted as null. + + Returns + ------- + bool + true if missing fields are interpreted as null. + """ + def set_allow_single_quotes(self, val: bool): + """ + Set whether single-quotes for strings are allowed. + + Parameters + ---------- + val : bool + Whether to allow single quotes + + Returns + ------- + None + """ + def set_strip_quotes_from_single_strings(self, val: bool): + """ + Set whether individually returned string values have their quotes stripped. + + Parameters + ---------- + val : bool + Whether to strip quotes from single strings. + + Returns + ------- + None + """ + def set_missing_fields_as_nulls(self, val: bool): + """ + Set whether missing fields are interpreted as null. + + Parameters + ---------- + val : bool + Whether to treat missing fields as nulls. + + Returns + ------- + None + """ + +def get_json_object(col: Column, json_path: Scalar, options: GetJsonObjectOptions | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Apply a JSONPath string to all rows in an input strings column. + + For details, see :cpp:func:`get_json_object` + + Parameters + ---------- + col : Column + The input strings column. Each row must contain a valid json string. + + json_path : Scalar + The JSONPath string to be applied to each row. + + options : GetJsonObjectOptions + Options for controlling the behavior of the function. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column containing the retrieved json object strings. + """ diff --git a/python/pylibcudf/pylibcudf/labeling.pyi b/python/pylibcudf/pylibcudf/labeling.pyi index 272edd43f5fa..f44688b47314 100644 --- a/python/pylibcudf/pylibcudf/labeling.pyi +++ b/python/pylibcudf/pylibcudf/labeling.pyi @@ -1,23 +1,41 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/labeling.pyx +from pylibcudf.libcudf.labeling import inclusive +from pylibcudf.libcudf.labeling import inclusive as Inclusive from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -class Inclusive(IntEnum): - YES = ... - NO = ... - -def label_bins( - input: Column, - left_edges: Column, - left_inclusive: Inclusive, - right_edges: Column, - right_inclusive: Inclusive, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column + +__all__ = ['Inclusive', 'label_bins'] + +def label_bins(input: Column, left_edges: Column, left_inclusive: inclusive, right_edges: Column, right_inclusive: inclusive, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Labels elements based on membership in the specified bins. + + For details see :cpp:func:`label_bins`. + + Parameters + ---------- + input : Column + Column of input elements to label according to the specified bins. + left_edges : Column + Column of the left edge of each bin. + left_inclusive : Inclusive + Whether or not the left edge is inclusive. + right_edges : Column + Column of the right edge of each bin. + right_inclusive : Inclusive + Whether or not the right edge is inclusive. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + Column of integer labels of the elements in `input` + according to the specified bins. + """ diff --git a/python/pylibcudf/pylibcudf/lists.pyi b/python/pylibcudf/pylibcudf/lists.pyi index 6ff273458541..8f9951a82eb7 100644 --- a/python/pylibcudf/pylibcudf/lists.pyi +++ b/python/pylibcudf/pylibcudf/lists.pyi @@ -1,146 +1,410 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/lists.pyx +from pylibcudf.libcudf.copying import out_of_bounds_policy +from pylibcudf.libcudf.lists.combine import concatenate_null_policy +from pylibcudf.libcudf.lists.combine import \ + concatenate_null_policy as ConcatenateNullPolicy +from pylibcudf.libcudf.lists.contains import duplicate_find_option +from pylibcudf.libcudf.lists.contains import \ + duplicate_find_option as DuplicateFindOption +from pylibcudf.libcudf.types import (nan_equality, null_equality, null_order, + order, size_type) from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.copying import OutOfBoundsPolicy -from pylibcudf.scalar import Scalar -from pylibcudf.table import Table -from pylibcudf.types import NanEquality, NullEquality, NullOrder, Order -from pylibcudf.utils import CudaStreamLike - -class ConcatenateNullPolicy(IntEnum): - IGNORE = ... - NULLIFY_OUTPUT_ROW = ... - -class DuplicateFindOption(IntEnum): - FIND_FIRST = ... - FIND_LAST = ... - -def explode_outer( - input: Table, - explode_column_idx: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def concatenate_rows( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def concatenate_list_elements( - input: Column, - null_policy: ConcatenateNullPolicy, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def contains( - input: Column, - search_key: Column | Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def contains_nulls( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def index_of( - input: Column, - search_key: Column | Scalar, - find_option: DuplicateFindOption, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def reverse( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def segmented_gather( - input: Column, - gather_map_list: Column, - bounds_policy: OutOfBoundsPolicy = OutOfBoundsPolicy.DONT_CHECK, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def extract_list_element( - input: Column, - index: Column | int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def count_elements( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def sequences( - starts: Column, - sizes: Column, - steps: Column | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def sort_lists( - input: Column, - sort_order: Order, - na_position: NullOrder, - stable: bool = False, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def difference_distinct( - lhs: Column, - rhs: Column, - nulls_equal: NullEquality = NullEquality.EQUAL, - nans_equal: NanEquality = NanEquality.ALL_EQUAL, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def have_overlap( - lhs: Column, - rhs: Column, - nulls_equal: NullEquality = NullEquality.EQUAL, - nans_equal: NanEquality = NanEquality.ALL_EQUAL, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def intersect_distinct( - lhs: Column, - rhs: Column, - nulls_equal: NullEquality = NullEquality.EQUAL, - nans_equal: NanEquality = NanEquality.ALL_EQUAL, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def union_distinct( - lhs: Column, - rhs: Column, - nulls_equal: NullEquality = NullEquality.EQUAL, - nans_equal: NanEquality = NanEquality.ALL_EQUAL, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def apply_boolean_mask( - input: Column, - boolean_mask: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def apply_deletion_mask( - input: Column, - deletion_mask: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def distinct( - input: Column, - nulls_equal: NullEquality, - nans_equal: NanEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column +from .scalar import Scalar +from .table import Table + +__all__ = ['ConcatenateNullPolicy', 'DuplicateFindOption', 'apply_boolean_mask', 'apply_deletion_mask', 'concatenate_list_elements', 'concatenate_rows', 'contains', 'contains_nulls', 'count_elements', 'difference_distinct', 'distinct', 'explode_outer', 'extract_list_element', 'have_overlap', 'index_of', 'intersect_distinct', 'reverse', 'segmented_gather', 'sequences', 'sort_lists', 'union_distinct'] + +def explode_outer(input: Table, explode_column_idx: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Explode a column of lists into rows. + + All other columns will be duplicated for each element in the list. + + For details, see :cpp:func:`explode_outer`. + + Parameters + ---------- + input : Table + The input table + explode_column_idx : int + The index of the column to explode + + Returns + ------- + Table + A new table with the exploded column + """ +def concatenate_rows(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Concatenate multiple lists columns into a single lists column row-wise. + + For details, see :cpp:func:`concatenate_list_elements`. + + Parameters + ---------- + input : Table + The input table + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + A new Column of concatenated rows + """ +def concatenate_list_elements(input: Column, null_policy: concatenate_null_policy, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Concatenate multiple lists on the same row into a single list. + + For details, see :cpp:func:`concatenate_list_elements`. + + Parameters + ---------- + input : Column + The input column + null_policy : ConcatenateNullPolicy + How to treat null list elements. + + Returns + ------- + Column + A new Column of concatenated list elements + """ +def contains(input: Column, search_key: Column | Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a column of bool values indicating whether + the search_key is contained in the input. + + ``search_key`` may be a + :py:class:`~pylibcudf.column.Column` or a + :py:class:`~pylibcudf.scalar.Scalar`. + + For details, see :cpp:func:`contains`. + + Parameters + ---------- + input : Column + The input column. + search_key : Union[Column, Scalar] + The search key. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A new Column of bools indicating if the search_key was + found in the list column. + """ +def contains_nulls(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a column of bool values indicating whether + each row in the lists column contains a null value. + + For details, see :cpp:func:`contains_nulls`. + + Parameters + ---------- + input : Column + The input column. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A new Column of bools indicating if the list column + contains a null value. + """ +def index_of(input: Column, search_key: Column | Scalar, find_option: duplicate_find_option, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a column of index values indicating the position of a search + key row within the corresponding list row in the lists column. + + ``search_key`` may be a + :py:class:`~pylibcudf.column.Column` or a + :py:class:`~pylibcudf.scalar.Scalar`. + + For details, see :cpp:func:`index_of`. + + Parameters + ---------- + input : Column + The input column. + search_key : Union[Column, Scalar] + The search key. + find_option : DuplicateFindOption + Which match to return if there are duplicates. + + Returns + ------- + Column + A new Column of index values that indicate where in the + list column tthe search_key was found. An index value + of -1 indicates that the search_key was not found. + """ +def reverse(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Reverse the element order within each list of the input column. + + For details, see :cpp:func:`reverse`. + + Parameters + ---------- + input : Column + The input column. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A new Column with reversed lists. + """ +def segmented_gather(input: Column, gather_map_list: Column, bounds_policy: out_of_bounds_policy=out_of_bounds_policy.DONT_CHECK, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a column with elements gathered based on the indices in gather_map_list + + For details, see :cpp:func:`segmented_gather`. + + Parameters + ---------- + input : Column + The input column. + gather_map_list : Column + The indices of the lists column to gather. + bounds_policy : OutOfBoundsPolicy + Can be ``DONT_CHECK`` or ``NULLIFY``. Selects whether or not to nullify + the output list row's element, when the gather index falls outside the range + ``[-n, n)``, where ``n`` is the number of elements in list row corresponding + to the gather-map row. + + When ``bounds_policy`` is ``DONT_CHECK``, it's the caller's responsibility to + ensure that the indices in ``gather_map_list`` are in-bounds for the lists in + ``input`` before calling this function. The behavior with out-of-bounds indices + and ``DONT_CHECK`` is undefined and maybe produce invalid results or crash. + + Returns + ------- + Column + A new Column with elements in list of rows + gathered based on gather_map_list + """ +def extract_list_element(input: Column, index: Column | size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a column of extracted list elements. + + For details, see :cpp:func:`extract_list_element`. + + Parameters + ---------- + input : Column + The input column. + index : Union[Column, size_type] + The selection index or indices. + + Returns + ------- + Column + A new Column with elements extracted. + """ +def count_elements(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Count the number of rows in each + list element in the given lists column. + For details, see :cpp:func:`count_elements`. + + For details, see :cpp:func:`count_elements`. + + Parameters + ---------- + input : Column + The input column + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A new Column of the lengths of each list element + """ +def sequences(starts: Column, sizes: Column, steps: Column | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a lists column in which each row contains a sequence of + values specified by a tuple of (start, step, size) parameters. + + For details, see :cpp:func:`sequences`. + + Parameters + ---------- + starts : Column + First values in the result sequences. + sizes : Column + Numbers of values in the result sequences. + steps : Optional[Column] + Increment values for the result sequences. + + Returns + ------- + Column + The result column containing generated sequences. + """ +def sort_lists(input: Column, sort_order: order, na_position: null_order, stable: bool=False, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Sort the elements within a list in each row of a list column. + + For details, see :cpp:func:`sort_lists`. + + Parameters + ---------- + input : Column + The input column. + ascending : Order + Sort order in the list. + na_position : NullOrder + If na_position equals NullOrder.FIRST, then the null values in the output + column are placed first. Otherwise, they are be placed after. + stable: bool + If true :cpp:func:`stable_sort_lists` is used, Otherwise, + :cpp:func:`sort_lists` is used. + + Returns + ------- + Column + A new Column with elements in each list sorted. + """ +def difference_distinct(lhs: Column, rhs: Column, nulls_equal: null_equality=null_equality.EQUAL, nans_equal: nan_equality=nan_equality.ALL_EQUAL, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a column of index values indicating the position of a search + key row within the corresponding list row in the lists column. + + For details, see :cpp:func:`difference_distinct`. + + Parameters + ---------- + lhs : Column + The input lists column of elements that may be included. + rhs : Column + The input lists column of elements to exclude. + nulls_equal : NullEquality, default EQUAL + Are nulls considered equal. + nans_equal : NanEquality, default ALL_EQUAL + Are nans considered equal. + + Returns + ------- + Column + A lists column containing the difference results. + """ +def have_overlap(lhs: Column, rhs: Column, nulls_equal: null_equality=null_equality.EQUAL, nans_equal: nan_equality=nan_equality.ALL_EQUAL, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Check if lists at each row of the given lists columns overlap. + + For details, see :cpp:func:`have_overlap`. + + Parameters + ---------- + lhs : Column + The input lists column for one side. + rhs : Column + The input lists column for the other side. + nulls_equal : NullEquality, default EQUAL + Are nulls considered equal. + nans_equal : NanEquality, default ALL_EQUAL + Are nans considered equal. + + Returns + ------- + Column + A column containing the check results. + """ +def intersect_distinct(lhs: Column, rhs: Column, nulls_equal: null_equality=null_equality.EQUAL, nans_equal: nan_equality=nan_equality.ALL_EQUAL, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a lists column of distinct elements common to two input lists columns. + + For details, see :cpp:func:`intersect_distinct`. + + Parameters + ---------- + lhs : Column + The input lists column of elements that may be included. + rhs : Column + The input lists column of elements to exclude. + nulls_equal : NullEquality, default EQUAL + Are nulls considered equal. + nans_equal : NanEquality, default ALL_EQUAL + Are nans considered equal. + + Returns + ------- + Column + A lists column containing the intersection results. + """ +def union_distinct(lhs: Column, rhs: Column, nulls_equal: null_equality=null_equality.EQUAL, nans_equal: nan_equality=nan_equality.ALL_EQUAL, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a lists column of distinct elements found in + either of two input lists columns. + + For details, see :cpp:func:`union_distinct`. + + Parameters + ---------- + lhs : Column + The input lists column of elements that may be included. + rhs : Column + The input lists column of elements to exclude. + nulls_equal : NullEquality, default EQUAL + Are nulls considered equal. + nans_equal : NanEquality, default ALL_EQUAL + Are nans considered equal. + + Returns + ------- + Column + A lists column containing the union results. + """ +def apply_boolean_mask(input: Column, boolean_mask: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Filters elements in each row of the input lists column using a boolean mask + + For details, see :cpp:func:`apply_boolean_mask`. + + Parameters + ---------- + input : Column + The input column. + boolean_mask : Column + The boolean mask. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + A Column of filtered elements based upon the boolean mask. + """ +def apply_deletion_mask(input: Column, deletion_mask: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Filters elements in each row of the input lists column using a deletion mask. + + For details, see :cpp:func:`apply_deletion_mask`. + + Parameters + ---------- + input : Column + The input lists column. + deletion_mask : Column + A lists-of-bools column used as a deletion mask. + + Returns + ------- + Column + Lists column with elements removed where deletion_mask is true. + """ +def distinct(input: Column, nulls_equal: null_equality, nans_equal: nan_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a new list column without duplicate elements in each list. + + For details, see :cpp:func:`distinct`. + + Parameters + ---------- + input : Column + The input column. + nulls_equal : NullEquality + Are nulls considered equal. + nans_equal : NanEquality + Are nans considered equal. + + Returns + ------- + Column + A new list column without duplicate elements in each list. + """ diff --git a/python/pylibcudf/pylibcudf/merge.pyi b/python/pylibcudf/pylibcudf/merge.pyi index 50e87d5bffa9..dfa361d9b2a1 100644 --- a/python/pylibcudf/pylibcudf/merge.pyi +++ b/python/pylibcudf/pylibcudf/merge.pyi @@ -1,17 +1,36 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/merge.pyx + from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.table import Table -from pylibcudf.types import NullOrder, Order -from pylibcudf.utils import CudaStreamLike - -def merge( - tables_to_merge: list[Table], - key_cols: list[int], - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... +from .table import Table + +__all__ = ['merge'] + +def merge(tables_to_merge: list, key_cols: list, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Merge a set of sorted tables. + + For details see :cpp:func:`merge`. + + Parameters + ---------- + tables_to_merge : list + List of tables to merge. + key_cols : list + List of column indexes to merge on. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + Table + The merged table. + """ diff --git a/python/pylibcudf/pylibcudf/null_mask.pyi b/python/pylibcudf/pylibcudf/null_mask.pyi index 396905eb5723..4c5ed50f7e55 100644 --- a/python/pylibcudf/pylibcudf/null_mask.pyi +++ b/python/pylibcudf/pylibcudf/null_mask.pyi @@ -1,48 +1,180 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Sequence +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/null_mask.pyx +from pylibcudf.libcudf.types import mask_state, size_type from rmm.pylibrmm.device_buffer import DeviceBuffer from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.span import Span -from pylibcudf.types import MaskState -from pylibcudf.utils import CudaStreamLike - -def copy_bitmask( - col: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> DeviceBuffer: ... -def copy_bitmask_from_bitmask( - bitmask: Span, - begin_bit: int, - end_bit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> DeviceBuffer: ... -def bitmask_allocation_size_bytes(number_of_bits: int) -> int: ... -def create_null_mask( - size: int, - state: MaskState = MaskState.UNINITIALIZED, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> DeviceBuffer: ... -def bitmask_and( - columns: Sequence[Column], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[DeviceBuffer, int]: ... -def bitmask_or( - columns: Sequence[Column], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[DeviceBuffer, int]: ... -def null_count( - bitmask: Span, start: int, stop: int, stream: CudaStreamLike | None = None -) -> int: ... -def index_of_first_set_bit( - bitmask: Span, start: int, stop: int, stream: CudaStreamLike | None = None -) -> int: ... +from .column import Column + +__all__ = ['bitmask_allocation_size_bytes', 'bitmask_and', 'bitmask_or', 'copy_bitmask', 'create_null_mask', 'null_count', 'index_of_first_set_bit'] + +def copy_bitmask(col: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> DeviceBuffer: + """Copies ``col``'s bitmask into a ``DeviceBuffer``. + + For details, see :cpp:func:`copy_bitmask`. + + Parameters + ---------- + col : Column + Column whose bitmask needs to be copied + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource for allocations. + + Returns + ------- + rmm.DeviceBuffer + A ``DeviceBuffer`` containing ``col``'s bitmask, or an empty + ``DeviceBuffer`` if ``col`` is not nullable + """ +def copy_bitmask_from_bitmask(bitmask: object, begin_bit: size_type, end_bit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> DeviceBuffer: + """Copies a portion of a bitmask into a ``DeviceBuffer``. + + For details, see :cpp:func:`copy_bitmask`. + + Parameters + ---------- + bitmask : Span-like object + Object with ptr and size attributes (e.g., gpumemoryview, Buffer, DeviceBuffer). + begin_bit : size_type + The starting bit index (inclusive). + end_bit : size_type + The ending bit index (exclusive). + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource for allocations. + + Returns + ------- + rmm.DeviceBuffer + A ``DeviceBuffer`` containing ``col``'s bitmask, or an empty + ``DeviceBuffer`` if ``col`` is not nullable + """ +def bitmask_allocation_size_bytes(number_of_bits: size_type) -> int: + """ + Computes the required bytes necessary to represent the specified number of bits + with a 64B padding boundary. + + For details, see :cpp:func:`bitmask_allocation_size_bytes`. + + Parameters + ---------- + number_of_bits : size_type + The number of bits that need to be represented + + Returns + ------- + size_t + The necessary number of bytes + """ +def create_null_mask(size: size_type, state: mask_state=mask_state.UNINITIALIZED, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> DeviceBuffer: + """Creates a ``DeviceBuffer`` for use as a null value indicator bitmask of a + ``Column``. + + For details, see :cpp:func:`create_null_mask`. + + Parameters + ---------- + size : size_type + The number of elements to be represented by the mask + state : mask_state, optional + The desired state of the mask. Can be one of { MaskState.UNALLOCATED, + MaskState.UNINITIALIZED, MaskState.ALL_VALID, MaskState.ALL_NULL } + (default MaskState.UNINITIALIZED) + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource for allocations. + + Returns + ------- + rmm.DeviceBuffer + A ``DeviceBuffer`` for use as a null bitmask satisfying the desired size and + state + """ +def bitmask_and(columns, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Performs bitwise AND of the bitmasks of a list of columns. + + For details, see :cpp:func:`bitmask_and`. + + Parameters + ---------- + columns : Sequence[Column] + The columns + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource for allocations. + + Returns + ------- + tuple[DeviceBuffer, size_type] + A tuple of the resulting mask and count of unset bits + """ +def bitmask_or(columns, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Performs bitwise OR of the bitmasks of a list of columns. + + For details, see :cpp:func:`bitmask_or`. + + Parameters + ---------- + columns : Sequence[Column] + The columns + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource for allocations. + + Returns + ------- + tuple[DeviceBuffer, size_type] + A tuple of the resulting mask and count of unset bits + """ +def null_count(bitmask: object, start: size_type, stop: size_type, stream: object | None=None) -> size_type: + """Given a validity bitmask, counts the number of null elements. + + For details, see :cpp:func:`null_count`. + + Parameters + ---------- + bitmask : Span-like object + Object with ptr and size attributes (e.g., gpumemoryview, Buffer, DeviceBuffer). + start : int + Index of the first bit to count (inclusive). + stop : int + Index of the last bit to count (exclusive). + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + int + The number of null elements in the specified range. + """ +def index_of_first_set_bit(bitmask: object, start: size_type, stop: size_type, stream: object | None=None) -> size_type: + """Given a validity bitmask, returns the index of the first valid element + relative to ``start``. + + For details, see :cpp:func:`index_of_first_set_bit`. + + Parameters + ---------- + bitmask : Span-like object + Object with ptr and size attributes (e.g., gpumemoryview, Buffer, DeviceBuffer). + start : int + Index of the first bit to check (inclusive). + stop : int + Index of the last bit to check (exclusive). + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + int + The index of the first set bit relative to ``start`` + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyi b/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyi index 7ee48f722094..bc9197f75214 100644 --- a/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyi @@ -1,24 +1,42 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/byte_pair_encode.pyx from pylibcudf.column import Column from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['BPEMergePairs', 'byte_pair_encoding'] class BPEMergePairs: - def __init__( - self, - merge_pairs: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ): ... - -def byte_pair_encoding( - input: Column, - merge_pairs: BPEMergePairs, - separator: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + """The table of merge pairs for the BPE encoder. + + For details, see :cpp:class:`cudf::nvtext::bpe_merge_pairs`. + """ + __hash__ = None + + def __init__(self, merge_pairs: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None): ... + +def byte_pair_encoding(input: Column, merge_pairs: BPEMergePairs, separator: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Byte pair encode the input strings. + + For details, see cpp:func:`cudf::nvtext::byte_pair_encoding` + + Parameters + ---------- + input : Column + Strings to encode. + merge_pairs : BPEMergePairs + Substrings to rebuild each string on. + separator : Scalar + String used to build the output after encoding. Default is a space. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + An encoded column of strings. + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyi b/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyi index 653ee588f612..faab2fd64d22 100644 --- a/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/deduplicate.pyi @@ -1,30 +1,89 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/deduplicate.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def build_suffix_array( - input: Column, - min_width: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def resolve_duplicates( - input: Column, - indices: Column, - min_width: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def resolve_duplicates_pair( - input1: Column, - indices1: Column, - input2: Column, - indices2: Column, - min_width: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['build_suffix_array', 'resolve_duplicates', 'resolve_duplicates_pair'] + +def build_suffix_array(input: Column, min_width: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Builds a suffix array for the input strings column. + A suffix array is the indices of the sorted set of substrings + of the input column as: [ input[0:], input[1:], ... input[bytes-1:] ] + where bytes is the total number of bytes in input. + The returned array represent the sorted strings such that + result[i] = input[result[i]:] + + For details, see :cpp:func:`build_suffix_array` + + Parameters + ---------- + input : Column + Strings column of text + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of suffix array + """ +def resolve_duplicates(input: Column, indices: Column, min_width: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns duplicate strings found in the input column + with min_width minimum number of bytes. + The indices are expected to be the suffix array previously created + for input. Otherwise, the results are undefined. + + For details, see :cpp:func:`resolve_duplicates` + + Parameters + ---------- + input : Column + Strings column of text + indices : Column + Suffix array from :cpp:func:`build_suffix_array` + min_width : size_type + Minimum width of bytes to detect duplicates + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of duplicate strings + """ +def resolve_duplicates_pair(input1: Column, indices1: Column, input2: Column, indices2: Column, min_width: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns duplicate strings in input1 found in input2 + with min_width minimum number of bytes. + The indices are expected to be the suffix array previously created + for the inputs. Otherwise, the results are undefined. + + For details, see :cpp:func:`resolve_duplicates_pair` + + Parameters + ---------- + input1 : Column + Strings column of text + indices1 : Column + Suffix array from :cpp:func:`build_suffix_array` for input1 + input2 : Column + Strings column of text + indices2 : Column + Suffix array from :cpp:func:`build_suffix_array` for input2 + min_width : size_type + Minimum width of bytes to detect duplicates + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of duplicate strings + + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyi b/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyi index 90d5991aeaa7..39ca54a3592d 100644 --- a/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/edit_distance.pyi @@ -1,14 +1,30 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/edit_distance.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def edit_distance( - input: Column, - targets: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['edit_distance'] + +def edit_distance(input: Column, targets: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the edit distance between individual strings in two strings columns + + For details, see :cpp:func:`edit_distance` + + Parameters + ---------- + input : Column + Input strings + targets : Column + Strings to compute edit distance against + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of edit distance values + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyi b/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyi index 317fdb9ee730..4d2e0ade1cff 100644 --- a/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyi @@ -1,33 +1,76 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from typing import Any - -import numpy as np - -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/generate_ngrams.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -def generate_ngrams( - input: Column, - ngrams: int, - separator: Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def generate_character_ngrams( - input: Column, - ngrams: int = 2, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def hash_character_ngrams( - input: Column, - ngrams: int, - seed: int | np.unsignedinteger[Any], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['generate_ngrams', 'generate_character_ngrams', 'hash_character_ngrams'] + +def generate_ngrams(input: Column, ngrams: size_type, separator: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a single column of strings by generating ngrams from a strings column. + + For details, see :cpp:func:`generate_ngrams` + + Parameters + ---------- + input : Column + Input strings + ngram : size_type + The ngram number to generate + separator : Scalar + The string to use for separating ngram tokens + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings columns of tokens + """ +def generate_character_ngrams(input: Column, ngrams: size_type=2, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a lists column of ngrams of characters within each string. + + For details, see :cpp:func:`generate_character_ngrams` + + Parameters + ---------- + input : Column + Input strings + ngram : size_type + The ngram number to generate + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Lists column of strings + """ +def hash_character_ngrams(input: Column, ngrams: size_type, seed: int, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a lists column of hash values of the characters in each string + + For details, see :cpp:func:`hash_character_ngrams` + + Parameters + ---------- + input : Column + Input strings + ngram : size_type + The ngram number to generate + seed : uint32_t + Seed used for the hash algorithm + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Lists column of hash values + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/jaccard.pyi b/python/pylibcudf/pylibcudf/nvtext/jaccard.pyi index 355d2d7a92fa..3fbad068de85 100644 --- a/python/pylibcudf/pylibcudf/nvtext/jaccard.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/jaccard.pyi @@ -1,15 +1,35 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/jaccard.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def jaccard_index( - input1: Column, - input2: Column, - width: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['jaccard_index'] + +def jaccard_index(input1: Column, input2: Column, width: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the Jaccard similarity between individual rows in two strings columns. + + For details, see :cpp:func:`jaccard_index` + + Parameters + ---------- + input1 : Column + Input strings column + input2 : Column + Input strings column + width : size_type + The ngram number to generate + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + Index calculation values + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/minhash.pyi b/python/pylibcudf/pylibcudf/nvtext/minhash.pyi index 5bce73dc9911..06543f285833 100644 --- a/python/pylibcudf/pylibcudf/nvtext/minhash.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/minhash.pyi @@ -1,48 +1,119 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from typing import Any - -import numpy as np +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/minhash.pyx +from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def minhash( - input: Column, - seed: int | np.unsignedinteger[Any], - a: Column, - b: Column, - width: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def minhash64( - input: Column, - seed: int | np.unsignedinteger[Any], - a: Column, - b: Column, - width: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def minhash_ngrams( - input: Column, - ngrams: int, - seed: int | np.unsignedinteger[Any], - a: Column, - b: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def minhash64_ngrams( - input: Column, - ngrams: int, - seed: int | np.unsignedinteger[Any], - a: Column, - b: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +__all__ = ['minhash', 'minhash64', 'minhash_ngrams', 'minhash64_ngrams'] + +def minhash(input: Column, seed: int, a: Column, b: Column, width: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the minhash values for each string. + This function uses MurmurHash3_x86_32 for the hash algorithm. + + For details, see :cpp:func:`minhash`. + + Parameters + ---------- + input : Column + Strings column to compute minhash + seed : uint32_t + Seed used for the hash function + a : Column + 1st parameter value used for the minhash algorithm. + b : Column + 2nd parameter value used for the minhash algorithm. + width : size_type + Character width used for apply substrings; + + Returns + ------- + Column + List column of minhash values for each string per seed + """ +def minhash64(input: Column, seed: int, a: Column, b: Column, width: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the minhash values for each string. + This function uses MurmurHash3_x64_128 for the hash algorithm. + + For details, see :cpp:func:`minhash64`. + + Parameters + ---------- + input : Column + Strings column to compute minhash + seed : uint64_t + Seed used for the hash function + a : Column + 1st parameter value used for the minhash algorithm. + b : Column + 2nd parameter value used for the minhash algorithm. + width : size_type + Character width used for apply substrings; + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + List column of minhash values for each string per seed + """ +def minhash_ngrams(input: Column, ngrams: size_type, seed: int, a: Column, b: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the minhash values for each input row of strings. + This function uses MurmurHash3_x86_32 for the hash algorithm. + + For details, see :cpp:func:`minhash_ngrams`. + + Parameters + ---------- + input : Column + List column of strings to compute minhash + ngrams : size_type + Number of consecutive strings to hash in each row + seed : uint32_t + Seed used for the hash function + a : Column + 1st parameter value used for the minhash algorithm. + b : Column + 2nd parameter value used for the minhash algorithm. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + List column of minhash values for each row per + value in columns a and b. + """ +def minhash64_ngrams(input: Column, ngrams: size_type, seed: int, a: Column, b: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the minhash values for each input row of strings. + This function uses MurmurHash3_x64_128 for the hash algorithm. + + For details, see :cpp:func:`minhash64_ngrams`. + + Parameters + ---------- + input : Column + Strings column to compute minhash + ngrams : size_type + Number of consecutive strings to hash in each row + seed : uint64_t + Seed used for the hash function + a : Column + 1st parameter value used for the minhash algorithm. + b : Column + 2nd parameter value used for the minhash algorithm. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + List column of minhash values for each row per + value in columns a and b. + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyi b/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyi index 99c309a21ffc..557920c18287 100644 --- a/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyi @@ -1,17 +1,38 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/ngrams_tokenize.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['ngrams_tokenize'] + +def ngrams_tokenize(input: Column, ngrams: size_type, delimiter: Scalar, separator: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a single column of strings by tokenizing the input strings column + and then producing ngrams of each string. + + For details, see :cpp:func:`ngrams_tokenize` + + Parameters + ---------- + input : Column + Input strings + ngrams : size_type + The ngram number to generate + delimiter : Scalar + UTF-8 characters used to separate each string into tokens. + An empty string will separate tokens using whitespace. + separator : Scalar + The string to use for separating ngram tokens + stream : Stream | None + CUDA stream on which to perform the operation. -def ngrams_tokenize( - input: Column, - ngrams: int, - delimiter: Scalar, - separator: Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + Returns + ------- + Column + New strings columns of tokens + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/normalize.pyi b/python/pylibcudf/pylibcudf/nvtext/normalize.pyi index 0fbd2e7e725b..ef06e70d2776 100644 --- a/python/pylibcudf/pylibcudf/nvtext/normalize.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/normalize.pyi @@ -1,28 +1,58 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/normalize.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['CharacterNormalizernormalize_characters', 'normalize_spaces'] class CharacterNormalizer: - def __init__( - self, - do_lower_case: bool, - special_tokens: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ): ... - -def normalize_spaces( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def normalize_characters( - input: Column, - normalizer: CharacterNormalizer, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + """The normalizer object to be used with ``normalize_characters``. + + For details, see :cpp:class:`cudf::nvtext::character_normalizer`. + """ + __hash__ = None + + def __init__(self, do_lower_case: bool, tokens: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None): ... + +def normalize_spaces(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new strings column by normalizing the whitespace in + each string in the input column. + + For details, see :cpp:func:`normalize_spaces` + + Parameters + ---------- + input : Column + Input strings + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings columns of normalized strings. + """ +def normalize_characters(input: Column, normalizer: CharacterNormalizer, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Normalizes strings characters for tokenizing. + + For details, see :cpp:func:`normalize_characters` + + Parameters + ---------- + input : Column + Input strings + normalizer : CharacterNormalizer + Normalizer object used for modifying the input column text + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Normalized strings column + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/replace.pyi b/python/pylibcudf/pylibcudf/nvtext/replace.pyi index a5e451cdb169..68a3fed74784 100644 --- a/python/pylibcudf/pylibcudf/nvtext/replace.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/replace.pyi @@ -1,25 +1,63 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/replace.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -def replace_tokens( - input: Column, - targets: Column, - replacements: Column, - delimiter: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def filter_tokens( - input: Column, - min_token_length: int, - replacement: Scalar | None = None, - delimiter: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['filter_tokens', 'replace_tokens'] + +def replace_tokens(input: Column, targets: Column, replacements: Column, delimiter: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Replaces specified tokens with corresponding replacement strings. + + For details, see :cpp:func:`replace_tokens` + + Parameters + ---------- + input : Column + Strings column to replace + targets : Column + Strings to compare against tokens found in ``input`` + replacements : Column + Replacement strings for each string in ``targets`` + delimiter : Scalar, optional + Characters used to separate each string into tokens. + The default of empty string will identify tokens using whitespace. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column with replaced strings + """ +def filter_tokens(input: Column, min_token_length: size_type, replacement: Scalar | None=None, delimiter: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Removes tokens whose lengths are less than a specified number of characters. + + For details, see :cpp:func:`filter_tokens` + + Parameters + ---------- + input : Column + Strings column to replace + min_token_length : size_type + The minimum number of characters to retain a + token in the output string + replacement : Scalar, optional + Optional replacement string to be used in place of removed tokens + delimiter : Scalar, optional + Characters used to separate each string into tokens. + The default of empty string will identify tokens using whitespace. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column of filtered strings + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/stemmer.pyi b/python/pylibcudf/pylibcudf/nvtext/stemmer.pyi index 5fef689a8956..01ddf5cc4951 100644 --- a/python/pylibcudf/pylibcudf/nvtext/stemmer.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/stemmer.pyi @@ -1,20 +1,59 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/stemmer.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def is_letter( - input: Column, - check_vowels: bool, - indices: Column | int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def porter_stemmer_measure( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from pylibcudf.libcudf.nvtext.stemmer import letter_type as LetterType +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['is_letter', 'porter_stemmer_measure', 'LetterType'] + +def is_letter(input: Column, check_vowels: bool, indices: Column | size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns boolean column indicating if the character + or characters at the provided character index or + indices (respectively) are consonants or vowels + + For details, see :cpp:func:`is_letter` + + Parameters + ---------- + input : Column + Input strings + check_vowels : bool + If true, the check is for vowels. Otherwise the check is + for consonants. + indices : Union[Column, size_type] + The character position(s) to check in each string + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + New boolean column. + """ +def porter_stemmer_measure(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the Porter Stemmer measurements of a strings column. + + For details, see :cpp:func:`porter_stemmer_measure` + + Parameters + ---------- + input : Column + Strings column of words to measure + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + New column of measure values + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/tokenize.pyi b/python/pylibcudf/pylibcudf/nvtext/tokenize.pyi index 72a5209902e7..c3915af8a3c7 100644 --- a/python/pylibcudf/pylibcudf/nvtext/tokenize.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/tokenize.pyi @@ -1,61 +1,172 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/tokenize.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['TokenizeVocabulary', 'character_tokenize', 'count_tokens_column', 'count_tokens_scalar', 'detokenize', 'tokenize_column', 'tokenize_scalar', 'tokenize_with_vocabulary'] class TokenizeVocabulary: - def __init__( - self, - vocab: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ): ... - -def tokenize_scalar( - input: Column, - delimiter: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def tokenize_column( - input: Column, - delimiters: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def count_tokens_scalar( - input: Column, - delimiter: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def count_tokens_column( - input: Column, - delimiters: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def character_tokenize( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def detokenize( - input: Column, - row_indices: Column, - separator: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def tokenize_with_vocabulary( - input: Column, - vocabulary: TokenizeVocabulary, - delimiter: Scalar, - default_id: int = -1, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + """The Vocabulary object to be used with ``tokenize_with_vocabulary``. + + For details, see :cpp:class:`cudf::nvtext::tokenize_vocabulary`. + """ + __hash__ = None + + def __init__(self, vocab: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None): ... + +def tokenize_scalar(input: Column, delimiter: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a single column of strings by tokenizing the input + strings column using the provided characters as delimiters. + + For details, see cpp:func:`cudf::nvtext::tokenize` + + Parameters + ---------- + input : Column + Strings column to tokenize + delimiter : Scalar + String scalar used to separate individual strings into tokens + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings columns of tokens + """ +def tokenize_column(input: Column, delimiters: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a single column of strings by tokenizing the input + strings column using multiple strings as delimiters. + + For details, see cpp:func:`cudf::nvtext::tokenize` + + Parameters + ---------- + input : Column + Strings column to tokenize + delimiters : Column + Strings column used to separate individual strings into tokens + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings columns of tokens + """ +def count_tokens_scalar(input: Column, delimiter: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the number of tokens in each string of a strings column + using the provided characters as delimiters. + + For details, see cpp:func:`cudf::nvtext::count_tokens` + + Parameters + ---------- + input : Column + Strings column to count tokens + delimiters : Scalar + String scalar used to separate each string into tokens + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of token counts + """ +def count_tokens_column(input: Column, delimiters: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the number of tokens in each string of a strings column + using multiple strings as delimiters. + + For details, see cpp:func:`cudf::nvtext::count_tokens` + + Parameters + ---------- + input : Column + Strings column to count tokens + delimiters : Column + Strings column used to separate each string into tokens + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of token counts + """ +def character_tokenize(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a single column of strings by converting + each character to a string. + + For details, see cpp:func:`cudf::nvtext::character_tokens` + + Parameters + ---------- + input : Column + Strings column to tokenize + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings columns of tokens + """ +def detokenize(input: Column, row_indices: Column, separator: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Creates a strings column from a strings column of tokens + and an associated column of row ids. + + For details, see cpp:func:`cudf::nvtext::detokenize` + + Parameters + ---------- + input : Column + Strings column to detokenize + row_indices : Column + The relative output row index assigned for each token in the input column + separator : Scalar + String to append after concatenating each token to the proper output row + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings columns of tokens + """ +def tokenize_with_vocabulary(input: Column, vocabulary: TokenizeVocabulary, delimiter: Scalar, default_id: size_type=-1, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the token ids for the input string by looking + up each delimited token in the given vocabulary. + + For details, see cpp:func:`cudf::nvtext::tokenize_with_vocabulary` + + Parameters + ---------- + input : Column + Strings column to tokenize + vocabulary : TokenizeVocabulary + Used to lookup tokens within ``input`` + delimiter : Scalar + Used to identify tokens within ``input`` + default_id : size_type + The token id to be used for tokens not found in the vocabulary; Default is -1 + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Lists column of token ids + """ diff --git a/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyi b/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyi index e77a8c86a693..ef4b5c8336a1 100644 --- a/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyi +++ b/python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyi @@ -1,23 +1,44 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/nvtext/wordpiece_tokenize.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['WordPieceVocabulary', 'wordpiece_tokenize'] class WordPieceVocabulary: - def __init__( - self, - vocab: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ): ... - -def wordpiece_tokenize( - input: Column, - vocabulary: WordPieceVocabulary, - max_words_per_row: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + """The Vocabulary object to be used with ``wordpiece_tokenize``. + + For details, see :cpp:class:`cudf::nvtext::wordpiece_tokenize`. + """ + __hash__ = None + + def __init__(self, vocab: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None): ... + +def wordpiece_tokenize(input: Column, vocabulary: WordPieceVocabulary, max_words_per_row: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns the token ids for the input string by looking + up each delimited token in the given vocabulary. + The input is expected to be normalized. + + For details, see cpp:func:`cudf::nvtext::wordpiece_tokenize` + + Parameters + ---------- + input : Column + Normalized strings column to tokenize + vocabulary : WordPieceVocabulary + Used to lookup tokens within ``input`` + max_words_per_row : size_type + Maximum number of words to tokenize per input row + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Lists column of token ids + """ diff --git a/python/pylibcudf/pylibcudf/partitioning.pyi b/python/pylibcudf/pylibcudf/partitioning.pyi index 971346421ea0..530f8e0493ae 100644 --- a/python/pylibcudf/pylibcudf/partitioning.pyi +++ b/python/pylibcudf/pylibcudf/partitioning.pyi @@ -1,38 +1,93 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/partitioning.pyx +from pylibcudf.libcudf import partitioning as cpp_partitioning from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -class HashId(IntEnum): - HASH_IDENTITY = ... - HASH_MURMUR3 = ... - -def hash_partition( - input: Table, - keys: Table | list[int], - num_partitions: int, - hash_function: HashId = ..., - seed: int = ..., - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Table, list[int]]: ... -def partition( - t: Table, - partition_map: Column, - num_partitions: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Table, list[int]]: ... -def round_robin_partition( - input: Table, - num_partitions: int, - start_partition: int = 0, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Table, list[int]]: ... +from .column import Column +from .table import Table + +__all__ = ['hash_partition', 'partition', 'round_robin_partition'] + +def hash_partition(input: Table, keys: Table | list, num_partitions: int, hash_function: cpp_partitioning.hash_id=cpp_partitioning.hash_id.HASH_MURMUR3, seed: int=cpp_partitioning.DEFAULT_HASH_SEED, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple[object, object]: + """ + Partitions rows from the input table into multiple output tables. + + For details, see :cpp:func:`hash_partition`. + + Parameters + ---------- + input : Table + The table to partition + keys : Table | list[int] + Table providing keys to hash or list of indices of input columns to hash + num_partitions : int + The number of partitions to use + hash_function : HashId + Hashing function apply to key columns. + seed : int + Seed for hash function. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + tuple[Table, list[int]] + An output table and a list of `num_partitions + 1` row offsets where + partition `i` contains rows in the range `[offsets[i], offsets[i+1])` + """ +def partition(t: Table, partition_map: Column, num_partitions: int, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple[object, object]: + """ + Partitions rows of `t` according to the mapping specified by `partition_map`. + + For details, see :cpp:func:`partition`. + + Parameters + ---------- + t : Table + The table to partition + partition_map : Column + Non-nullable column of integer values that map each row + in `t` to it's partition. + num_partitions : int + The total number of partitions + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + tuple[Table, list[int]] + An output table and a list of `num_partitions + 1` row offsets where + partition `i` contains rows in the range `[offsets[i], offsets[i+1])` + """ +def round_robin_partition(input: Table, num_partitions: int, start_partition: int=0, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple[object, object]: + """ + Round-robin partition. + + For details, see :cpp:func:`round_robin_partition`. + + Parameters + ---------- + input : Table + The input table to be round-robin partitioned + num_partitions : int + Number of partitions for the table + start_partition : int, default 0 + Index of the 1st partition + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + tuple[Table, list[int]] + The partitioned table and a list of `num_partitions + 1` partition offsets + where partition `i` contains rows in the range `[offsets[i], offsets[i+1])`. + """ diff --git a/python/pylibcudf/pylibcudf/prefetch.pyi b/python/pylibcudf/pylibcudf/prefetch.pyi index 6d97284dc0d4..cc2b1616ee50 100644 --- a/python/pylibcudf/pylibcudf/prefetch.pyi +++ b/python/pylibcudf/pylibcudf/prefetch.pyi @@ -1,7 +1,15 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -def enable() -> None: ... -def disable() -> None: ... -def enable_debugging() -> None: ... -def disable_debugging() -> None: ... +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/prefetch.pyx + +__all__ = ['disable', 'disable_debugging', 'enable', 'enable_debugging'] + +def enable(): + """Turn on prefetching of managed memory.""" +def disable(): + """Turn off prefetching of managed memory.""" +def enable_debugging(): + """Enable prefetch debugging.""" +def disable_debugging(): + """Disable prefetch debugging.""" diff --git a/python/pylibcudf/pylibcudf/quantiles.pyi b/python/pylibcudf/pylibcudf/quantiles.pyi index 9af646407ab1..26fddd4a2c93 100644 --- a/python/pylibcudf/pylibcudf/quantiles.pyi +++ b/python/pylibcudf/pylibcudf/quantiles.pyi @@ -1,31 +1,93 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Iterable +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/quantiles.pyx +from pylibcudf.libcudf.types import interpolation, sorted from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.table import Table -from pylibcudf.types import Interpolation, NullOrder, Order, Sorted -from pylibcudf.utils import CudaStreamLike - -def quantile( - input: Column, - q: Iterable[float], - interp: Interpolation = Interpolation.LINEAR, - ordered_indices: Column | None = None, - exact: bool = True, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def quantiles( - input: Table, - q: Iterable[float], - interp: Interpolation = Interpolation.NEAREST, - is_input_sorted: Sorted = Sorted.NO, - column_order: list[Order] | None = None, - null_precedence: list[NullOrder] | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... +from .column import Column +from .table import Table + +__all__ = ['quantile', 'quantiles'] + +def quantile(input: Column, q: ..., interp: interpolation=interpolation.LINEAR, ordered_indices: Column | None=None, exact: bool=True, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes quantiles with interpolation. + + Computes the specified quantiles by interpolating values between which they lie, + using the interpolation strategy specified in interp. + + For details see :cpp:func:`quantile`. + + Parameters + ---------- + input: Column + The Column to calculate quantiles on. + q: array-like that implements buffer-protocol + The quantiles to calculate in range [0,1] + interp: Interpolation, default Interpolation.LINEAR + The strategy used to select between values adjacent to a specified quantile. + ordered_indices: Column, default empty column + The column containing the sorted order of input. + + If empty, all input values are used in existing order. + Indices must be in range [0, input.size()), but are not required to be unique. + Values not indexed by this column will be ignored. + exact: bool, default True + Returns doubles if True. Otherwise, returns same type as input + stream : Stream | None + CUDA stream on which to perform the operation. + + For details, see :cpp:func:`quantile`. + + Returns + ------- + Column + A Column containing specified quantiles, with nulls for indeterminable values + """ +def quantiles(input: Table, q: ..., interp: interpolation=interpolation.NEAREST, is_input_sorted: sorted=sorted.NO, column_order: list | None=None, null_precedence: list | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Computes row quantiles with interpolation. + + Computes the specified quantiles by retrieving the row corresponding to the + specified quantiles. In the event a quantile lies in between rows, the specified + interpolation strategy is used to pick between the rows. + + For details see :cpp:func:`quantiles`. + + Parameters + ---------- + input: Table + The Table to calculate row quantiles on. + q: array-like + The quantiles to calculate in range [0,1] + interp: Interpolation, default Interpolation.NEAREST + The strategy used to select between values adjacent to a specified quantile. + + Must be a non-arithmetic interpolation strategy + (i.e. one of + {`Interpolation.HIGHER`, `Interpolation.LOWER`, `Interpolation.NEAREST`}) + is_input_sorted: Sorted, default Sorted.NO + Whether the input table has been pre-sorted or not. + column_order: list, default None + A list of `Order` enums, + indicating the desired sort order for each column. + By default, will sort all columns so that they are in ascending order. + + Ignored if `is_input_sorted` is `Sorted.YES` + null_precedence: list, default None + A list of `NullOrder` enums, + indicating how nulls should be sorted. + By default, will sort all columns so that nulls appear before + all other elements. + + Ignored if `is_input_sorted` is `Sorted.YES` + stream : Stream | None + CUDA stream on which to perform the operation. + + For details, see :cpp:func:`quantiles`. + + Returns + ------- + Column + A Column containing specified quantiles, with nulls for indeterminable values + """ diff --git a/python/pylibcudf/pylibcudf/reduce.pyi b/python/pylibcudf/pylibcudf/reduce.pyi index ba6e2640f6c3..e919233f73f7 100644 --- a/python/pylibcudf/pylibcudf/reduce.pyi +++ b/python/pylibcudf/pylibcudf/reduce.pyi @@ -1,62 +1,191 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/reduce.pyx +from pylibcudf.libcudf.reduce import scan_type +from pylibcudf.libcudf.reduce import scan_type as ScanType +from pylibcudf.libcudf.types import (nan_policy, null_equality, null_policy, + size_type) from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf import Table -from pylibcudf.aggregation import Aggregation -from pylibcudf.column import Column -from pylibcudf.scalar import Scalar -from pylibcudf.types import DataType, NanPolicy, NullEquality, NullPolicy -from pylibcudf.utils import CudaStreamLike - -class ScanType(IntEnum): - INCLUSIVE = ... - EXCLUSIVE = ... - -def reduce( - col: Column, - agg: Aggregation, - data_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Scalar: ... -def scan( - col: Column, - agg: Aggregation, - inclusive: ScanType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def minmax( - col: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Scalar, Scalar]: ... -def is_valid_reduce_aggregation( - source: DataType, agg: Aggregation -) -> bool: ... -def unique_count( - source: Column, - null_handling: NullPolicy, - nan_handling: NanPolicy, - stream: CudaStreamLike | None = None, -) -> int: ... -def distinct_count( - source: Column, - null_handling: NullPolicy, - nan_handling: NanPolicy, - stream: CudaStreamLike | None = None, -) -> int: ... -def unique_count_table( - source: Table, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, -) -> int: ... -def distinct_count_table( - source: Table, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, -) -> int: ... +from .aggregation import Aggregation +from .column import Column +from .scalar import Scalar +from .table import Table +from .types import DataType + +__all__ = ['ScanType', 'distinct_count', 'is_valid_reduce_aggregation', 'minmax', 'reduce', 'scan', 'unique_count'] + +def reduce(col: Column, agg: Aggregation, data_type: DataType, init: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Scalar: + """Perform a reduction on a column + + For details, see ``cudf::reduce`` documentation. + + Parameters + ---------- + col : Column + The column to perform the reduction on. + agg : Aggregation + The aggregation to perform. + data_type : DataType + The data type of the result. + init : Scalar | None + The initial value for the reduction. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned scalar's device memory. + + Returns + ------- + Scalar + The result of the reduction. + """ +def scan(col: Column, agg: Aggregation, inclusive: scan_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a scan on a column + + For details, see ``cudf::scan`` documentation. + + Parameters + ---------- + col : Column + The column to perform the scan on. + agg : Aggregation + The aggregation to perform. + inclusive : scan_type + The type of scan to perform. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + The result of the scan. + """ +def minmax(col: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """Compute the minimum and maximum of a column + + For details, see ``cudf::minmax`` documentation. + + Parameters + ---------- + col : Column + The column to compute the minimum and maximum of. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned scalars' device memory. + + Returns + ------- + tuple + A tuple of two Scalars, the first being the minimum and the second + being the maximum. + """ +def is_valid_reduce_aggregation(source: DataType, agg: Aggregation) -> bool: + """ + Return if an aggregation is supported for a given datatype. + + Parameters + ---------- + source + The type of the column the aggregation is being performed on. + agg + The aggregation. + + Returns + ------- + True if the aggregation is supported. + """ +def unique_count(source: Column, null_handling: null_policy, nan_handling: nan_policy, stream: object | None=None) -> size_type: + """Returns the number of unique consecutive elements in the input column. + + For details, see :cpp:func:`cudf::unique_count`. + + Parameters + ---------- + source : Column + The input column to count the unique elements of. + null_handling : null_policy + Flag to include or exclude nulls from the count. If included, all + nulls compare equal. + nan_handling : nan_policy + Whether to treat NaNs as null, or valid elements. If valid all NaNs + compare equal. + + Returns + ------- + size_type + The number of unique consecutive elements in the input column. + + Notes + ----- + If the input column is sorted, then unique_count can produce the + same result as distinct_count, but faster. + """ +def distinct_count(source: Column, null_handling: null_policy, nan_handling: nan_policy, stream: object | None=None) -> size_type: + """Returns the number of distinct elements in the input column. + + For details, see :cpp:func:`cudf::distinct_count`. + + Parameters + ---------- + source : Column + The input column to count the unique elements of. + null_handling : null_policy + Flag to include or exclude nulls from the count. If included, all + nulls compare equal. + nan_handling : nan_policy + Whether to treat NaNs as null, or valid elements. If valid all NaNs + compare equal. + + Returns + ------- + size_type + The number of distinct elements in the input column. + """ +def unique_count_table(source: Table, nulls_equal: null_equality, stream: object | None=None) -> size_type: + """Returns the number of unique consecutive rows in the input table. + + For details, see :cpp:func:`cudf::unique_count`. + + Parameters + ---------- + source : Table + The input table to count the unique elements of. + nulls_equal : null_equality + Whether nulls should compare equal. + + Returns + ------- + size_type + The number of unique consecutive rows. + + Notes + ----- + NaNs compare equal in this comparison. + """ +def distinct_count_table(source: Table, nulls_equal: null_equality, stream: object | None=None) -> size_type: + """Returns the number of distinct rows in the input table. + + For details, see :cpp:func:`cudf::distinct_count`. + + Parameters + ---------- + source : Table + The input table to count the unique rows of. + nulls_equal : null_equality + Whether nulls should compare equal. + + Returns + ------- + size_type + The number of distinct rows. + + Notes + ----- + NaNs compare equal in this comparison. + """ diff --git a/python/pylibcudf/pylibcudf/replace.pyi b/python/pylibcudf/pylibcudf/replace.pyi index f74e06c3909e..66f5e8a29fdb 100644 --- a/python/pylibcudf/pylibcudf/replace.pyi +++ b/python/pylibcudf/pylibcudf/replace.pyi @@ -1,43 +1,122 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/replace.pyx +from pylibcudf.libcudf.replace import replace_policy as ReplacePolicy from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -class ReplacePolicy(IntEnum): - PRECEDING = ... - FOLLOWING = ... - -def replace_nulls( - source_column: Column, - replacement: Column | Scalar | ReplacePolicy, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def find_and_replace_all( - source_column: Column, - values_to_replace: Column, - replacement_values: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def clamp( - source_column: Column, - lo: Scalar, - hi: Scalar, - lo_replace: Scalar | None = None, - hi_replace: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def normalize_nans_and_zeros( - source_column: Column, - inplace: bool = False, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column +from .scalar import Scalar + +__all__ = ['ReplacePolicy', 'clamp', 'find_and_replace_all', 'normalize_nans_and_zeros', 'replace_nulls'] + +def replace_nulls(source_column: Column, replacement: object, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Replace nulls in source_column. + + The values used to replace nulls depends on the type of replacement: + - If replacement is a Column, the corresponding value from replacement + is used. + - If replacement is a Scalar, the same value is used for all nulls. + - If replacement is a replace_policy, the policy is used to determine + the replacement value: + + - PRECEDING: The first non-null value that precedes the null is used. + - FOLLOWING: The first non-null value that follows the null is used. + + For more details, see :cpp:func:`replace_nulls`. + + Parameters + ---------- + source_column : Column + The column in which to replace nulls. + replacement_column : Union[Column, Scalar, replace_policy] + If a Column, the values to use as replacements. If a Scalar, the value + to use as a replacement. If a replace_policy, the policy to use to + determine the replacement value. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + A copy of source_column with nulls replaced by values from + replacement_column. + """ +def find_and_replace_all(source_column: Column, values_to_replace: Column, replacement_values: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Replace all occurrences of values_to_replace with replacement_values. + + For details, see :cpp:func:`find_and_replace_all`. + + Parameters + ---------- + source_column : Column + The column in which to replace values. + values_to_replace : Column + The column containing values to replace. + replacement_values : Column + The column containing replacement values. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + A copy of source_column with all occurrences of values_to_replace + replaced by replacement_values. + """ +def clamp(source_column: Column, lo: Scalar, hi: Scalar, lo_replace: Scalar | None=None, hi_replace: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Clamp the values in source_column to the range [lo, hi]. + + For details, see :cpp:func:`clamp`. + + Parameters + ---------- + source_column : Column + The column to clamp. + lo : Scalar + The lower bound of the clamp range. + hi : Scalar + The upper bound of the clamp range. + lo_replace : Scalar, optional + The value to use for elements that are less than lo. If not specified, + the value of lo is used. + hi_replace : Scalar, optional + The value to use for elements that are greater than hi. If not + specified, the value of hi is used. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + A copy of source_column with values clamped to the range [lo, hi]. + """ +def normalize_nans_and_zeros(source_column: Column, inplace: bool=False, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Normalize NaNs and zeros in source_column. + + For details, see :cpp:func:`normalize_nans_and_zeros`. + + Parameters + ---------- + source_column : Column + The column to normalize. + inplace : bool, optional + If True, normalize source_column in place. If False, return a new + column with the normalized values. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + A copy of source_column with NaNs and zeros normalized. + """ diff --git a/python/pylibcudf/pylibcudf/reshape.pyi b/python/pylibcudf/pylibcudf/reshape.pyi index 03acda183531..c04867c97b6c 100644 --- a/python/pylibcudf/pylibcudf/reshape.pyi +++ b/python/pylibcudf/pylibcudf/reshape.pyi @@ -1,26 +1,75 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/reshape.pyx + +from pylibcudf.libcudf.types import size_type from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -def interleave_columns( - source_table: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def tile( - source_table: Table, - count: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def table_to_array( - input_table: Table, - ptr: int, - size: int, - stream: CudaStreamLike | None = None, -) -> None: ... +from .column import Column +from .table import Table + +__all__ = ['interleave_columns', 'tile', 'table_to_array'] + +def interleave_columns(source_table: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Interleave columns of a table into a single column. + + Converts the column major table `input` into a row major column. + + Example: + in = [[A1, A2, A3], [B1, B2, B3]] + return = [A1, B1, A2, B2, A3, B3] + + For details, see :cpp:func:`interleave_columns`. + + Parameters + ---------- + source_table: Table + The input table to interleave + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + A new column which is the result of interleaving the input columns + """ +def tile(source_table: Table, count: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Repeats the rows from input table count times to form a new table. + + For details, see :cpp:func:`tile`. + + Parameters + ---------- + source_table: Table + The input table containing rows to be repeated + count: size_type + The number of times to tile "rows". Must be non-negative + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + Table + The table containing the tiled "rows" + """ +def table_to_array(input_table: Table, ptr: int, size: int, stream: object | None=None) -> None: + """ + Copy a table into a preallocated column-major device array. + + Parameters + ---------- + input_table : Table + A table with fixed-width, non-nullable columns of the same type. + ptr : uintptr_t + A device pointer to the beginning of the output buffer. + size : size_t + The total number of bytes available at `ptr`. + Must be at least `num_rows * num_columns * sizeof(dtype)`. + stream : Stream | None + CUDA stream on which to perform the operation. + """ diff --git a/python/pylibcudf/pylibcudf/rolling.pyi b/python/pylibcudf/pylibcudf/rolling.pyi index 883f62d0d3f5..95cd36e7a030 100644 --- a/python/pylibcudf/pylibcudf/rolling.pyi +++ b/python/pylibcudf/pylibcudf/rolling.pyi @@ -1,63 +1,182 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/rolling.pyx + +from typing import TypeVar + +from pylibcudf.libcudf.types import null_order, order, size_type from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.aggregation import Aggregation -from pylibcudf.column import Column -from pylibcudf.scalar import Scalar -from pylibcudf.table import Table -from pylibcudf.types import DataType, NullOrder, Order -from pylibcudf.utils import CudaStreamLike +from .aggregation import Aggregation +from .column import Column +from .scalar import Scalar +from .table import Table +from .types import DataType + +WindowType = TypeVar('WindowType', Column, size_type) +__all__ = ['BoundedClosed', 'BoundedOpen', 'CurrentRow', 'RollingRequest', 'Unbounded', 'grouped_range_rolling_window', 'rolling_window'] + +class Unbounded: + """ + An unbounded rolling window. + + This window runs to the begin/end of the current row's group. + """ + def __init__(self): ... + +class CurrentRow: + """ + A current row rolling window. -class Unbounded: ... -class CurrentRow: ... + This window contains all rows that are equal to the current row in the group. + """ + def __init__(self): ... class BoundedClosed: - def __init__(self, delta: Scalar) -> None: ... + """ + A bounded closed window. + + This window contains rows with delta of the current row, endpoints included. + + Parameters + ---------- + delta + Offset from current row, must be valid. If floating point must not be inf/nan. + """ delta: Scalar + def __init__(self, delta: Scalar): ... + class BoundedOpen: - def __init__(self, delta: Scalar) -> None: ... + """ + A bounded open window. + + This window contains rows with delta of the current row, endpoints excluded. + + Parameters + ---------- + delta + Offset from current row, must be valid. If floating point must not be inf/nan. + """ delta: Scalar + def __init__(self, delta: Scalar): ... + class RollingRequest: - def __init__( - self, values: Column, min_periods: int, aggregation: Aggregation - ) -> None: ... - -RangeWindowType = BoundedClosed | BoundedOpen | CurrentRow | Unbounded - -def grouped_range_rolling_window( - group_keys: Table, - orderby: Column, - order: Order, - null_order: NullOrder, - preceding: RangeWindowType, - following: RangeWindowType, - requests: list[RollingRequest], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def rolling_window[WindowType: (Column, int)]( - source: Column, - preceding_window: WindowType, - following_window: WindowType, - min_periods: int, - agg: Aggregation, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_valid_rolling_aggregation( - source: DataType, agg: Aggregation -) -> bool: ... -def make_range_windows( - group_keys: Table, - orderby: Column, - order: Order, - null_order: NullOrder, - preceding: RangeWindowType, - following: RangeWindowType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Column, Column]: ... + """ + A request for a rolling aggregation. + + Parameters + ---------- + values + The column of values to aggregate. + min_periods + The minimum number of observations required for a valid result + in a given window. + aggregation + The aggregation to perform. + """ + def __init__(self, values: Column, min_periods: size_type, aggregation: Aggregation): ... + +def grouped_range_rolling_window(group_keys: Table, orderby: Column, order: order, null_order: null_order, preceding: BoundedClosed | BoundedOpen | CurrentRow | Unbounded, following: BoundedClosed | BoundedOpen | CurrentRow | Unbounded, requests: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Perform grouping-aware range-based rolling window aggregations on some columns. + + Parameters + ---------- + group_keys + Possibly empty table of sorted keys defining groups. + orderby + Column defining window ranges. Must be sorted, if + ``group_keys`` is not empty, must be sorted groupwise. + order + Sort order of the ``orderby`` column. + null_order + Null sort order in the sorted ``orderby`` column + preceding + The type of the preceding window offset. + following + The type of the following window offset. + requests + List of :class:`RollingRequest` objects. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + A table of results, one column per input request, in order of the + input requests. + """ +def rolling_window(source: Column, preceding_window: WindowType, following_window: WindowType, min_periods: size_type, agg: Aggregation, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a rolling window operation on a column + + For details, see ``cudf::rolling_window`` documentation. + + Parameters + ---------- + source : Column + The column to perform the rolling window operation on. + preceding_window : Union[Column, size_type] + The column containing the preceding window sizes or a scalar value + indicating the sizes of all windows. + following_window : Union[Column, size_type] + The column containing the following window sizes or a scalar value + indicating the sizes of all windows. + min_periods : int + The minimum number of periods to include in the result. + agg : Aggregation + The aggregation to perform. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + The result of the rolling window operation. + """ +def is_valid_rolling_aggregation(source: DataType, agg: Aggregation) -> bool: + """ + Return if a rolling aggregation is supported for a given datatype. + + Parameters + ---------- + source + The type of the column the aggregation is being performed on. + agg + The aggregation. + + Returns + ------- + True if the aggregation is supported. + """ +def make_range_windows(group_keys: Table, orderby: Column, order: order, null_order: null_order, preceding: BoundedClosed | BoundedOpen | CurrentRow | Unbounded, following: BoundedClosed | BoundedOpen | CurrentRow | Unbounded, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple: + """ + Constructs preceding and following columns given window range specifications. + + Parameters + ---------- + group_keys + Possibly empty table of sorted keys defining groups. + orderby + Column defining window ranges. Must be sorted, if + ``group_keys`` is not empty, must be sorted groupwise. + order + Sort order of the ``orderby`` column. + null_order + Null sort order in the sorted ``orderby`` column + preceding + The type of the preceding window offset. + following + The type of the following window offset. + + Returns + ------- + tuple[Column, Column] + A tuple of preceding and following columns that define the window bounds + for each row suitable for passing to `rolling_window`. + """ diff --git a/python/pylibcudf/pylibcudf/round.pyi b/python/pylibcudf/pylibcudf/round.pyi index 30d08f234d59..dfc36547543b 100644 --- a/python/pylibcudf/pylibcudf/round.pyi +++ b/python/pylibcudf/pylibcudf/round.pyi @@ -1,28 +1,68 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/round.pyx +from pylibcudf.libcudf.round import rounding_method +from pylibcudf.libcudf.round import rounding_method as RoundingMethod from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -class RoundingMethod(IntEnum): - HALF_UP = ... - HALF_EVEN = ... - -def round( - source: Column, - decimal_places: int = 0, - round_method: RoundingMethod = RoundingMethod.HALF_UP, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def round_decimal( - source: Column, - decimal_places: int = 0, - round_method: RoundingMethod = RoundingMethod.HALF_UP, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column + +__all__ = ['RoundingMethod', 'round'] + +def round(source: Column, decimal_places: int=0, round_method: rounding_method=rounding_method.HALF_UP, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Rounds all the values in a column to the specified number of decimal places. + + .. deprecated:: release 26.04 + round is deprecated for float type. + Use ``round_decimal`` for decimal and integer types. + + For details, see :cpp:func:`round`. + + Parameters + ---------- + source : Column + The Column for which to round values. + decimal_places: int32_t, optional + The number of decimal places to round to (default 0) + round_method: rounding_method, optional + The method by which to round each value. + Can be one of { RoundingMethod.HALF_UP, RoundingMethod.HALF_EVEN } + (default rounding_method.HALF_UP) + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + A Column with values rounded + """ +def round_decimal(source: Column, decimal_places: int=0, round_method: rounding_method=rounding_method.HALF_UP, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Rounds all the values in a column to the specified number of decimal places. + Only decimal and integer types are supported. + + For details, see :cpp:func:`round_decimal`. + + Parameters + ---------- + source : Column + The Column for which to round values. + decimal_places: int32_t, optional + The number of decimal places to round to (default 0) + round_method: rounding_method, optional + The method by which to round each value. + Can be one of { RoundingMethod.HALF_UP, RoundingMethod.HALF_EVEN } + (default rounding_method.HALF_UP) + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + A Column with values rounded + """ diff --git a/python/pylibcudf/pylibcudf/scalar.pyi b/python/pylibcudf/pylibcudf/scalar.pyi index a204894afd8d..6af802ab3943 100644 --- a/python/pylibcudf/pylibcudf/scalar.pyi +++ b/python/pylibcudf/pylibcudf/scalar.pyi @@ -1,47 +1,146 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from typing import Any +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/scalar.pyx -from pylibcudf._interop_helpers import ColumnMetadata -from pylibcudf.column import Column -from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike +import datetime +import decimal +from functools import singledispatch +from typing import Any, overload -NpGeneric = type[Any] +from cpython import bool as py_bool +from cython import no_gc_clear +from rmm.pylibrmm.memory_resource import DeviceMemoryResource +from rmm.pylibrmm.stream import Stream -PaScalar = type[Any] +from ._interop_helpers import ArrowLike, ColumnMetadata +from .types import DataType +__all__ = ['Scalar'] + +@no_gc_clear class Scalar: - def __init__(self): ... - def type(self) -> DataType: ... - def is_valid(self, stream: CudaStreamLike) -> bool: ... - @staticmethod - def empty_like( - column: Column, stream: CudaStreamLike | None = None - ) -> Scalar: ... - def to_arrow( - self, - metadata: ColumnMetadata | str | None = None, - stream: CudaStreamLike | None = None, - ) -> PaScalar: ... + """A scalar value in device memory. + + This is the Cython representation of :cpp:class:`cudf::scalar`. + """ + __hash__ = None + + def __init__(self, *args, **kwargs): ... + def type(self) -> DataType: + """The type of data in the column.""" + def is_valid(self, stream: object | None=None) -> bool: + """True if the scalar is valid, false if not""" + def to_arrow(self, metadata: ColumnMetadata | str | None=None, stream: Stream | None=None) -> ArrowLike: + """Create a PyArrow array from a pylibcudf scalar. + + Parameters + ---------- + metadata : ColumnMetadata | str | None + The metadata to attach to the scalar. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pyarrow.Scalar + """ @staticmethod - def from_arrow( - pa_val: Any, - dtype: DataType | None = None, - stream: CudaStreamLike | None = None, - ) -> Scalar: ... + def from_arrow(pa_val, dtype: DataType | None=None, stream: Stream | None=None) -> Scalar: + """ + Convert a pyarrow scalar to a pylibcudf.Scalar. + + Parameters + ---------- + pa_val: pyarrow scalar + Value to convert to a pylibcudf.Scalar + dtype: DataType | None + The datatype to cast the value to. If None, + the type is inferred from the pyarrow scalar. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Scalar + New pylibcudf.Scalar + """ @classmethod - def from_py( - cls, - py_val: Any, - dtype: DataType | None = None, - stream: CudaStreamLike | None = None, - ) -> Scalar: ... + def from_py(cls, py_val, dtype: DataType | None=None, stream: Stream | None=None, mr: DeviceMemoryResource | None=None): + """ + Convert a Python standard library object to a Scalar. + + Parameters + ---------- + py_val: None, bool, int, float, str, datetime, timedelta, list, dict + Value to convert to a pylibcudf.Scalar + dtype: DataType | None + The datatype to cast the value to. If None, + the type is inferred from `py_val`. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Memory resource for allocations + + Returns + ------- + Scalar + New pylibcudf.Scalar + """ @classmethod - def from_numpy( - cls, np_val: NpGeneric, stream: CudaStreamLike | None = None - ) -> Scalar: ... - def to_py( - self, stream: CudaStreamLike | None = None - ) -> None | int | float | str | bool: ... + def from_numpy(cls, np_val, stream: Stream | None=None, mr: DeviceMemoryResource | None=None): + """ + Convert a NumPy scalar to a Scalar. + + Parameters + ---------- + np_val: numpy.generic + Value to convert to a pylibcudf.Scalar + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Memory resource for allocations + + Returns + ------- + Scalar + New pylibcudf.Scalar + """ + def to_py(self, stream: Stream | None=None): + """ + Convert a Scalar to a Python scalar. + + Parameters + ---------- + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Python scalar + A Python scalar associated with the type of the Scalar. + """ + +@overload +def _from_py(py_val: type(None), dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: dict, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: list, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: float, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: int, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: py_bool, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: str, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: datetime.timedelta, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: datetime.date, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@overload +def _from_py(py_val: decimal.Decimal, dtype: DataType | None, stream: Stream, mr: DeviceMemoryResource) -> Any: ... +@singledispatch +def _from_numpy(np_val, stream: Stream, mr: DeviceMemoryResource): ... +def _from_arrow(obj: ..., dtype: DataType | None=None, stream: Stream | None=None) -> Scalar: ... diff --git a/python/pylibcudf/pylibcudf/search.pyi b/python/pylibcudf/pylibcudf/search.pyi index 6cc58946f560..bd227cbff4c9 100644 --- a/python/pylibcudf/pylibcudf/search.pyi +++ b/python/pylibcudf/pylibcudf/search.pyi @@ -1,32 +1,83 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/search.pyx + from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.table import Table -from pylibcudf.types import NullOrder, Order -from pylibcudf.utils import CudaStreamLike - -def lower_bound( - haystack: Table, - needles: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def upper_bound( - haystack: Table, - needles: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def contains( - haystack: Column, - needles: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column +from .table import Table + +__all__ = ['contains', 'lower_bound', 'upper_bound'] + +def lower_bound(haystack: Table, needles: Table, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Find smallest indices in haystack where needles may be inserted to retain order. + + For details, see :cpp:func:`lower_bound`. + + Parameters + ---------- + haystack : Table + The search space. + needles : Table + The values for which to find insertion points. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + The insertion points + """ +def upper_bound(haystack: Table, needles: Table, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Find largest indices in haystack where needles may be inserted to retain order. + + For details, see :cpp:func:`upper_bound`. + + Parameters + ---------- + haystack : Table + The search space. + needles : Table + The values for which to find insertion points. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + The insertion points + """ +def contains(haystack: Column, needles: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Check whether needles are present in haystack. + + For details, see :cpp:func:`contains`. + + Parameters + ---------- + haystack : Column + The search space. + needles : Column + The values for which to search. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + Boolean indicator for each needle. + """ diff --git a/python/pylibcudf/pylibcudf/sorting.pyi b/python/pylibcudf/pylibcudf/sorting.pyi index a06586a8f39d..e98f6450128d 100644 --- a/python/pylibcudf/pylibcudf/sorting.pyi +++ b/python/pylibcudf/pylibcudf/sorting.pyi @@ -1,103 +1,269 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/sorting.pyx + +from pylibcudf.libcudf.aggregation import rank_method +from pylibcudf.libcudf.types import null_order, null_policy, order, size_type from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.aggregation import RankMethod -from pylibcudf.column import Column -from pylibcudf.table import Table -from pylibcudf.types import NullOrder, NullPolicy, Order -from pylibcudf.utils import CudaStreamLike - -def sorted_order( - source_table: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def stable_sorted_order( - source_table: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def rank( - input_view: Column, - method: RankMethod, - column_order: Order, - null_handling: NullPolicy, - null_precedence: NullOrder, - percentage: bool, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_sorted( - tbl: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, -) -> bool: ... -def segmented_sort_by_key( - values: Table, - keys: Table, - segment_offsets: Column, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def stable_segmented_sort_by_key( - values: Table, - keys: Table, - segment_offsets: Column, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def sort_by_key( - values: Table, - keys: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def stable_sort_by_key( - values: Table, - keys: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def sort( - source_table: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def stable_sort( - source_table: Table, - column_order: list[Order], - null_precedence: list[NullOrder], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def top_k( - col: Column, - k: int, - sort_order: Order = Order.DESCENDING, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def top_k_order( - col: Column, - k: int, - sort_order: Order = Order.DESCENDING, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from .column import Column +from .table import Table + +__all__ = ['is_sorted', 'rank', 'segmented_sort_by_key', 'sort', 'sort_by_key', 'sorted_order', 'stable_segmented_sort_by_key', 'stable_sort', 'stable_sort_by_key', 'stable_sorted_order', 'top_k', 'top_k_order'] + +def sorted_order(source_table: Table, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the row indices required to sort the table. + + For details, see :cpp:func:`sorted_order`. + + Parameters + ---------- + source_table : Table + The table to sort. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + + Returns + ------- + Column + The row indices required to sort the table. + """ +def stable_sorted_order(source_table: Table, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the row indices required to sort the table, + preserving order of equal elements. + + For details, see :cpp:func:`stable_sorted_order`. + + Parameters + ---------- + source_table : Table + The table to sort. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + + Returns + ------- + Column + The row indices required to sort the table. + """ +def rank(input_view: Column, method: rank_method, column_order: order, null_handling: null_policy, null_precedence: null_order, percentage: bool, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Computes the rank of each element in the column. + + For details, see :cpp:func:`rank`. + + Parameters + ---------- + input_view : Column + The column to rank. + method : rank_method + The method to use for ranking ties. + column_order : order + Whether the column should be sorted in ascending or descending order. + null_handling : null_policy + Whether or not nulls should be included in the ranking. + null_precedence : null_order + Whether nulls should come before or after non-nulls. + percentage : bool + Whether to return the rank as a percentage. + + Returns + ------- + Column + The rank of each element in the column. + """ +def is_sorted(tbl: Table, column_order: list, null_precedence: list, stream: object | None=None) -> bool: + """Checks if the table is sorted. + + For details, see :cpp:func:`is_sorted`. + + Parameters + ---------- + tbl : Table + The table to check. + column_order : List[ColumnOrder] + Whether each column is expected to be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls are expected before or after non-nulls. + + Returns + ------- + bool + Whether the table is sorted. + """ +def segmented_sort_by_key(values: Table, keys: Table, segment_offsets: Column, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Sorts the table by key, within segments. + + For details, see :cpp:func:`segmented_sort_by_key`. + + Parameters + ---------- + values : Table + The table to sort. + keys : Table + The table to sort by. + segment_offsets : Column + The offsets of the segments. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + + Returns + ------- + Table + The sorted table. + """ +def stable_segmented_sort_by_key(values: Table, keys: Table, segment_offsets: Column, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Sorts the table by key preserving order of equal elements, + within segments. + + For details, see :cpp:func:`stable_segmented_sort_by_key`. + + Parameters + ---------- + values : Table + The table to sort. + keys : Table + The table to sort by. + segment_offsets : Column + The offsets of the segments. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + + Returns + ------- + Table + The sorted table. + """ +def sort_by_key(values: Table, keys: Table, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Sorts the table by key. + + For details, see :cpp:func:`sort_by_key`. + + Parameters + ---------- + values : Table + The table to sort. + keys : Table + The table to sort by. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + + Returns + ------- + Table + The sorted table. + """ +def stable_sort_by_key(values: Table, keys: Table, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Sorts the table by key preserving order of equal elements. + + For details, see :cpp:func:`stable_sort_by_key`. + + Parameters + ---------- + values : Table + The table to sort. + keys : Table + The table to sort by. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + + Returns + ------- + Table + The sorted table. + """ +def sort(source_table: Table, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Sorts the table. + + For details, see :cpp:func:`sort`. + + Parameters + ---------- + source_table : Table + The table to sort. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + + Returns + ------- + Table + The sorted table. + """ +def stable_sort(source_table: Table, column_order: list, null_precedence: list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Sorts the table preserving order of equal elements. + + For details, see :cpp:func:`stable_sort`. + + Parameters + ---------- + source_table : Table + The table to sort. + column_order : List[ColumnOrder] + Whether each column should be sorted in ascending or descending order. + null_precedence : List[NullOrder] + Whether nulls should come before or after non-nulls. + + Returns + ------- + Table + The sorted table. + """ +def top_k(col: Column, k: size_type, sort_order: order=order.DESCENDING, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Computes the top-k values of a column. + + For details, see :cpp:func:`top_k`. + + Parameters + ---------- + col : Column + The input column. + k : int + The number of top values to retrieve. + sort_order : Order, default DESCENDING + The desired order of the top values. If ASCENDING, the smallest `k` values + are returned. If DESCENDING, the largest `k` values are returned. + + Returns + ------- + Column + A column of the top ``k`` elements from the input. + """ +def top_k_order(col: Column, k: size_type, sort_order: order=order.DESCENDING, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Computes the indices of the top-k values of a column. + + This returns the row indices of the top-k elements. + + For details, see :cpp:func:`top_k_order`. + + Parameters + ---------- + col : Column + The input column. + k : int + The number of top values to retrieve. + sort_order : Order, default DESCENDING + The desired order of the top values. If ASCENDING, the indices of the smallest + `k` values are returned. If DESCENDING, the indices of the largest `k` values + are returned. + + Returns + ------- + Column + A column of the indices of the top ``k`` elements. + """ diff --git a/python/pylibcudf/pylibcudf/stream_compaction.pyi b/python/pylibcudf/pylibcudf/stream_compaction.pyi index 76e669f89951..b34f7ac6becc 100644 --- a/python/pylibcudf/pylibcudf/stream_compaction.pyi +++ b/python/pylibcudf/pylibcudf/stream_compaction.pyi @@ -1,86 +1,204 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/stream_compaction.pyx +from pylibcudf.libcudf.stream_compaction import duplicate_keep_option +from pylibcudf.libcudf.stream_compaction import \ + duplicate_keep_option as DuplicateKeepOption +from pylibcudf.libcudf.types import nan_equality, null_equality, size_type from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.expressions import Expression -from pylibcudf.table import Table -from pylibcudf.types import NanEquality, NullEquality -from pylibcudf.utils import CudaStreamLike - -class DuplicateKeepOption(IntEnum): - KEEP_ANY = ... - KEEP_FIRST = ... - KEEP_LAST = ... - KEEP_NONE = ... - -def drop_nulls( - source_table: Table, - keys: list[int], - keep_threshold: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def drop_nans( - source_table: Table, - keys: list[int], - keep_threshold: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def apply_boolean_mask( - source_table: Table, - boolean_mask: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def apply_deletion_mask( - source_table: Table, - deletion_mask: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def unique( - input: Table, - keys: list[int], - keep: DuplicateKeepOption, - nulls_equal: NullEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def distinct( - input: Table, - keys: list[int], - keep: DuplicateKeepOption, - nulls_equal: NullEquality, - nans_equal: NanEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def distinct_indices( - input: Table, - keep: DuplicateKeepOption, - nulls_equal: NullEquality, - nans_equal: NanEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def stable_distinct( - input: Table, - keys: list[int], - keep: DuplicateKeepOption, - nulls_equal: NullEquality, - nans_equal: NanEquality, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def filter( - predicate_table: Table, - predicate_expr: Expression, - filter_table: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... +from .column import Column +from .expressions import Expression +from .table import Table + +__all__ = ['DuplicateKeepOption', 'apply_boolean_mask', 'apply_deletion_mask', 'distinct', 'distinct_indices', 'drop_nans', 'drop_nulls', 'filter', 'stable_distinct', 'unique'] + +def drop_nulls(source_table: Table, keys: list, keep_threshold: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Filters out rows from the input table based on the presence of nulls. + + For details, see :cpp:func:`drop_nulls`. + + Parameters + ---------- + source_table : Table + The input table to filter. + keys : List[size_type] + The list of column indexes to consider for null filtering. + keep_threshold : size_type + The minimum number of non-nulls required to keep a row. + + Returns + ------- + Table + A new table with rows removed based on the null count. + """ +def drop_nans(source_table: Table, keys: list, keep_threshold: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Filters out rows from the input table based on the presence of NaNs. + + For details, see :cpp:func:`drop_nans`. + + Parameters + ---------- + source_table : Table + The input table to filter. + keys : List[size_type] + The list of column indexes to consider for NaN filtering. + keep_threshold : size_type + The minimum number of non-NaNs required to keep a row. + + Returns + ------- + Table + A new table with rows removed based on NaNs. + """ +def apply_boolean_mask(source_table: Table, boolean_mask: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Filters out rows from the input table based on a boolean mask. + + For details, see :cpp:func:`apply_boolean_mask`. + + Parameters + ---------- + source_table : Table + The input table to filter. + boolean_mask : Column + The boolean mask to apply to the input table. + + Returns + ------- + Table + A new table with rows removed based on the boolean mask. + """ +def apply_deletion_mask(source_table: Table, deletion_mask: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Filters out rows from the input table using a deletion mask. + + For details, see :cpp:func:`apply_deletion_mask`. + + Parameters + ---------- + source_table : Table + The input table to filter. + deletion_mask : Column + A boolean column used as a deletion mask. + + Returns + ------- + Table + Table with rows removed where deletion_mask is true. + """ +def unique(input: Table, keys: list, keep: duplicate_keep_option, nulls_equal: null_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Filter duplicate consecutive rows from the input table. + + For details, see :cpp:func:`unique`. + + Parameters + ---------- + input : Table + The input table to filter + keys : list[int] + The list of column indexes to consider for filtering. + keep : duplicate_keep_option + The option to specify which rows to keep in the case of duplicates. + nulls_equal : null_equality + The option to specify how nulls are handled in the comparison. + + Returns + ------- + Table + New Table with unique rows from each sequence of equivalent rows + as specified by keep. In the same order as the input table. + + Notes + ----- + If the input columns to be filtered on are sorted, then + unique can produce the same result as stable_distinct, but faster. + """ +def distinct(input: Table, keys: list, keep: duplicate_keep_option, nulls_equal: null_equality, nans_equal: nan_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Get the distinct rows from the input table. + + For details, see :cpp:func:`distinct`. + + Parameters + ---------- + input : Table + The input table to filter. + keys : list + The list of column indexes to consider for distinct filtering. + keep : duplicate_keep_option + The option to specify which rows to keep in the case of duplicates. + nulls_equal : null_equality + The option to specify how nulls are handled in the comparison. + nans_equal : nan_equality + The option to specify how NaNs are handled in the comparison. + + Returns + ------- + Table + A new table with distinct rows from the input table. The + output will not necessarily be in the same order as the input. + """ +def distinct_indices(input: Table, keep: duplicate_keep_option, nulls_equal: null_equality, nans_equal: nan_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Get the indices of the distinct rows from the input table. + + For details, see :cpp:func:`distinct_indices`. + + Parameters + ---------- + input : Table + The input table to filter. + keep : duplicate_keep_option + The option to specify which rows to keep in the case of duplicates. + nulls_equal : null_equality + The option to specify how nulls are handled in the comparison. + nans_equal : nan_equality + The option to specify how NaNs are handled in the comparison. + + Returns + ------- + Column + A new column with the indices of the distinct rows from the input table. + """ +def stable_distinct(input: Table, keys: list, keep: duplicate_keep_option, nulls_equal: null_equality, nans_equal: nan_equality, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Get the distinct rows from the input table, preserving input order. + + For details, see :cpp:func:`stable_distinct`. + + Parameters + ---------- + input : Table + The input table to filter. + keys : list + The list of column indexes to consider for distinct filtering. + keep : duplicate_keep_option + The option to specify which rows to keep in the case of duplicates. + nulls_equal : null_equality + The option to specify how nulls are handled in the comparison. + nans_equal : nan_equality + The option to specify how NaNs are handled in the comparison. + + Returns + ------- + Table + A new table with distinct rows from the input table, preserving + the input table order. + """ +def filter(predicate_table: Table, predicate_expr: Expression, filter_table: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Filters a table using a predicate expression. + + For details, see :cpp:func:`filter`. + + Parameters + ---------- + predicate_table : Table + The table used for predicate expression evaluation. + predicate_expr : Expression + The predicate filter expression. + filter_table : Table + The table to be filtered. + + Returns + ------- + Table + The filtered table. + """ diff --git a/python/pylibcudf/pylibcudf/strings/attributes.pyi b/python/pylibcudf/pylibcudf/strings/attributes.pyi index 2e28fb9f186f..5c845efc66a7 100644 --- a/python/pylibcudf/pylibcudf/strings/attributes.pyi +++ b/python/pylibcudf/pylibcudf/strings/attributes.pyi @@ -1,23 +1,61 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/attributes.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def count_characters( - source_strings: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def count_bytes( - source_strings: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def code_points( - source_strings: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['code_points', 'count_bytes', 'count_characters'] + +def count_characters(source_strings: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a column containing character lengths of each string + in the given column. + + Parameters + ---------- + source_strings : Column + Column of strings. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with lengths for each string + """ +def count_bytes(source_strings: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a column containing byte lengths of each string + in the given column. + + Parameters + ---------- + source_strings : Column + Column of strings. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with the number of bytes for each string + """ +def code_points(source_strings: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Creates a numeric column with code point values (integers) + for each character of each string. + + Parameters + ---------- + source_strings : Column + Column of strings. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with code point integer values for each character + """ diff --git a/python/pylibcudf/pylibcudf/strings/capitalize.pyi b/python/pylibcudf/pylibcudf/strings/capitalize.pyi index 031d244bf250..6645bdae6d65 100644 --- a/python/pylibcudf/pylibcudf/strings/capitalize.pyi +++ b/python/pylibcudf/pylibcudf/strings/capitalize.pyi @@ -1,27 +1,62 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/capitalize.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.strings.char_types import string_character_types from pylibcudf.scalar import Scalar -from pylibcudf.strings.char_types import StringCharacterTypes -from pylibcudf.utils import CudaStreamLike - -def capitalize( - input: Column, - delimiters: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def title( - input: Column, - sequence_type: StringCharacterTypes = StringCharacterTypes.ALPHA, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_title( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['capitalize', 'is_title', 'title'] + +def capitalize(input: Column, delimiters: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Returns a column of capitalized strings. + + For details, see :cpp:func:`capitalize`. + + Parameters + ---------- + input : Column + String column + delimiters : Scalar, default None + Characters for identifying words to capitalize + + Returns + ------- + pylibcudf.Column + Column of strings capitalized from the input column + """ +def title(input: Column, sequence_type: string_character_types=string_character_types.ALPHA, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Modifies first character of each word to upper-case and lower-cases + the rest. + + For details, see :cpp:func:`title`. + + Parameters + ---------- + input : Column + String column + sequence_type : string_character_types, default string_character_types.ALPHA + The character type that is used when identifying words + + Returns + ------- + pylibcudf.Column + Column of titled strings + """ +def is_title(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Checks if the strings in the input column are title formatted. + + For details, see :cpp:func:`is_title`. + + Parameters + ---------- + input : Column + String column + + Returns + ------- + pylibcudf.Column + Column of type BOOL8 + """ diff --git a/python/pylibcudf/pylibcudf/strings/case.pyi b/python/pylibcudf/pylibcudf/strings/case.pyi index 1337e7df5a93..a359227e49eb 100644 --- a/python/pylibcudf/pylibcudf/strings/case.pyi +++ b/python/pylibcudf/pylibcudf/strings/case.pyi @@ -1,23 +1,69 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/case.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def to_lower( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def to_upper( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def swapcase( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['swapcase', 'to_lower', 'to_upper'] + +def to_lower(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Returns a column of lowercased strings. + + For details, see :cpp:func:`to_lower`. + + Parameters + ---------- + input : Column + String column + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + Column of strings lowercased from the input column + """ +def to_upper(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Returns a column of uppercased strings. + + For details, see :cpp:func:`to_upper`. + + Parameters + ---------- + input : Column + String column + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + Column of strings uppercased from the input column + """ +def swapcase(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Returns a column of strings where the lowercase characters + are converted to uppercase and the uppercase characters + are converted to lowercase. + + For details, see :cpp:func:`swapcase`. + + Parameters + ---------- + input : Column + String column + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + Column of strings + """ diff --git a/python/pylibcudf/pylibcudf/strings/char_types.pyi b/python/pylibcudf/pylibcudf/strings/char_types.pyi index 1740a67eb00f..ca80b85145dd 100644 --- a/python/pylibcudf/pylibcudf/strings/char_types.pyi +++ b/python/pylibcudf/pylibcudf/strings/char_types.pyi @@ -1,38 +1,58 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum - -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/char_types.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.strings.char_types import string_character_types +from pylibcudf.libcudf.strings.char_types import \ + string_character_types as StringCharacterTypes from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -class StringCharacterTypes(IntEnum): - DECIMAL = ... - NUMERIC = ... - DIGIT = ... - ALPHA = ... - SPACE = ... - UPPER = ... - LOWER = ... - ALPHANUM = ... - CASE_TYPES = ... - ALL_TYPES = ... - -def all_characters_of_type( - source_strings: Column, - types: StringCharacterTypes, - verify_types: StringCharacterTypes, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def filter_characters_of_type( - source_strings: Column, - types_to_remove: StringCharacterTypes, - replacement: Scalar, - types_to_keep: StringCharacterTypes, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['StringCharacterTypes', 'all_characters_of_type', 'filter_characters_of_type'] + +def all_characters_of_type(source_strings: Column, types: string_character_types, verify_types: string_character_types, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Identifies strings where all characters match the specified type. + + Parameters + ---------- + source_strings : Column + Strings instance for this operation + types : StringCharacterTypes + The character types to check in each string + verify_types : StringCharacterTypes + Only verify against these character types. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of boolean results for each string + """ +def filter_characters_of_type(source_strings: Column, types_to_remove: string_character_types, replacement: Scalar, types_to_keep: string_character_types, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Filter specific character types from a column of strings. + + Parameters + ---------- + source_strings : Column + Strings instance for this operation + types_to_remove : StringCharacterTypes + The character types to check in each string. + replacement : Scalar + The replacement character to use when removing characters + types_to_keep : StringCharacterTypes + Default `ALL_TYPES` means all characters of `types_to_remove` + will be filtered. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with the specified characters filtered out and + replaced with the specified replacement string. + """ diff --git a/python/pylibcudf/pylibcudf/strings/combine.pyi b/python/pylibcudf/pylibcudf/strings/combine.pyi index 3186709996fd..c36301a7c738 100644 --- a/python/pylibcudf/pylibcudf/strings/combine.pyi +++ b/python/pylibcudf/pylibcudf/strings/combine.pyi @@ -1,46 +1,103 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum - -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/combine.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.strings.combine import output_if_empty_list +from pylibcudf.libcudf.strings.combine import \ + output_if_empty_list as OutputIfEmptyList +from pylibcudf.libcudf.strings.combine import separator_on_nulls +from pylibcudf.libcudf.strings.combine import \ + separator_on_nulls as SeparatorOnNulls from pylibcudf.scalar import Scalar from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -class SeparatorOnNulls(IntEnum): - YES = ... - NO = ... - -class OutputIfEmptyList(IntEnum): - EMPTY_STRING = ... - NULL_ELEMENT = ... - -def concatenate( - strings_columns: Table, - separator: Column | Scalar, - narep: Scalar | None = None, - col_narep: Scalar | None = None, - separate_nulls: SeparatorOnNulls = SeparatorOnNulls.YES, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def join_strings( - input: Column, - separator: Scalar, - narep: Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def join_list_elements( - lists_strings_column: Column, - separator: Column | Scalar, - separator_narep: Scalar, - string_narep: Scalar, - separate_nulls: SeparatorOnNulls, - empty_list_policy: OutputIfEmptyList, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['OutputIfEmptyList', 'SeparatorOnNulls', 'concatenate', 'join_list_elements', 'join_strings'] + +def concatenate(strings_columns: Table, separator: Column | Scalar, narep: Scalar | None=None, col_narep: Scalar | None=None, separate_nulls: separator_on_nulls=separator_on_nulls.YES, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Concatenate all columns in the table horizontally into one new string + delimited by an optional separator string. + + Parameters + ---------- + strings_columns : Table + Strings for this operation + + separator : Column or Scalar + Separator(s) for a given row + + narep : Scalar + String to replace a null separator for a given row. + + col_narep : Scalar + String that should be used in place of any null strings found in any column. + An exception is raised when separator is a Scalar. + + separate_nulls : SeparatorOnNulls + If YES, then the separator is included for null rows. + + Returns + ------- + Column + New column with concatenated results + """ +def join_strings(input: Column, separator: Scalar, narep: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Concatenates all strings in the column into one new string delimited + by an optional separator string. + + Parameters + ---------- + input : Column + List of strings columns to concatenate + + separator : Scalar + Strings column that provides the separator for a given row + + narep : Scalar + String to replace any null strings found. + + Returns + ------- + Column + New column containing one string + """ +def join_list_elements(lists_strings_column: Column, separator: Column | Scalar, separator_narep: Scalar, string_narep: Scalar, separate_nulls: separator_on_nulls, empty_list_policy: output_if_empty_list, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Given a lists column of strings (each row is a list of strings), + concatenates the strings within each row and returns a single strings + column result. + + Parameters + ---------- + lists_strings_column : Column + Column containing lists of strings to concatenate + + separator : Column or Scalar + String(s) that should inserted between each string from each row. + + separator_narep : Scalar + String that should be used to replace a null separator. + + string_narep : Scalar + String to replace null strings in any non-null list row. + Ignored if separator is a Scalar. + + separate_nulls : SeparatorOnNulls + If YES, then the separator is included for null rows + if `narep` is valid + + empty_list_policy : OutputIfEmptyList + If set to EMPTY_STRING, any input row that is an empty + list will result in an empty string. Otherwise, it will + result in a null. + + + Returns + ------- + Column + New strings column with concatenated results + """ diff --git a/python/pylibcudf/pylibcudf/strings/contains.pyi b/python/pylibcudf/pylibcudf/strings/contains.pyi index b751ef0b24cd..39151e1823ae 100644 --- a/python/pylibcudf/pylibcudf/strings/contains.pyi +++ b/python/pylibcudf/pylibcudf/strings/contains.pyi @@ -1,34 +1,88 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/contains.pyx from pylibcudf.column import Column from pylibcudf.strings.regex_program import RegexProgram -from pylibcudf.utils import CudaStreamLike - -def contains_re( - input: Column, - prog: RegexProgram, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def count_re( - input: Column, - prog: RegexProgram, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def matches_re( - input: Column, - prog: RegexProgram, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def like( - input: Column, - pattern: str, - escape_character: str | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['contains_re', 'count_re', 'like', 'matches_re'] + +def contains_re(input: Column, prog: RegexProgram, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Returns a boolean column identifying rows which match the given + regex_program object. + + For details, see :cpp:func:`contains_re`. + + Parameters + ---------- + input : Column + The input strings + prog : RegexProgram + Regex program instance + + Returns + ------- + pylibcudf.Column + New column of boolean results for each string + """ +def count_re(input: Column, prog: RegexProgram, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Returns the number of times the given regex_program's pattern + matches in each string. + + For details, see :cpp:func:`count_re`. + + Parameters + ---------- + input : Column + The input strings + prog : RegexProgram + Regex program instance + + Returns + ------- + pylibcudf.Column + New column of match counts for each string + """ +def matches_re(input: Column, prog: RegexProgram, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Returns a boolean column identifying rows which + matching the given regex_program object but only at + the beginning the string. + + For details, see :cpp:func:`matches_re`. + + Parameters + ---------- + input : Column + The input strings + prog : RegexProgram + Regex program instance + + Returns + ------- + pylibcudf.Column + New column of boolean results for each string + """ +def like(input: Column, pattern: str, escape_character: str | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a boolean column identifying rows which + match the given like pattern. + + For details, see :cpp:func:`like`. + + Parameters + ---------- + input : Column + The input strings + pattern : str + Like pattern to match within each string + escape_character : str + Optional character specifies the escape prefix. + Default is no escape character. + + Returns + ------- + pylibcudf.Column + New column of boolean results for each string + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyi index 10c7b96bfc0b..7dd88b556dc1 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyi @@ -1,22 +1,60 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_booleans.pyx from pylibcudf.column import Column from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -def to_booleans( - input: Column, - true_string: Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def from_booleans( - booleans: Column, - true_string: Scalar, - false_string: Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['from_booleans', 'to_booleans'] + +def to_booleans(input: Column, true_string: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new bool column by parsing boolean values from the strings + in the provided strings column. + + For details, see :cpp:func:`to_booleans`. + + Parameters + ---------- + input : Column + Strings instance for this operation + + true_string : Scalar + String to expect for true. Non-matching strings are false + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New bool column converted from strings. + """ +def from_booleans(booleans: Column, true_string: Scalar, false_string: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new strings column converting the boolean values from the + provided column into strings. + + For details, see :cpp:func:`from_booleans`. + + Parameters + ---------- + booleans : Column + Boolean column to convert. + + true_string : Scalar + String to use for true in the output column. + + false_string : Scalar + String to use for false in the output column. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column. + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyi index 99f067ecb04a..6ef7bb2aade6 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyi @@ -1,29 +1,86 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_datetime.pyx from pylibcudf.column import Column from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -def to_timestamps( - input: Column, - timestamp_type: DataType, - format: str, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def from_timestamps( - timestamps: Column, - format: str, - input_strings_names: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_timestamp( - input: Column, - format: str, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['from_timestamps', 'is_timestamp', 'to_timestamps'] + +def to_timestamps(input: Column, timestamp_type: DataType, format: str, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new timestamp column converting a strings column into + timestamps using the provided format pattern. + + For details, see cpp:`cudf::strings::to_timestamps`. + + Parameters + ---------- + input : Column + Strings instance for this operation. + + timestamp_type : DataType + The timestamp type used for creating the output column. + + format : str + String specifying the timestamp format in strings. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New datetime column + """ +def from_timestamps(timestamps: Column, format: str, input_strings_names: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new strings column converting a timestamp column into + strings using the provided format pattern. + + For details, see cpp:`cudf::strings::from_timestamps`. + + Parameters + ---------- + timestamps : Column + Timestamp values to convert + + format : str + The string specifying output format. + + input_strings_names : Column + The string names to use for weekdays ("%a", "%A") and months ("%b", "%B"). + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column with formatted timestamps. + """ +def is_timestamp(input: Column, format: str, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Verifies the given strings column can be parsed to timestamps + using the provided format pattern. + + For details, see cpp:`cudf::strings::is_timestamp`. + + Parameters + ---------- + input : Column + Strings instance for this operation. + + format : str + String specifying the timestamp format in strings. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New bool column. + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyi index ac9fd9825dc8..21cf7923dfef 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyi @@ -1,22 +1,61 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_durations.pyx from pylibcudf.column import Column from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -def to_durations( - input: Column, - duration_type: DataType, - format: str, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def from_durations( - durations: Column, - format: str | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['from_durations', 'to_durations'] + +def to_durations(input: Column, duration_type: DataType, format: str, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new duration column converting a strings column into + durations using the provided format pattern. + + For details, see cpp:func:`cudf::strings::to_durations` + + Parameters + ---------- + input : Column + Strings instance for this operation. + + duration_type : DataType + The duration type used for creating the output column. + + format : str + String specifying the duration format in strings. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New duration column. + """ +def from_durations(durations: Column, format: str | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new strings column converting a duration column into + strings using the provided format pattern. + + For details, see cpp:func:`cudf::strings::from_durations` + + Parameters + ---------- + durations : Column + Duration values to convert. + + format : str + The string specifying output format. + Default format is "%D days %H:%M:%S". + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column with formatted durations. + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyi index a9d4a0eac982..dc8b6bcab699 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyi @@ -1,26 +1,78 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_fixed_point.pyx from pylibcudf.column import Column from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -def to_fixed_point( - input: Column, - output_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def from_fixed_point( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_fixed_point( - input: Column, - decimal_type: DataType | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['from_fixed_point', 'is_fixed_point', 'to_fixed_point'] + +def to_fixed_point(input: Column, output_type: DataType, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new fixed-point column parsing decimal values from the + provided strings column. + + For details, see :cpp:func:`to_fixed_point` + + Parameters + ---------- + input : Column + Strings instance for this operation. + + output_type : DataType + Type of fixed-point column to return including the scale value. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of output_type. + """ +def from_fixed_point(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new strings column converting the fixed-point values + into a strings column. + + For details, see :cpp:func:`from_fixed_point` + + Parameters + ---------- + input : Column + Fixed-point column to convert. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column. + """ +def is_fixed_point(input: Column, decimal_type: DataType | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a boolean column identifying strings in which all + characters are valid for conversion to fixed-point. + + For details, see :cpp:func:`is_fixed_point` + + Parameters + ---------- + input : Column + Strings instance for this operation. + + decimal_type : DataType + Fixed-point type (with scale) used only for checking overflow. + Defaults to Decimal64 + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of boolean results for each string. + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyi index b334dfef9c7d..a1f04b4c4e75 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyi @@ -1,25 +1,74 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_floats.pyx from pylibcudf.column import Column from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -def to_floats( - strings: Column, - output_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def from_floats( - floats: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_float( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['from_floats', 'is_float', 'to_floats'] + +def to_floats(strings: Column, output_type: DataType, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new numeric column by parsing float values from each string + in the provided strings column. + + For details, see cpp:func:`cudf::strings::to_floats` + + Parameters + ---------- + strings : Column + Strings instance for this operation. + + output_type : DataType + Type of float numeric column to return. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with floats converted from strings. + """ +def from_floats(floats: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new strings column converting the float values from the + provided column into strings. + + For details, see cpp:func:`cudf::strings::from_floats` + + Parameters + ---------- + floats : Column + Numeric column to convert. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column with floats as strings. + """ +def is_float(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a boolean column identifying strings in which all + characters are valid for conversion to floats. + + For details, see cpp:func:`cudf::strings::is_float` + + Parameters + ---------- + input : Column + Strings instance for this operation. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of boolean results for each string. + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyi index 88a663504662..8ea525ff70cb 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyi @@ -1,42 +1,142 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_integers.pyx from pylibcudf.column import Column from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -def to_integers( - input: Column, - output_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def from_integers( - integers: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_integer( - input: Column, - int_type: DataType | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def hex_to_integers( - input: Column, - output_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_hex( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def integers_to_hex( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['from_integers', 'hex_to_integers', 'integers_to_hex', 'is_hex', 'is_integer', 'to_integers'] + +def to_integers(input: Column, output_type: DataType, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new integer numeric column parsing integer values from the + provided strings column. + + For details, cpp:func:`cudf::strings::to_integers`. + + Parameters + ---------- + input : Column + Strings instance for this operation. + + output_type : DataType + Type of integer numeric column to return. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with integers converted from strings. + """ +def from_integers(integers: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new strings column converting the integer values from the + provided column into strings. + + For details, cpp:func:`cudf::strings::from_integers`. + + Parameters + ---------- + integers : Column + Strings instance for this operation. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column with integers as strings. + """ +def is_integer(input: Column, int_type: DataType | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a boolean column identifying strings in which all + characters are valid for conversion to integers. + + For details, cpp:func:`cudf::strings::is_integer`. + + Parameters + ---------- + input : Column + Strings instance for this operation. + + int_type : DataType + Integer type used for checking underflow and overflow. + By default, does not check an integer type for underflow + or overflow. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of boolean results for each string. + """ +def hex_to_integers(input: Column, output_type: DataType, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new integer numeric column parsing hexadecimal values + from the provided strings column. + + For details, cpp:func:`cudf::strings::hex_to_integers`. + + Parameters + ---------- + input : Column + Strings instance for this operation. + + output_type : DataType + Type of integer numeric column to return. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with integers converted from strings. + """ +def is_hex(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a boolean column identifying strings in which all + characters are valid for conversion to integers from hex. + + For details, cpp:func:`cudf::strings::is_hex`. + + Parameters + ---------- + input : Column + Strings instance for this operation. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of boolean results for each string. + """ +def integers_to_hex(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a new strings column converting integer columns to hexadecimal + characters. + + For details, cpp:func:`cudf::strings::integers_to_hex`. + + Parameters + ---------- + input : Column + Integer column to convert to hex. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column with hexadecimal characters. + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyi index 16e4d8d990ab..5bb42794b5e3 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyi @@ -1,23 +1,68 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_ipv4.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def ipv4_to_integers( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def integers_to_ipv4( - integers: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_ipv4( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['integers_to_ipv4', 'ipv4_to_integers', 'is_ipv4'] + +def ipv4_to_integers(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Converts IPv4 addresses into integers. + + For details, see cpp:func:`cudf::strings::ipv4_to_integers` + + Parameters + ---------- + input : Column + Strings instance for this operation + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New uint32 column converted from strings. + """ +def integers_to_ipv4(integers: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Converts integers into IPv4 addresses as strings. + + For details, see cpp:func:`cudf::strings::integers_to_ipv4` + + Parameters + ---------- + integers : Column + Integer (uint32) column to convert. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column. + """ +def is_ipv4(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a boolean column identifying strings in which all + characters are valid for conversion to integers from IPv4 format. + + For details, see cpp:func:`cudf::strings::is_ipv4` + + Parameters + ---------- + input : Column + Strings instance for this operation. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of boolean results for each string. + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyi index 29f94a30123d..4afde2e58c46 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyi @@ -1,16 +1,38 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_lists.pyx from pylibcudf.column import Column from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -def format_list_column( - input: Column, - na_rep: Scalar | None = None, - separators: Column | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['format_list_column'] + +def format_list_column(input: Column, na_rep: Scalar | None=None, separators: Column | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Convert a list column of strings into a formatted strings column. + + For details, see :cpp:func`cudf::strings::format_list_column` + + Parameters + ---------- + input : Column + Lists column to format + + na_rep : Scalar + Replacement string for null elements. + Default, empty string + + separators : Column + Strings to use for enclosing list components and separating elements. + Default, ``,``, ``[``, ``]`` + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column + """ diff --git a/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyi b/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyi index 8707da953b5a..43444db98298 100644 --- a/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyi +++ b/python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyi @@ -1,18 +1,48 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/convert/convert_urls.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def url_encode( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def url_decode( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['url_decode', 'url_encode'] + +def url_encode(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Encodes each string using URL encoding. + + For details, see :cpp:func:`url_encode` + + Parameters + ---------- + input : Column + Strings instance for this operation. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column. + """ +def url_decode(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Decodes each string using URL encoding. + + For details, see :cpp:func:`url_decode` + + Parameters + ---------- + input : Column + Strings instance for this operation. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New strings column. + """ diff --git a/python/pylibcudf/pylibcudf/strings/extract.pyi b/python/pylibcudf/pylibcudf/strings/extract.pyi index a9607266bbcd..1a26314f296a 100644 --- a/python/pylibcudf/pylibcudf/strings/extract.pyi +++ b/python/pylibcudf/pylibcudf/strings/extract.pyi @@ -1,29 +1,80 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/extract.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.strings.regex_program import RegexProgram from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -def extract( - input: Column, - prog: RegexProgram, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def extract_all_record( - input: Column, - prog: RegexProgram, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def extract_single( - input: Column, - prog: RegexProgram, - group: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['extract', 'extract_all_record', 'extract_single'] + +def extract(input: Column, prog: RegexProgram, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Returns a table of strings columns where each column + corresponds to the matching group specified in the given + egex_program object. + + For details, see :cpp:func:`extract`. + + Parameters + ---------- + input : Column + Strings instance for this operation + prog : RegexProgram + Regex program instance + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + Columns of strings extracted from the input column. + """ +def extract_all_record(input: Column, prog: RegexProgram, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a lists column of strings where each string column + row corresponds to the matching group specified in the given + regex_program object. + + For details, see :cpp:func:`extract_all_record`. + + Parameters + ---------- + input : Column + Strings instance for this operation + prog : RegexProgram + Regex program instance + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Lists column containing strings extracted from the input column + """ +def extract_single(input: Column, prog: RegexProgram, group: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a column of strings where each string corresponds to the + matching group specified in the given regex_program object. + + For details, see :cpp:func:`extract_single`. + + Parameters + ---------- + input : Column + Strings instance for this operation + prog : RegexProgram + Regex program instance + group : size_type + Index of the group number to extract + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Column of strings extracted from the input column + """ diff --git a/python/pylibcudf/pylibcudf/strings/find.pyi b/python/pylibcudf/pylibcudf/strings/find.pyi index a8b3ca1da7c1..a2fa1702cf73 100644 --- a/python/pylibcudf/pylibcudf/strings/find.pyi +++ b/python/pylibcudf/pylibcudf/strings/find.pyi @@ -1,43 +1,160 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/find.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -def find( - input: Column, - target: Column | Scalar, - start: int = 0, - stop: int = -1, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def rfind( - input: Column, - target: Scalar, - start: int = 0, - stop: int = -1, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def contains( - input: Column, - target: Column | Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def starts_with( - input: Column, - target: Column | Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def ends_with( - input: Column, - target: Column | Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['contains', 'ends_with', 'find', 'rfind', 'starts_with'] + +def find(input: Column, target: Column | Scalar, start: size_type=0, stop: size_type=-1, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Returns a column of character position values where the target string is + first found in each string of the provided column. + + ``target`` may be a + :py:class:`~pylibcudf.column.Column` or a + :py:class:`~pylibcudf.scalar.Scalar`. + + If ``target`` is a scalar, the scalar will be searched for in each string. + If ``target`` is a column, the corresponding string in the column will be + searched for in each string. + + For details, see :cpp:func:`find`. + + Parameters + ---------- + input : Column + The input strings + target : Union[Column, Scalar] + String to search for in each string + start : size_type + First character position to include in the search + stop : size_type + Last position (exclusive) to include in the search. Default of -1 will + search to the end of the string. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + New integer column with character position values + """ +def rfind(input: Column, target: Scalar, start: size_type=0, stop: size_type=-1, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a column of character position values where the target string is + first found searching from the end of each string. + + For details, see :cpp:func:`rfind`. + + Parameters + ---------- + input : Column + The input strings + target : Scalar + String to search for in each string + start : size_type + First character position to include in the search + stop : size_type + Last position (exclusive) to include in the search. Default of -1 will + search to the end of the string. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + New integer column with character position values + """ +def contains(input: Column, target: Column | Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a column of boolean values for each string where true indicates the + corresponding target string was found within that string in the provided + column. + + ``target`` may be a + :py:class:`~pylibcudf.column.Column` or a + :py:class:`~pylibcudf.scalar.Scalar`. + + If ``target`` is a scalar, the scalar will be searched for in each string. + If ``target`` is a column, the corresponding string in the column will be + searched for in each string. + + For details, see :cpp:func:`contains`. + + Parameters + ---------- + input : Column + The input strings + target : Union[Column, Scalar] + String to search for in each string + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + New boolean column with True for each string that contains the target + """ +def starts_with(input: Column, target: Column | Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a column of boolean values for each string where true indicates the + target string was found at the beginning of the string in the provided + column. + + ``target`` may be a + :py:class:`~pylibcudf.column.Column` or a + :py:class:`~pylibcudf.scalar.Scalar`. + + If ``target`` is a scalar, the scalar will be searched for in each string. + If ``target`` is a column, the corresponding string in the column will be + searched for in each string. + + For details, see :cpp:func:`starts_with`. + + Parameters + ---------- + input : Column + The input strings + target : Union[Column, Scalar] + String to search for at the beginning of each string + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + New boolean column with True for each string that starts with the target + """ +def ends_with(input: Column, target: Column | Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a column of boolean values for each string where true indicates the + target string was found at the end of the string in the provided column. + + ``target`` may be a + :py:class:`~pylibcudf.column.Column` or a + :py:class:`~pylibcudf.scalar.Scalar`. + + If ``target`` is a scalar, the scalar will be searched for in each string. + If ``target`` is a column, the corresponding string in the column will be + searched for in each string. + + For details, see :cpp:func:`ends_with`. + + Parameters + ---------- + input : Column + The input strings + target : Union[Column, Scalar] + String to search for at the end of each string + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + New boolean column with True for each string that ends with the target + """ diff --git a/python/pylibcudf/pylibcudf/strings/find_multiple.pyi b/python/pylibcudf/pylibcudf/strings/find_multiple.pyi index 76115cd74968..9037f66a9cf7 100644 --- a/python/pylibcudf/pylibcudf/strings/find_multiple.pyi +++ b/python/pylibcudf/pylibcudf/strings/find_multiple.pyi @@ -1,21 +1,53 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/find_multiple.pyx from pylibcudf.column import Column from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -def find_multiple( - input: Column, - targets: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def contains_multiple( - input: Column, - targets: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['find_multiple', 'contains_multiple'] + +def find_multiple(input: Column, targets: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a lists column with character position values where each + of the target strings are found in each string. + + For details, see :cpp:func:`find_multiple`. + + Parameters + ---------- + input : Column + Strings instance for this operation + targets : Column + Strings to search for in each string + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + Lists column with character position values + """ +def contains_multiple(input: Column, targets: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Returns a table of boolean values where each column indicates + whether the corresponding target is found at that row. + + For details, see :cpp:func:`contains_multiple`. + + Parameters + ---------- + input : Column + Strings instance for this operation + targets : Column + Strings to search for in each string + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + Columns of booleans + """ diff --git a/python/pylibcudf/pylibcudf/strings/findall.pyi b/python/pylibcudf/pylibcudf/strings/findall.pyi index f72e786cf1d0..b7f1888563db 100644 --- a/python/pylibcudf/pylibcudf/strings/findall.pyi +++ b/python/pylibcudf/pylibcudf/strings/findall.pyi @@ -1,21 +1,53 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/findall.pyx from pylibcudf.column import Column from pylibcudf.strings.regex_program import RegexProgram -from pylibcudf.utils import CudaStreamLike - -def find_re( - input: Column, - pattern: RegexProgram, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def findall( - input: Column, - pattern: RegexProgram, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['findall', 'find_re'] + +def findall(input: Column, pattern: RegexProgram, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns a lists column of strings for each matching occurrence using + the regex_program pattern within each string. + + For details, see :cpp:func:`findall`. + + Parameters + ---------- + input : Column + Strings instance for this operation + pattern : RegexProgram + Regex pattern + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New lists column of strings + """ +def find_re(input: Column, pattern: RegexProgram, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Returns character positions where the pattern first matches + the elements in input strings. + + For details, see :cpp:func:`find_re` + + Parameters + ---------- + input : Column + Strings instance for this operation + pattern : RegexProgram + Regex pattern + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of integers + """ diff --git a/python/pylibcudf/pylibcudf/strings/padding.pyi b/python/pylibcudf/pylibcudf/strings/padding.pyi index 904b0022317f..c142e50f3385 100644 --- a/python/pylibcudf/pylibcudf/strings/padding.pyi +++ b/python/pylibcudf/pylibcudf/strings/padding.pyi @@ -1,29 +1,76 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/padding.pyx from pylibcudf.column import Column -from pylibcudf.strings.side_type import SideType -from pylibcudf.utils import CudaStreamLike - -def pad( - input: Column, - width: int, - side: SideType, - fill_char: str, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def zfill( - input: Column, - width: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def zfill_by_widths( - input: Column, - widths: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from pylibcudf.libcudf.strings.side_type import side_type +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['pad', 'zfill', 'zfill_by_widths'] + +def pad(input: Column, width: size_type, side: side_type, fill_char: str, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Add padding to each string using a provided character. + + For details, see :cpp:func:`pad`. + + Parameters + ---------- + input : Column + Strings instance for this operation + width : int + The minimum number of characters for each string. + side : SideType + Where to place the padding characters. + fill_char : str + Single UTF-8 character to use for padding + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with padded strings. + """ +def zfill(input: Column, width: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Add '0' as padding to the left of each string. + + For details, see :cpp:func:`zfill`. + + Parameters + ---------- + input : Column + Strings instance for this operation + width : int + The minimum number of characters for each string. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of strings. + """ +def zfill_by_widths(input: Column, widths: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Add '0' as padding to the left of each string. + + For details, see :cpp:func:`zfill_by_widths`. + + Parameters + ---------- + input : Column + Strings instance for this operation + widths : Column + The minimum number of characters for each string. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column of strings. + """ diff --git a/python/pylibcudf/pylibcudf/strings/regex_flags.pyi b/python/pylibcudf/pylibcudf/strings/regex_flags.pyi index f847d235f3b4..2e8093b8ae1e 100644 --- a/python/pylibcudf/pylibcudf/strings/regex_flags.pyi +++ b/python/pylibcudf/pylibcudf/strings/regex_flags.pyi @@ -1,9 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum -class RegexFlags(IntEnum): - DEFAULT = ... - IGNORECASE = ... - MULTILINE = ... - DOTALL = ... +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/regex_flags.pyx + +from pylibcudf.libcudf.strings.regex_flags import regex_flags as RegexFlags + +__all__ = ['RegexFlags'] diff --git a/python/pylibcudf/pylibcudf/strings/regex_program.pyi b/python/pylibcudf/pylibcudf/strings/regex_program.pyi index e0a685d070f9..8309d91656e2 100644 --- a/python/pylibcudf/pylibcudf/strings/regex_program.pyi +++ b/python/pylibcudf/pylibcudf/strings/regex_program.pyi @@ -1,9 +1,39 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from pylibcudf.strings.regex_flags import RegexFlags +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/regex_program.pyx + +from pylibcudf.libcudf.strings.regex_flags import regex_flags + +__all__ = ['RegexProgram'] class RegexProgram: - def __init__(self): ... + """Regex program class. + + This is the Cython representation of + :cpp:class:`cudf::strings::regex_program`. + + Do not instantiate this class directly, use the `create` method. + + """ + __hash__ = None + + def __init__(self, *args, **kwargs): ... @staticmethod - def create(pattern: str, flags: RegexFlags) -> RegexProgram: ... + def create(pattern: str, flags: regex_flags): + """Create a program from a pattern. + + For detils, see :cpp:func:`create`. + + Parameters + ---------- + pattern : str + Regex pattern + flags : RegexFlags + Regex flags for interpreting special characters in the pattern + + Returns + ------- + RegexProgram + A new RegexProgram + """ diff --git a/python/pylibcudf/pylibcudf/strings/repeat.pyi b/python/pylibcudf/pylibcudf/strings/repeat.pyi index fedb7dee76c2..903c3f3abdc1 100644 --- a/python/pylibcudf/pylibcudf/strings/repeat.pyi +++ b/python/pylibcudf/pylibcudf/strings/repeat.pyi @@ -1,14 +1,35 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/repeat.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def repeat_strings( - input: Column, - repeat_times: Column | int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['repeat_strings'] + +def repeat_strings(input: Column, repeat_times: Column | size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Repeat each string in the given strings column by the numbers + of times given in another numeric column. + + For details, see :cpp:func:`repeat`. + + Parameters + ---------- + input : Column + The column containing strings to repeat. + repeat_times : Column or int + Number(s) of times that the corresponding input strings + for each row are repeated. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + New column containing the repeated strings. + """ diff --git a/python/pylibcudf/pylibcudf/strings/replace.pyi b/python/pylibcudf/pylibcudf/strings/replace.pyi index 0e76eb402f77..acda5cbf57dd 100644 --- a/python/pylibcudf/pylibcudf/strings/replace.pyi +++ b/python/pylibcudf/pylibcudf/strings/replace.pyi @@ -1,33 +1,89 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/replace.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -def replace( - input: Column, - target: Scalar, - repl: Scalar, - maxrepl: int = -1, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def replace_multiple( - input: Column, - target: Column, - repl: Column, - maxrepl: int = -1, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def replace_slice( - input: Column, - repl: Scalar | None = None, - start: int = 0, - stop: int = -1, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['replace', 'replace_multiple', 'replace_slice'] + +def replace(input: Column, target: Scalar, repl: Scalar, maxrepl: size_type=-1, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Replaces target string within each string with the specified replacement string. + + Null string entries will return null output string entries. + + For details, see :cpp:func:`replace`. + + Parameters + ---------- + input : Column + The input strings + target : Scalar + String to search for in each string. + repl : Scalar + String to replace target with. + maxrepl : size_type, default -1 + Maximum times to replace if target appears multiple times in the input string. + Default of -1 specifies to replace all occurrences of target in each string. + + Returns + ------- + pylibcudf.Column + New string column with target replaced. + """ +def replace_multiple(input: Column, target: Column, repl: Column, maxrepl: size_type=-1, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Replaces target string within each string with the specified replacement string. + + Null string entries will return null output string entries. + + For details, see :cpp:func:`replace_multiple`. + + Parameters + ---------- + input : Column + The input strings + target : Column + Column containing strings to search for in the input column. + repl : Column + Column containing strings to replace target with. + Each target, when found, will be replaced by the value at the + corresponding index in the repl Column. + + Must be of the same length as target. + + Returns + ------- + pylibcudf.Column + New string column with target replaced. + """ +def replace_slice(input: Column, repl: Scalar | None=None, start: size_type=0, stop: size_type=-1, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Replaces each string in the column with the provided repl string + within the [start,stop) character position range. + + Null string entries will return null output string entries. + This function can be used to insert a string into specific position + by specifying the same position value for start and stop. + The repl string can be appended to each string by specifying -1 + for both start and stop. + + For details, see :cpp:func:`replace_slice`. + + Parameters + ---------- + input : Column + The input strings + repl : Scalar, default "" + String scalar to replace target with. + start : size_type, default 0 + Start position where repl will be added. + stop : size_type, default -1 + End position (exclusive) to use for replacement. + + Returns + ------- + pylibcudf.Column + New string column + """ diff --git a/python/pylibcudf/pylibcudf/strings/replace_re.pyi b/python/pylibcudf/pylibcudf/strings/replace_re.pyi index 6b79b066ee6e..f1fa28250226 100644 --- a/python/pylibcudf/pylibcudf/strings/replace_re.pyi +++ b/python/pylibcudf/pylibcudf/strings/replace_re.pyi @@ -1,25 +1,61 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/replace_re.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar from pylibcudf.strings.regex_program import RegexProgram -from pylibcudf.utils import CudaStreamLike - -def replace_re( - input: Column, - pattern: RegexProgram, - replacement: Scalar, - max_replace_count: int = -1, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def replace_with_backrefs( - input: Column, - prog: RegexProgram, - replacement: str, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['replace_re', 'replace_with_backrefs'] + +def replace_re(input: Column, pattern: RegexProgram, replacement: Scalar | None=None, max_replace_count: size_type=-1, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + For each string, replaces any character sequence matching the given patterns + with the provided replacement. + + For details, see :cpp:func:`replace_re` + + Parameters + ---------- + input : Column + Strings instance for this operation. + pattern: RegexProgram + The regex to match to each string and replace. + replacement : Scalar + The string used to replace the matched sequence in each string. + max_replace_count : int + The maximum number of times to replace the matched pattern + within each string. + Default replaces every substring that is matched. + + Returns + ------- + Column + New strings column + """ +def replace_with_backrefs(input: Column, prog: RegexProgram, replacement: str, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + For each string, replaces any character sequence matching the given regex + using the replacement template for back-references. + + For details, see :cpp:func:`replace_with_backrefs` + + Parameters + ---------- + input : Column + Strings instance for this operation. + + prog: RegexProgram + Regex program instance. + + replacement : str + The replacement template for creating the output string. + + Returns + ------- + Column + New strings column. + """ diff --git a/python/pylibcudf/pylibcudf/strings/reverse.pyi b/python/pylibcudf/pylibcudf/strings/reverse.pyi index 48c602e2d28b..64b2ee9f198d 100644 --- a/python/pylibcudf/pylibcudf/strings/reverse.pyi +++ b/python/pylibcudf/pylibcudf/strings/reverse.pyi @@ -1,13 +1,29 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/reverse.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['reverse'] + +def reverse(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Reverses the characters within each string. + + Any null string entries return corresponding null output column entries. + + For details, see :cpp:func:`reverse`. + + Parameters + ---------- + input : Column + Strings column for this operation + stream : Stream | None + CUDA stream on which to perform the operation. -def reverse( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + Returns + ------- + pylibcudf.Column + New strings column + """ diff --git a/python/pylibcudf/pylibcudf/strings/side_type.pyi b/python/pylibcudf/pylibcudf/strings/side_type.pyi index cf57013de865..69867a4d45cb 100644 --- a/python/pylibcudf/pylibcudf/strings/side_type.pyi +++ b/python/pylibcudf/pylibcudf/strings/side_type.pyi @@ -1,8 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum -class SideType(IntEnum): - LEFT = ... - RIGHT = ... - BOTH = ... +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/side_type.pyx + +from pylibcudf.libcudf.strings.side_type import side_type as SideType + +__all__ = ['SideType'] diff --git a/python/pylibcudf/pylibcudf/strings/slice.pyi b/python/pylibcudf/pylibcudf/strings/slice.pyi index ac2e4d12f1f1..578e4338a6b1 100644 --- a/python/pylibcudf/pylibcudf/strings/slice.pyi +++ b/python/pylibcudf/pylibcudf/strings/slice.pyi @@ -1,17 +1,42 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/slice.pyx + +from typing import TypeVar from pylibcudf.column import Column from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -def slice_strings( - input: Column, - start: Column | Scalar | None = None, - stop: Column | Scalar | None = None, - step: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +ColumnOrScalar = TypeVar('ColumnOrScalar', Column, Scalar) +__all__ = ['slice_strings'] + +def slice_strings(input: Column, start: ColumnOrScalar | None=None, stop: ColumnOrScalar | None=None, step: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a slice operation on a strings column. + + ``start`` and ``stop`` may be a + :py:class:`~pylibcudf.column.Column` or a + :py:class:`~pylibcudf.scalar.Scalar`. But ``step`` must be a + :py:class:`~pylibcudf.scalar.Scalar`. + + For details, see :cpp:func:`slice_strings`. + + Parameters + ---------- + input : Column + Strings column for this operation + start : Union[Column, Scalar] + The start character position or positions. + stop : Union[Column, Scalar] + The end character position or positions + step : Scalar + Distance between input characters retrieved + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pylibcudf.Column + The result of the slice operation + """ diff --git a/python/pylibcudf/pylibcudf/strings/split/partition.pyi b/python/pylibcudf/pylibcudf/strings/split/partition.pyi index cef2d16aea6f..824b26659934 100644 --- a/python/pylibcudf/pylibcudf/strings/split/partition.pyi +++ b/python/pylibcudf/pylibcudf/strings/split/partition.pyi @@ -1,22 +1,52 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/split/partition.pyx from pylibcudf.column import Column from pylibcudf.scalar import Scalar from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -def partition( - input: Column, - delimiter: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def rpartition( - input: Column, - delimiter: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['partition', 'rpartition'] + +def partition(input: Column, delimiter: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Returns a set of 3 columns by splitting each string using the + specified delimiter. + + For details, see :cpp:func:`partition`. + + Parameters + ---------- + input : Column + Strings instance for this operation + + delimiter : Scalar + UTF-8 encoded string indicating where to split each string. + + Returns + ------- + Table + New table of strings columns + """ +def rpartition(input: Column, delimiter: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Returns a set of 3 columns by splitting each string using the + specified delimiter starting from the end of each string. + + For details, see :cpp:func:`rpartition`. + + Parameters + ---------- + input : Column + Strings instance for this operation + + delimiter : Scalar + UTF-8 encoded string indicating where to split each string. + + Returns + ------- + Table + New strings columns + """ diff --git a/python/pylibcudf/pylibcudf/strings/split/split.pyi b/python/pylibcudf/pylibcudf/strings/split/split.pyi index 7a775bd960c5..9e8b8717d01e 100644 --- a/python/pylibcudf/pylibcudf/strings/split/split.pyi +++ b/python/pylibcudf/pylibcudf/strings/split/split.pyi @@ -1,74 +1,213 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/split/split.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.types import size_type from pylibcudf.scalar import Scalar from pylibcudf.strings.regex_program import RegexProgram from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike - -def split( - strings_column: Column, - delimiter: Scalar, - maxsplit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def rsplit( - strings_column: Column, - delimiter: Scalar, - maxsplit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def split_record( - strings: Column, - delimiter: Scalar, - maxsplit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def rsplit_record( - strings: Column, - delimiter: Scalar, - maxsplit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def split_re( - input: Column, - prog: RegexProgram, - maxsplit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def rsplit_re( - input: Column, - prog: RegexProgram, - maxsplit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... -def split_record_re( - input: Column, - prog: RegexProgram, - maxsplit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def rsplit_record_re( - input: Column, - prog: RegexProgram, - maxsplit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def split_part( - input: Column, - delimiter: Scalar, - index: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['rsplit', 'rsplit_re', 'rsplit_record', 'rsplit_record_re', 'split', 'split_re', 'split_record', 'split_record_re'] + +def split(strings_column: Column, delimiter: Scalar, maxsplit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Returns a list of columns by splitting each string using the + specified delimiter. + + For details, see :cpp:func:`split`. + + Parameters + ---------- + strings_column : Column + Strings instance for this operation + + delimiter : Scalar + UTF-8 encoded string indicating the split points in each string. + + maxsplit : int + Maximum number of splits to perform. -1 indicates all possible + splits on each string. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + New table of strings columns + """ +def rsplit(strings_column: Column, delimiter: Scalar, maxsplit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Returns a list of columns by splitting each string using the + specified delimiter starting from the end of each string. + + For details, see :cpp:func:`rsplit`. + + Parameters + ---------- + strings_column : Column + Strings instance for this operation + + delimiter : Scalar + UTF-8 encoded string indicating the split points in each string. + + maxsplit : int + Maximum number of splits to perform. -1 indicates all possible + splits on each string. + + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Table + New table of strings columns. + """ +def split_record(strings: Column, delimiter: Scalar, maxsplit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Splits individual strings elements into a list of strings. + + For details, see :cpp:func:`split_record`. + + Parameters + ---------- + strings : Column + A column of string elements to be split. + + delimiter : Scalar + The string to identify split points in each string. + + maxsplit : int + Maximum number of splits to perform. -1 indicates all possible + splits on each string. + + Returns + ------- + Column + Lists column of strings. + """ +def rsplit_record(strings: Column, delimiter: Scalar, maxsplit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Splits individual strings elements into a list of strings starting + from the end of each string. + + For details, see :cpp:func:`rsplit_record`. + + Parameters + ---------- + strings : Column + A column of string elements to be split. + + delimiter : Scalar + The string to identify split points in each string. + + maxsplit : int + Maximum number of splits to perform. -1 indicates all possible + splits on each string. + + Returns + ------- + Column + Lists column of strings. + """ +def split_re(input: Column, prog: RegexProgram, maxsplit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Splits strings elements into a table of strings columns + using a regex_program's pattern to delimit each string. + + For details, see :cpp:func:`split_re`. + + Parameters + ---------- + input : Column + A column of string elements to be split. + + prog : RegexProgram + Regex program instance. + + maxsplit : int + Maximum number of splits to perform. -1 indicates all possible + splits on each string. + + Returns + ------- + Table + A table of columns of strings. + """ +def rsplit_re(input: Column, prog: RegexProgram, maxsplit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Splits strings elements into a table of strings columns + using a regex_program's pattern to delimit each string starting from + the end of the string. + + For details, see :cpp:func:`rsplit_re`. + + Parameters + ---------- + input : Column + A column of string elements to be split. + + prog : RegexProgram + Regex program instance. + + maxsplit : int + Maximum number of splits to perform. -1 indicates all possible + splits on each string. + + Returns + ------- + Table + A table of columns of strings. + """ +def split_record_re(input: Column, prog: RegexProgram, maxsplit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Splits strings elements into a list column of strings using the given + regex_program to delimit each string. + + For details, see :cpp:func:`split_record_re`. + + Parameters + ---------- + input : Column + A column of string elements to be split. + + prog : RegexProgram + Regex program instance. + + maxsplit : int + Maximum number of splits to perform. -1 indicates all possible + splits on each string. + + Returns + ------- + Column + Lists column of strings. + """ +def rsplit_record_re(input: Column, prog: RegexProgram, maxsplit: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Splits strings elements into a list column of strings using the given + regex_program to delimit each string starting from the end of the string. + + For details, see :cpp:func:`rsplit_record_re`. + + Parameters + ---------- + input : Column + A column of string elements to be split. + + prog : RegexProgram + Regex program instance. + + maxsplit : int + Maximum number of splits to perform. -1 indicates all possible + splits on each string. + + Returns + ------- + Column + Lists column of strings. + """ +def split_part(input: Column, delimiter: Scalar, index: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: ... diff --git a/python/pylibcudf/pylibcudf/strings/strip.pyi b/python/pylibcudf/pylibcudf/strings/strip.pyi index 786079769c71..ea616b64bfdb 100644 --- a/python/pylibcudf/pylibcudf/strings/strip.pyi +++ b/python/pylibcudf/pylibcudf/strings/strip.pyi @@ -1,17 +1,34 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/strip.pyx from pylibcudf.column import Column from pylibcudf.scalar import Scalar -from pylibcudf.strings.side_type import SideType -from pylibcudf.utils import CudaStreamLike +from pylibcudf.strings.side_type import side_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['strip'] + +def strip(input: Column, side: side_type=side_type.BOTH, to_strip: Scalar | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Removes the specified characters from the beginning + or end (or both) of each string. + + For details, see :cpp:func:`strip`. + + Parameters + ---------- + input : Column + Strings column for this operation + side : SideType, default SideType.BOTH + Indicates characters are to be stripped from the beginning, + end, or both of each string; Default is both + to_strip : Scalar + UTF-8 encoded characters to strip from each string; + Default is empty string which indicates strip whitespace characters -def strip( - input: Column, - side: SideType = SideType.BOTH, - to_strip: Scalar | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... + Returns + ------- + pylibcudf.Column + New strings column. + """ diff --git a/python/pylibcudf/pylibcudf/strings/translate.pyi b/python/pylibcudf/pylibcudf/strings/translate.pyi index 9e7624e0b174..5c9bb9afe905 100644 --- a/python/pylibcudf/pylibcudf/strings/translate.pyi +++ b/python/pylibcudf/pylibcudf/strings/translate.pyi @@ -1,29 +1,62 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Mapping -from enum import IntEnum -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/translate.pyx from pylibcudf.column import Column +from pylibcudf.libcudf.strings.translate import filter_type +from pylibcudf.libcudf.strings.translate import filter_type as FilterType from pylibcudf.scalar import Scalar -from pylibcudf.utils import CudaStreamLike - -class FilterType(IntEnum): - KEEP = ... - REMOVE = ... - -def translate( - input: Column, - chars_table: Mapping[int | str, int | str], - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def filter_characters( - input: Column, - characters_to_filter: Mapping[int | str, int | str], - keep_characters: FilterType, - replacement: Scalar, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['FilterType', 'filter_characters', 'translate'] + +def translate(input: Column, chars_table: dict, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Translates individual characters within each string. + + For details, see :cpp:func:`translate`. + + Parameters + ---------- + input : Column + Strings instance for this operation + + chars_table : dict + Table of UTF-8 character mappings + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with padded strings. + """ +def filter_characters(input: Column, characters_to_filter: dict, keep_characters: filter_type, replacement: Scalar, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Removes ranges of characters from each string in a strings column. + + For details, see :cpp:func:`filter_characters`. + + Parameters + ---------- + input : Column + Strings instance for this operation + + characters_to_filter : dict + Table of character ranges to filter on + + keep_characters : FilterType + If true, the `characters_to_filter` are retained + and all other characters are removed. + + replacement : Scalar + Replacement string for each character removed. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + Column + New column with filtered strings. + """ diff --git a/python/pylibcudf/pylibcudf/strings/wrap.pyi b/python/pylibcudf/pylibcudf/strings/wrap.pyi index aa88b64a391f..cea5dbb58a22 100644 --- a/python/pylibcudf/pylibcudf/strings/wrap.pyi +++ b/python/pylibcudf/pylibcudf/strings/wrap.pyi @@ -1,14 +1,36 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from rmm.pylibrmm.memory_resource import DeviceMemoryResource +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/strings/wrap.pyx from pylibcudf.column import Column -from pylibcudf.utils import CudaStreamLike - -def wrap( - input: Column, - width: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... +from pylibcudf.libcudf.types import size_type +from rmm.pylibrmm.memory_resource import DeviceMemoryResource + +__all__ = ['wrap'] + +def wrap(input: Column, width: size_type, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Wraps strings onto multiple lines shorter than `width` by + replacing appropriate white space with + new-line characters (ASCII 0x0A). + + For details, see :cpp:func:`wrap`. + + Parameters + ---------- + input : Column + String column + + width : int + Maximum character width of a line within each string + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + Column of wrapped strings + """ diff --git a/python/pylibcudf/pylibcudf/table.pyi b/python/pylibcudf/pylibcudf/table.pyi index 0d68cddf292b..cd89ee9a0aaa 100644 --- a/python/pylibcudf/pylibcudf/table.pyi +++ b/python/pylibcudf/pylibcudf/table.pyi @@ -1,43 +1,123 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Sequence -from typing import Any +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/table.pyx from rmm.pylibrmm.memory_resource import DeviceMemoryResource +from rmm.pylibrmm.stream import Stream -from pylibcudf._interop_helpers import ArrowLike, ColumnMetadata -from pylibcudf.column import Column -from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike +from ._interop_helpers import ArrowLike, ColumnMetadata +from .types import DataType + +__all__ = ['Table'] + +class _ArrowTableHolder: + """A holder for an Arrow table for gpumemoryview lifetime management.""" class Table: - def __init__( - self, columns: Sequence[Column], num_rows: int | None = None - ): ... - def num_columns(self) -> int: ... - def num_rows(self) -> int: ... - def shape(self) -> tuple[int, int]: ... - def columns(self) -> tuple[Column, ...]: ... - def release(self) -> list[Column]: ... - def copy( - self, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Table: ... - def to_arrow( - self, - metadata: list[ColumnMetadata | str] | None = None, - stream: CudaStreamLike | None = None, - ) -> ArrowLike: ... - # Private methods below are included because polars is currently using them, - # but we want to remove stubs for these private methods eventually - def _to_schema(self, metadata: Any = None) -> Any: ... - def _to_host_array(self, stream: CudaStreamLike) -> Any: ... + """A list of columns of the same size. + + If the list of columns is empty, the table's row count may still be non-zero. + + Parameters + ---------- + columns : Sequence[Column] + The columns in this table. + num_rows : int | None + Optional explicit row count. Only used to preserve the row count of a + table with zero columns. When `columns` is non-empty, `num_rows` must + equal the size of every column. + """ + __hash__ = None + + def __init__(self, columns, num_rows=None): ... + def to_arrow(self, metadata: list[ColumnMetadata | str] | None=None, stream: Stream | None=None) -> ArrowLike: + """Create a pyarrow table from a pylibcudf table. + + Parameters + ---------- + metadata : list[ColumnMetadata | str] | None + The metadata to attach to the columns of the table. + stream : Stream | None + CUDA stream on which to perform the operation. + + Returns + ------- + pyarrow.Table + """ @staticmethod - def from_arrow( - arrow_like: ArrowLike, - dtype: DataType | None = None, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, - ) -> Table: ... + def from_arrow(obj: ArrowLike, dtype: DataType | None=None, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """ + Create a Table from an Arrow-like object using the Arrow C data interface. + + This method supports constructing a `pylibcudf.Table` from an object that + implements one of the Arrow C data interface protocols, such as: + + - `__arrow_c_device_array__`: Returns a tuple of (ArrowSchema, ArrowDeviceArray) + representing columnar device memory. + - `__arrow_c_stream__`: Returns an ArrowArrayStream pointer representing + a stream of host columnar batches. + - `__arrow_c_device_stream__`: Not yet implemented. + - `__arrow_c_array__`: Not yet implemented. + + Parameters + ---------- + obj : Arrow-like type + An object implementing one of the Arrow C data interface methods. + dtype: DataType + The pylibcudf data type. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource for allocations. + + Returns + ------- + Table + A Table constructed from the Arrow-like input. + + Raises + ------ + NotImplementedError + If the input is a device or host stream not yet supported. + If the dtype argument is not None. + ValueError + If the input does not implement a supported Arrow C interface. + """ + def num_columns(self) -> int: + """The number of columns in this table.""" + def num_rows(self) -> int: + """The number of rows in this table.""" + def columns(self) -> tuple: + """The columns in this table.""" + def release(self) -> list: + """Release ownership of this table's columns and leave it empty. + + Returns + ------- + list + The columns that were in this table. + """ + def shape(self) -> tuple: + """The shape of this table""" + def copy(self, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Create a deep copy of the table. + + Parameters + ---------- + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource for allocations. + + Returns + ------- + Table + A new Table with deep copies of all columns. + """ + def _to_schema(self, metadata=None): + """Create an Arrow schema from this table.""" + def _to_host_array(self, stream: object): ... + def _to_device_array(self): ... + def __arrow_c_array__(self, requested_schema=None): ... + def __arrow_c_device_array__(self, requested_schema=None, **kwargs): ... diff --git a/python/pylibcudf/pylibcudf/table_equality.pyi b/python/pylibcudf/pylibcudf/table_equality.pyi index c5d98adb1527..098159a89109 100644 --- a/python/pylibcudf/pylibcudf/table_equality.pyi +++ b/python/pylibcudf/pylibcudf/table_equality.pyi @@ -1,13 +1,37 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from pylibcudf.table import Table -from pylibcudf.types import NullEquality -from pylibcudf.utils import CudaStreamLike +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/table_equality.pyx -def tables_equal( - left: Table, - right: Table, - nulls_equal: NullEquality = NullEquality.EQUAL, - stream: CudaStreamLike | None = None, -) -> bool: ... +from pylibcudf.libcudf.types import null_equality + +from .table import Table + +__all__ = ['tables_equal'] + +def tables_equal(left: Table, right: Table, nulls_equal: null_equality=null_equality.EQUAL, stream: object | None=None) -> bool: + """Check if two tables are equal. + + Returns true if the input tables have the same number of rows, the same + number of columns, matching column types, and every row in ``left`` + compares equal to the row at the same index in ``right``. Null equality + is controlled by ``nulls_equal``. Floating point NaN values compare equal. + + For details, see :cpp:func:`tables_equal`. + + Parameters + ---------- + left : Table + The first table to compare. + right : Table + The second table to compare. + nulls_equal : NullEquality, default NullEquality.EQUAL + Flag to denote if null elements should be considered equal. + stream : Stream, default None + CUDA stream on which to perform the operation. + + Returns + ------- + bool + True if the tables are equal, False otherwise. + """ diff --git a/python/pylibcudf/pylibcudf/traits.pyi b/python/pylibcudf/pylibcudf/traits.pyi index 1fa4bb7be94f..307a37f70108 100644 --- a/python/pylibcudf/pylibcudf/traits.pyi +++ b/python/pylibcudf/pylibcudf/traits.pyi @@ -1,24 +1,104 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from pylibcudf.types import DataType - -def is_relationally_comparable(typ: DataType) -> bool: ... -def is_equality_comparable(typ: DataType) -> bool: ... -def is_numeric(typ: DataType) -> bool: ... -def is_numeric_not_bool(typ: DataType) -> bool: ... -def is_index_type(typ: DataType) -> bool: ... -def is_unsigned(typ: DataType) -> bool: ... -def is_integral(typ: DataType) -> bool: ... -def is_integral_not_bool(typ: DataType) -> bool: ... -def is_floating_point(typ: DataType) -> bool: ... -def is_boolean(typ: DataType) -> bool: ... -def is_timestamp(typ: DataType) -> bool: ... -def is_fixed_point(typ: DataType) -> bool: ... -def is_duration(typ: DataType) -> bool: ... -def is_chrono(typ: DataType) -> bool: ... -def is_dictionary(typ: DataType) -> bool: ... -def is_fixed_width(typ: DataType) -> bool: ... -def is_compound(typ: DataType) -> bool: ... -def is_nested(typ: DataType) -> bool: ... -def is_bit_castable(source: DataType, target: DataType) -> bool: ... +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/traits.pyx + +from .types import DataType + +__all__ = ['is_bit_castable', 'is_boolean', 'is_chrono', 'is_compound', 'is_dictionary', 'is_duration', 'is_equality_comparable', 'is_fixed_point', 'is_fixed_width', 'is_floating_point', 'is_index_type', 'is_integral', 'is_integral_not_bool', 'is_nested', 'is_numeric', 'is_numeric_not_bool', 'is_relationally_comparable', 'is_timestamp', 'is_unsigned'] + +def is_relationally_comparable(typ: DataType) -> bool: + """Checks if the given data type supports relational comparisons. + + For details, see :cpp:func:`is_relationally_comparable`. + """ +def is_equality_comparable(typ: DataType) -> bool: + """Checks if the given data type supports equality comparisons. + + For details, see :cpp:func:`is_equality_comparable`. + """ +def is_numeric(typ: DataType) -> bool: + """Checks if the given data type is numeric. + + For details, see :cpp:func:`is_numeric`. + """ +def is_numeric_not_bool(typ: DataType) -> bool: + """Checks if the given data type is numeric excluding booleans. + + For details, see :cpp:func:`is_numeric_not_bool`. + """ +def is_index_type(typ: DataType) -> bool: + """Checks if the given data type is an index type. + + For details, see :cpp:func:`is_index_type`. + """ +def is_unsigned(typ: DataType) -> bool: + """Checks if the given data type is an unsigned type. + + For details, see :cpp:func:`is_unsigned`. + """ +def is_integral(typ: DataType) -> bool: + """Checks if the given data type is an integral type. + + For details, see :cpp:func:`is_integral`. + """ +def is_integral_not_bool(typ: DataType) -> bool: + """Checks if the given data type is an integral type excluding booleans. + + For details, see :cpp:func:`is_integral_not_bool`. + """ +def is_floating_point(typ: DataType) -> bool: + """Checks if the given data type is a floating point type. + + For details, see :cpp:func:`is_floating_point`. + """ +def is_boolean(typ: DataType) -> bool: + """Checks if the given data type is a boolean type. + + For details, see :cpp:func:`is_boolean`. + """ +def is_timestamp(typ: DataType) -> bool: + """Checks if the given data type is a timestamp type. + + For details, see :cpp:func:`is_timestamp`. + """ +def is_fixed_point(typ: DataType) -> bool: + """Checks if the given data type is a fixed point type. + + For details, see :cpp:func:`is_fixed_point`. + """ +def is_duration(typ: DataType) -> bool: + """Checks if the given data type is a duration type. + + For details, see :cpp:func:`is_duration`. + """ +def is_chrono(typ: DataType) -> bool: + """Checks if the given data type is a chrono type. + + For details, see :cpp:func:`is_chrono`. + """ +def is_dictionary(typ: DataType) -> bool: + """Checks if the given data type is a dictionary type. + + For details, see :cpp:func:`is_dictionary`. + """ +def is_fixed_width(typ: DataType) -> bool: + """Checks if the given data type is a fixed width type. + + For details, see :cpp:func:`is_fixed_width`. + """ +def is_compound(typ: DataType) -> bool: + """Checks if the given data type is a compound type. + + For details, see :cpp:func:`is_compound`. + """ +def is_nested(typ: DataType) -> bool: + """Checks if the given data type is a nested type. + + For details, see :cpp:func:`is_nested`. + """ +def is_bit_castable(source: DataType, target: DataType) -> bool: + """Checks if the source type is bit-castable to the target type. + + For details, see :cpp:func:`is_bit_castable`. + """ diff --git a/python/pylibcudf/pylibcudf/transform.pyi b/python/pylibcudf/pylibcudf/transform.pyi index 64c8f24f7e21..710d32aaf251 100644 --- a/python/pylibcudf/pylibcudf/transform.pyi +++ b/python/pylibcudf/pylibcudf/transform.pyi @@ -1,68 +1,205 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from collections.abc import Sequence +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/transform.pyx + +from pylibcudf.libcudf.types import null_aware, output_nullability from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.expressions import Expression -from pylibcudf.gpumemoryview import gpumemoryview -from pylibcudf.table import Table -from pylibcudf.types import DataType, NullAware, OutputNullability -from pylibcudf.utils import CudaStreamLike - -def nans_to_nulls( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[gpumemoryview, int]: ... -def column_nans_to_nulls( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def compute_column( - input: Table, - expr: Expression, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def compute_column_jit( - input: Table, - expr: Expression, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def bools_to_mask( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[gpumemoryview, int]: ... -def mask_to_bools( - bitmask: int, - begin_bit: int, - end_bit: int, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def transform( - inputs: Sequence[Column], - transform_udf: str, - output_type: DataType, - is_ptx: bool, - null_aware: NullAware = NullAware.NO, - null_policy: OutputNullability = OutputNullability.PRESERVE, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def encode( - input: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> tuple[Table, Column]: ... -def one_hot_encode( - input: Column, - categories: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... +from .column import Column +from .expressions import Expression +from .table import Table +from .types import DataType + +const_transform_input = ... +const_transform_output = ... +__all__ = ['bools_to_mask', 'column_nans_to_nulls', 'compute_column', 'compute_column_jit', 'encode', 'mask_to_bools', 'nans_to_nulls', 'one_hot_encode', 'transform'] + +def nans_to_nulls(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple[object, int]: + """Create a null mask preserving existing nulls and converting nans to null. + + For details, see :cpp:func:`nans_to_nulls`. + + Parameters + ---------- + input : Column + Column to produce new mask from. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned mask's device memory. + + Returns + ------- + Two-tuple of a gpumemoryview wrapping the null mask and the new null count. + """ +def column_nans_to_nulls(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a column with nans converted to nulls. + + For details, see :cpp:func:`column_nans_to_nulls`. + + Parameters + ---------- + input : Column + Column to convert nans to nulls. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + New column with nans converted to nulls. + """ +def compute_column(input: Table, expr: Expression, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a column by evaluating an expression on a table. + + For details see :cpp:func:`compute_column`. + + Parameters + ---------- + input : Table + Table used for expression evaluation + expr : Expression + Expression to evaluate + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column of the evaluated expression + """ +def compute_column_jit(input: Table, expr: Expression, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """ + Create a column by evaluating an expression on a table + using a JIT-compiled kernel. + + For details see :cpp:func:`compute_column_jit`. + + Parameters + ---------- + input : Table + Table used for expression evaluation + expr : Expression + Expression to evaluate + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column of the evaluated expression + """ +def bools_to_mask(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple[object, int]: + """Create a bitmask from a column of boolean elements + + Parameters + ---------- + input : Column + Column to produce new mask from. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned mask's device memory. + + Returns + ------- + tuple[gpumemoryview, int] + Two-tuple of a gpumemoryview wrapping the bitmask and the null count. + """ +def mask_to_bools(bitmask: int, begin_bit: int, end_bit: int, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Creates a boolean column from given bitmask. + + Parameters + ---------- + bitmask : int + Pointer to the bitmask which needs to be converted + begin_bit : int + Position of the bit from which the conversion should start + end_bit : int + Position of the bit before which the conversion should stop + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + Boolean column of the bitmask from [begin_bit, end_bit] + """ +def transform(inputs, transform_udf: str, output_type: DataType, is_ptx: bool, is_null_aware: null_aware, null_policy: output_nullability, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Create a new column by applying a transform function against + multiple input columns. + + Parameters + ---------- + inputs : Sequence[Column] + Columns to transform. + transform_udf : str + The PTX/CUDA string of the transform function to apply. + output_type : DataType + The output type that is compatible with the output type in the unary_udf. + is_ptx : bool + If `True`, the UDF is treated as PTX code. + If `False`, the UDF is treated as CUDA code. + is_null_aware: NullAware + If `NO`, the UDF gets non-nullable parameters + If `YES`, the UDF gets nullable parameters + null_policy: OutputNullability + If `PRESERVE`, null-masks are produced if necessary. + If `ALL_VALID`, null-masks are not produced. + `ALL_VALID` has undefined behavior if the UDF can produce nulls. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + Column + The transformed column having the UDF applied to each element. + """ +def encode(input: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> tuple[object, object]: + """Encode the rows of the given table as integers. + + Parameters + ---------- + input : Table + Table containing values to be encoded + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned objects' device memory. + + Returns + ------- + tuple[Table, Column] + The distinct row of the input table in sorted order, + and a column of integer indices representing the encoded rows. + """ +def one_hot_encode(input: Column, categories: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Encodes `input` by generating a new column + for each value in `categories` indicating the presence + of that value in `input`. + + Parameters + ---------- + input : Column + Column containing values to be encoded. + categories : Column + Column containing categories + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. + + Returns + ------- + Column + A table of the encoded values. + """ diff --git a/python/pylibcudf/pylibcudf/transpose.pyi b/python/pylibcudf/pylibcudf/transpose.pyi index fbf2d3fce2d3..6ee02584596b 100644 --- a/python/pylibcudf/pylibcudf/transpose.pyi +++ b/python/pylibcudf/pylibcudf/transpose.pyi @@ -1,13 +1,30 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/transpose.pyx + from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.table import Table -from pylibcudf.utils import CudaStreamLike +from .table import Table + +__all__ = ['transpose'] + +def transpose(input_table: Table, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Table: + """Transpose a Table. + + For details, see :cpp:func:`transpose`. + + Parameters + ---------- + input_table : Table + Table to transpose + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned table's device memory. -def transpose( - input_table: Table, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Table: ... + Returns + ------- + Table + Transposed table. + """ diff --git a/python/pylibcudf/pylibcudf/types.pyi b/python/pylibcudf/pylibcudf/types.pyi index 4be1ba5f9148..1eaaeb5c405d 100644 --- a/python/pylibcudf/pylibcudf/types.pyi +++ b/python/pylibcudf/pylibcudf/types.pyi @@ -1,103 +1,134 @@ -# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum -from typing import Any, Final - -PyarrowDataType = type[Any] - -class Interpolation(IntEnum): - LINEAR = ... - LOWER = ... - HIGHER = ... - MIDPOINT = ... - NEAREST = ... - -class MaskState(IntEnum): - UNALLOCATED = ... - UNINITIALIZED = ... - ALL_VALID = ... - ALL_NULL = ... - -class NanEquality(IntEnum): - ALL_EQUAL = ... - UNEQUAL = ... - -class NanPolicy(IntEnum): - NAN_IS_NULL = ... - NAN_IS_VALID = ... - -class NullEquality(IntEnum): - EQUAL = ... - UNEQUAL = ... - -class NullAware(IntEnum): - NO = ... - YES = ... - -class OutputNullability(IntEnum): - PRESERVE = ... - ALL_VALID = ... - -class NullOrder(IntEnum): - AFTER = ... - BEFORE = ... - -class NullPolicy(IntEnum): - EXCLUDE = ... - INCLUDE = ... - -class Order(IntEnum): - ASCENDING = ... - DESCENDING = ... - -class Sorted(IntEnum): - NO = ... - YES = ... - -class TypeId(IntEnum): - EMPTY = ... - INT8 = ... - INT16 = ... - INT32 = ... - INT64 = ... - UINT8 = ... - UINT16 = ... - UINT32 = ... - UINT64 = ... - FLOAT32 = ... - FLOAT64 = ... - BOOL8 = ... - TIMESTAMP_DAYS = ... - TIMESTAMP_SECONDS = ... - TIMESTAMP_MILLISECONDS = ... - TIMESTAMP_MICROSECONDS = ... - TIMESTAMP_NANOSECONDS = ... - DURATION_DAYS = ... - DURATION_SECONDS = ... - DURATION_MILLISECONDS = ... - DURATION_MICROSECONDS = ... - DURATION_NANOSECONDS = ... - DICTIONARY32 = ... - STRING = ... - LIST = ... - DECIMAL32 = ... - DECIMAL64 = ... - DECIMAL128 = ... - STRUCT = ... - NUM_TYPE_IDS = ... + +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/types.pyx + +from functools import cache + +from pylibcudf.libcudf.types import bitmask_type +from pylibcudf.libcudf.types import interpolation as Interpolation +from pylibcudf.libcudf.types import mask_state as MaskState +from pylibcudf.libcudf.types import nan_equality as NanEquality +from pylibcudf.libcudf.types import nan_policy as NanPolicy +from pylibcudf.libcudf.types import null_aware as NullAware +from pylibcudf.libcudf.types import null_equality as NullEquality +from pylibcudf.libcudf.types import null_order as NullOrder +from pylibcudf.libcudf.types import null_policy as NullPolicy +from pylibcudf.libcudf.types import order as Order +from pylibcudf.libcudf.types import output_nullability as OutputNullability +from pylibcudf.libcudf.types import size_type +from pylibcudf.libcudf.types import sorted as Sorted +from pylibcudf.libcudf.types import type_id +from pylibcudf.libcudf.types import type_id as TypeId +from pylibcudf.libcudf.utilities.type_dispatcher import type_to_id + +__all__ = ['DataType', 'Interpolation', 'MaskState', 'NanEquality', 'NanPolicy', 'NullEquality', 'NullOrder', 'NullAware', 'OutputNullability', 'NullPolicy', 'Order', 'SIZE_TYPE', 'SIZE_TYPE_ID', 'Sorted', 'TypeId', 'size_of'] +SIZE_TYPE = DataType(type_to_id[size_type]()) +SIZE_TYPE_ID = SIZE_TYPE.id() +BITMASK_TYPE = DataType(type_to_id[bitmask_type]()) class DataType: - def __init__(self, type_id: TypeId, scale: int = 0): ... - def id(self) -> TypeId: ... - def scale(self) -> int: ... - def to_arrow(self, **kwargs) -> PyarrowDataType: ... + """Indicator for the logical data type of an element in a column. + + This is the Cython representation of :cpp:class:`cudf::data_type`. + + Parameters + ---------- + id : type_id + The type's identifier + scale : int + The scale associated with the data. Only used for decimal data types. + """ + def __init__(self, id: type_id, scale: int=0): ... + def id(self) -> type_id: + """Get the id associated with this data type.""" + def scale(self) -> int: + """Get the scale associated with this data type.""" + @property + def _python_typecode(self) -> str: + """The Python struct module typecode string.""" + @property + def typestr(self) -> str: + """The array interface type string.""" + def __eq__(self, other): ... + def __hash__(self): ... + def __reduce__(self): ... + def to_arrow(self, **kwargs): + """ + Convert a datatype to arrow. + + Returns + ------- + pyarrow.DataType + + Notes + ----- + Translation of some types requires extra information as a keyword + argument. Specifically: + + - When translating a decimal type, provide ``precision`` + - When translating a struct type, provide ``fields`` + - When translating a list type, provide the wrapped ``value_type`` + """ @staticmethod - def from_arrow(pa_typ: PyarrowDataType) -> DataType: ... - def from_py(self, type: type) -> DataType: ... - def python_typecode(self) -> str: ... - def typestr(self) -> str: ... - -def size_of(t: DataType) -> int: ... - -SIZE_TYPE: Final[DataType] -SIZE_TYPE_ID: Final[TypeId] + def from_arrow(pa_typ) -> DataType: + """ + Construct a DataType from a Python type. + + Parameters + ---------- + pa_typ : pyarrow type + A Pyarrow type (eg. pa) + + Returns + ------- + DataType + The corresponding pylibcudf DataType. + + Raises + ------ + ImportError + If pyarrow is not installed. + TypeError + If the Python type is not supported. + """ + @staticmethod + def from_py(typ: type) -> DataType: + """ + Construct a DataType from a Python type. + + Parameters + ---------- + typ : type + A Python type (eg. int, str, list) + + Returns + ------- + DataType + The corresponding pylibcudf DataType. + + Raises + ------ + TypeError + If the Python type is not supported. + """ + +def size_of(t: DataType) -> int: + """Returns the size in bytes of elements of the specified data_type. + + Only fixed-width types are supported. + + For details, see :cpp:func:`size_of`. + + Parameters + ---------- + t : DataType + The DataType to get the size of. + + Returns + ------- + int + Size in bytes of an element of the specified type. + """ +@cache +def _from_arrow(obj: ...) -> DataType: ... diff --git a/python/pylibcudf/pylibcudf/unary.pyi b/python/pylibcudf/pylibcudf/unary.pyi index 821254912db5..03e4de7b615a 100644 --- a/python/pylibcudf/pylibcudf/unary.pyi +++ b/python/pylibcudf/pylibcudf/unary.pyi @@ -1,76 +1,170 @@ # SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from enum import IntEnum +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/unary.pyx +from pylibcudf.libcudf.unary import unary_operator +from pylibcudf.libcudf.unary import unary_operator as UnaryOperator from rmm.pylibrmm.memory_resource import DeviceMemoryResource -from pylibcudf.column import Column -from pylibcudf.types import DataType -from pylibcudf.utils import CudaStreamLike - -class UnaryOperator(IntEnum): - SIN = ... - COS = ... - TAN = ... - ARCSIN = ... - ARCCOS = ... - ARCTAN = ... - SINH = ... - COSH = ... - TANH = ... - ARCSINH = ... - ARCCOSH = ... - ARCTANH = ... - EXP = ... - LOG = ... - SQRT = ... - CBRT = ... - CEIL = ... - FLOOR = ... - ABS = ... - RINT = ... - BIT_COUNT = ... - BIT_INVERT = ... - NOT = ... - NEGATE = ... - -def unary_operation( - input: Column, - op: UnaryOperator, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_null( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_valid( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def cast( - input: Column, - data_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def bit_cast( - input: Column, - data_type: DataType, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_nan( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_not_nan( - input: Column, - stream: CudaStreamLike | None = None, - mr: DeviceMemoryResource | None = None, -) -> Column: ... -def is_supported_cast(from_: DataType, to: DataType) -> bool: ... +from .column import Column +from .types import DataType + +__all__ = ['UnaryOperator', 'bit_cast', 'cast', 'is_nan', 'is_not_nan', 'is_null', 'is_supported_cast', 'is_valid', 'unary_operation'] + +def unary_operation(input: Column, op: unary_operator, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Perform a unary operation on a column. + + For details, see :cpp:func:`unary_operation`. + + Parameters + ---------- + input : Column + The column to operate on. + op : UnaryOperator + The operation to perform. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + The result of the unary operation + """ +def is_null(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Check whether elements of a column are null. + + For details, see :cpp:func:`is_null`. + + Parameters + ---------- + input : Column + The column to check. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + A boolean column with ``True`` representing null values. + """ +def is_valid(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Check whether elements of a column are valid. + + For details, see :cpp:func:`is_valid`. + + Parameters + ---------- + input : Column + The column to check. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + A boolean column with ``True`` representing valid values. + """ +def cast(input: Column, data_type: DataType, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Cast a column to a different data type. + + For details, see :cpp:func:`cast`. + + Parameters + ---------- + input : Column + The column to check. + data_type : DataType + The data type to cast to. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + A boolean column with ``True`` representing null values. + """ +def bit_cast(input: Column, data_type: DataType, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Bit-cast a column to a different data type. + + For details, see :cpp:func:`bit_cast`. + + Parameters + ---------- + input : Column + The column to bit-cast. + data_type : DataType + The data type to bit-cast to. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + A column with the same bit representation reinterpreted as ``data_type``. + """ +def is_nan(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Check whether elements of a column are nan. + + For details, see :cpp:func:`is_nan`. + + Parameters + ---------- + input : Column + The column to check. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + A boolean column with ``True`` representing nan values. + """ +def is_not_nan(input: Column, stream: object | None=None, mr: DeviceMemoryResource | None=None) -> Column: + """Check whether elements of a column are not nan. + + For details, see :cpp:func:`is_not_nan`. + + Parameters + ---------- + input : Column + The column to check. + stream : Stream | None + CUDA stream on which to perform the operation. + mr : DeviceMemoryResource | None + Device memory resource used to allocate the returned column's device memory. + + Returns + ------- + pylibcudf.Column + A boolean column with ``True`` representing non-nan values. + """ +def is_supported_cast(from_: DataType, to: DataType) -> bool: + """Check if a cast between datatypes is supported. + + For details, see :cpp:func:`is_supported_cast`. + + Parameters + ---------- + from_ + The source datatype + to + The target datatype + + Returns + ------- + bool + True if the cast is supported. + """ diff --git a/python/pylibcudf/pylibcudf/utilities.pyi b/python/pylibcudf/pylibcudf/utilities.pyi index be514ef4949d..9f8803a7f8a1 100644 --- a/python/pylibcudf/pylibcudf/utilities.pyi +++ b/python/pylibcudf/pylibcudf/utilities.pyi @@ -1,4 +1,12 @@ -# SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -def is_ptds_enabled() -> bool: ... +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/utilities.pyx + +__all__ = ['is_ptds_enabled'] + +def is_ptds_enabled() -> bool: + """Checks if per-thread default stream is enabled. + + For details, see :cpp:func:`is_ptds_enabled`. + """ diff --git a/python/pylibcudf/pylibcudf/utils.pyi b/python/pylibcudf/pylibcudf/utils.pyi index cc3cb93e6c0b..e2c9fe7cd72d 100644 --- a/python/pylibcudf/pylibcudf/utils.pyi +++ b/python/pylibcudf/pylibcudf/utils.pyi @@ -1,13 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -from typing import Protocol +# This file was generated by stubgen-pyx v0.2.18 from python/pylibcudf/pylibcudf/utils.pyx from rmm.pylibrmm.stream import Stream -class HasCudaStream(Protocol): - def __cuda_stream__(self) -> tuple[int, int]: ... +constscalar = ... -CudaStreamLike = Stream | HasCudaStream - -def _get_stream(stream: CudaStreamLike | None = None) -> Stream: ... +def _get_stream(stream: object | None=None) -> Stream: ...