Skip to content

Commit 4334a44

Browse files
committed
fix more doctests
1 parent 150d8be commit 4334a44

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

bigframes/core/compile/polars/compiler.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,14 +717,22 @@ def _ordered_join(
717717
]
718718
)
719719
if how != "cross":
720+
# Note: join_nulls renamed to nulls_equal for polars 1.24
721+
polars_version = tuple(
722+
int(part) for part in pl.__version__.split(".") if part.isnumeric()
723+
)
724+
if polars_version >= (1, 24, 0):
725+
join_kwargs = {"nulls_equal": join_nulls}
726+
else:
727+
join_kwargs = {"join_nulls": join_nulls}
728+
720729
joined = left.join(
721730
right,
722731
how=how,
723732
left_on=left_on,
724733
right_on=right_on,
725-
# Note: join_nulls renamed to nulls_equal for polars 1.24
726-
join_nulls=join_nulls, # type: ignore
727734
coalesce=False,
735+
**join_kwargs, # type: ignore
728736
)
729737
else:
730738
joined = left.join(right, how=how, coalesce=False)

third_party/bigframes_vendored/pandas/core/frame.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ def to_gbq(
405405
406406
**Examples:**
407407
408+
>>> import bigframes.pandas as bpd
408409
409410
Write a DataFrame to a BigQuery table.
410411
@@ -513,7 +514,7 @@ def to_parquet(
513514
514515
**Examples:**
515516
516-
517+
>>> import bigframes.pandas as bpd
517518
>>> df = bpd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
518519
>>> gcs_bucket = "gs://bigframes-dev-testing/sample_parquet*.parquet"
519520
>>> df.to_parquet(path=gcs_bucket)
@@ -4843,22 +4844,22 @@ def apply(self, func, *, axis=0, args=(), **kwargs):
48434844
to select only the necessary columns before calling `apply()`. Note: This
48444845
feature is currently in **preview**.
48454846
4846-
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default")
4847+
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default") # doctest: +SKIP
48474848
... def foo(row: pd.Series) -> int:
48484849
... result = 1
48494850
... result += row["col1"]
48504851
... result += row["col2"]*row["col2"]
48514852
... return result
48524853
4853-
>>> df[["col1", "col2"]].apply(foo, axis=1)
4854+
>>> df[["col1", "col2"]].apply(foo, axis=1) # doctest: +SKIP
48544855
0 11
48554856
1 19
48564857
dtype: Int64
48574858
48584859
You could return an array output for every input row from the remote
48594860
function.
48604861
4861-
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default")
4862+
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default") # doctest: +SKIP
48624863
... def marks_analyzer(marks: pd.Series) -> list[float]:
48634864
... import statistics
48644865
... average = marks.mean()
@@ -4875,8 +4876,8 @@ def apply(self, func, *, axis=0, args=(), **kwargs):
48754876
... "chemistry": [88, 56, 72],
48764877
... "algebra": [78, 91, 79]
48774878
... }, index=["Alice", "Bob", "Charlie"])
4878-
>>> stats = df.apply(marks_analyzer, axis=1)
4879-
>>> stats
4879+
>>> stats = df.apply(marks_analyzer, axis=1) # doctest: +SKIP
4880+
>>> stats # doctest: +SKIP
48804881
Alice [77.67 78. 77.19 76.71]
48814882
Bob [75.67 80. 74.15 72.56]
48824883
Charlie [75.33 75. 75.28 75.22]
@@ -4899,14 +4900,14 @@ def apply(self, func, *, axis=0, args=(), **kwargs):
48994900
<BLANKLINE>
49004901
[2 rows x 3 columns]
49014902
4902-
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default")
4903+
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default") # doctest: +SKIP
49034904
... def foo(x: int, y: int, z: int) -> float:
49044905
... result = 1
49054906
... result += x
49064907
... result += y/z
49074908
... return result
49084909
4909-
>>> df.apply(foo, axis=1)
4910+
>>> df.apply(foo, axis=1) # doctest: +SKIP
49104911
0 2.6
49114912
1 3.8
49124913
dtype: Float64

third_party/bigframes_vendored/pandas/core/indexes/accessor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def dayofyear(self):
9797
9898
**Examples:**
9999
100+
>>> import bigframes.pandas as bpd
100101
>>> s = bpd.Series(
101102
... pd.date_range('2016-12-28', '2017-01-03', freq='D').to_series()
102103
... )

third_party/bigframes_vendored/pandas/core/reshape/tile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def cut(
3333
3434
**Examples:**
3535
36-
36+
>>> import bigframes.pandas as bpd
3737
>>> s = bpd.Series([0, 1, 5, 10])
3838
>>> s
3939
0 0

third_party/bigframes_vendored/pandas/core/series.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def dt(self):
3737
3838
**Examples:**
3939
40-
40+
>>> import bigframes.pandas as bpd
4141
>>> seconds_series = bpd.Series(pd.date_range("2000-01-01", periods=3, freq="s"))
4242
>>> seconds_series
4343
0 2000-01-01 00:00:00
@@ -1053,6 +1053,7 @@ def duplicated(self, keep="first") -> Series:
10531053
10541054
**Examples:**
10551055
1056+
>>> import bigframes.pandas as bpd
10561057
10571058
By default, for each set of duplicated values, the first occurrence is
10581059
set on False and all others on True:
@@ -1616,7 +1617,7 @@ def nlargest(
16161617
16171618
**Examples:**
16181619
1619-
1620+
>>> import bigframes.pandas as bpd
16201621
>>> countries_population = {"Italy": 59000000, "France": 65000000,
16211622
... "Malta": 434000, "Maldives": 434000,
16221623
... "Brunei": 434000, "Iceland": 337000,
@@ -1700,7 +1701,7 @@ def nsmallest(self, n: int = 5, keep: str = "first") -> Series:
17001701
17011702
**Examples:**
17021703
1703-
1704+
>>> import bigframes.pandas as bpd
17041705
>>> countries_population = {"Italy": 59000000, "France": 65000000,
17051706
... "Malta": 434000, "Maldives": 434000,
17061707
... "Brunei": 434000, "Iceland": 337000,
@@ -4570,7 +4571,7 @@ def median(self, *, exact: bool = True):
45704571
45714572
**Examples:**
45724573
4573-
4574+
>>> import bigframes.pandas as bpd
45744575
>>> s = bpd.Series([1, 2, 3])
45754576
>>> s.median()
45764577
np.float64(2.0)
@@ -4870,7 +4871,6 @@ def mask(self, cond, other):
48704871
48714872
**Examples:**
48724873
4873-
48744874
>>> s = bpd.Series([10, 11, 12, 13, 14])
48754875
>>> s
48764876
0 10
@@ -4914,7 +4914,7 @@ def mask(self, cond, other):
49144914
condition is evaluated based on a complicated business logic which cannot
49154915
be expressed in form of a Series.
49164916
4917-
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default")
4917+
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default") # doctest: +SKIP
49184918
... def should_mask(name: str) -> bool:
49194919
... hash = 0
49204920
... for char_ in name:
@@ -4927,12 +4927,12 @@ def mask(self, cond, other):
49274927
1 Bob
49284928
2 Caroline
49294929
dtype: string
4930-
>>> s.mask(should_mask)
4930+
>>> s.mask(should_mask) # doctest: +SKIP
49314931
0 <NA>
49324932
1 Bob
49334933
2 Caroline
49344934
dtype: string
4935-
>>> s.mask(should_mask, "REDACTED")
4935+
>>> s.mask(should_mask, "REDACTED") # doctest: +SKIP
49364936
0 REDACTED
49374937
1 Bob
49384938
2 Caroline
@@ -5469,7 +5469,6 @@ def map(
54695469
54705470
**Examples:**
54715471
5472-
54735472
>>> s = bpd.Series(['cat', 'dog', pd.NA, 'rabbit'])
54745473
>>> s
54755474
0 cat
@@ -5490,7 +5489,7 @@ def map(
54905489
54915490
It also accepts a remote function:
54925491
5493-
>>> @bpd.remote_function(cloud_function_service_account="default")
5492+
>>> @bpd.remote_function(cloud_function_service_account="default") # doctest: +SKIP
54945493
... def my_mapper(val: str) -> str:
54955494
... vowels = ["a", "e", "i", "o", "u"]
54965495
... if val:
@@ -5499,7 +5498,7 @@ def map(
54995498
... ])
55005499
... return "N/A"
55015500
5502-
>>> s.map(my_mapper)
5501+
>>> s.map(my_mapper) # doctest: +SKIP
55035502
0 cAt
55045503
1 dOg
55055504
2 N/A

0 commit comments

Comments
 (0)