From bab36320c8ddb844c4ca6f1352997300757c4704 Mon Sep 17 00:00:00 2001 From: Artur Niederfahrenhorst Date: Wed, 23 Oct 2024 15:48:53 +0200 Subject: [PATCH] fix doctests --- python/ray/data/dataset.py | 2 +- python/ray/data/iterator.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/ray/data/dataset.py b/python/ray/data/dataset.py index 43268a5bd8fb..1890533e75fc 100644 --- a/python/ray/data/dataset.py +++ b/python/ray/data/dataset.py @@ -4278,7 +4278,7 @@ def to_tf( If your model accepts additional metadata aside from features and label, specify a single additional column or a list of additional columns. A common use case is to include sample weights in the data samples and train a ``tf.keras.Model`` with ``tf.keras.Model.fit``. - >>> ds = ds.add_column("sample weights", lambda df: 1) + >>> ds = ds.add_column("sample weights", lambda x: [1] * x.num_rows) >>> ds.to_tf(feature_columns="features", label_columns="target", additional_columns="sample weights") <_OptionsDataset element_spec=(TensorSpec(shape=(None, 4), dtype=tf.float64, name='features'), TensorSpec(shape=(None,), dtype=tf.int64, name='target'), TensorSpec(shape=(None,), dtype=tf.int64, name='sample weights'))> diff --git a/python/ray/data/iterator.py b/python/ray/data/iterator.py index 498950806a76..1af478d935cb 100644 --- a/python/ray/data/iterator.py +++ b/python/ray/data/iterator.py @@ -758,7 +758,7 @@ def to_tf( If your model accepts additional metadata aside from features and label, specify a single additional column or a list of additional columns. A common use case is to include sample weights in the data samples and train a ``tf.keras.Model`` with ``tf.keras.Model.fit``. - >>> ds = ds.add_column("sample weights", lambda df: 1) + >>> ds = ds.add_column("sample weights", lambda x: [1] * x.num_rows) >>> it = ds.iterator() >>> it.to_tf(feature_columns="sepal length (cm)", label_columns="target", additional_columns="sample weights") <_OptionsDataset element_spec=(TensorSpec(shape=(None,), dtype=tf.float64, name='sepal length (cm)'), TensorSpec(shape=(None,), dtype=tf.int64, name='target'), TensorSpec(shape=(None,), dtype=tf.int64, name='sample weights'))>