Skip to content

Commit 95a2fba

Browse files
committed
tests(bigframes): re-enable some tests blocking the doctest
1 parent 7bb29e5 commit 95a2fba

3 files changed

Lines changed: 15 additions & 30 deletions

File tree

packages/bigframes/bigframes/bigquery/_operations/struct.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ def struct(value: dataframe.DataFrame) -> series.Series:
4141
4242
>>> srs = series.Series([{"version": 1, "project": "pandas"}, {"version": 2, "project": "numpy"},])
4343
>>> df = srs.struct.explode()
44-
>>> df = df[["project", "version"]] # set the column order to ensure stable output for doctest
4544
>>> bbq.struct(df)
46-
0 {'project': 'pandas', 'version': 1}
47-
1 {'project': 'numpy', 'version': 2}
48-
dtype: struct<project: string, version: int64>[pyarrow]
45+
0 {'version': 1, 'project': 'pandas'}
46+
1 {'version': 2, 'project': 'numpy'}
47+
dtype: struct<version: int64, project: string>[pyarrow]
4948
5049
Args:
5150
value (bigframes.dataframe.DataFrame):

packages/bigframes/tests/system/small/bigquery/test_json.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ def test_to_json_from_int():
398398
def test_to_json_from_struct():
399399
s = bpd.Series(
400400
[
401-
{"project": "pandas", "version": 1},
402-
{"project": "numpy", "version": 2},
401+
{"version": 1, "project": "pandas"},
402+
{"version": 2, "project": "numpy"},
403403
]
404404
)
405405
assert dtypes.is_struct_like(s.dtype)
@@ -410,9 +410,7 @@ def test_to_json_from_struct():
410410
dtype=dtypes.JSON_DTYPE,
411411
)
412412

413-
actual_json = [json.loads(x) for x in actual.to_pandas()]
414-
expected_json = [json.loads(x) for x in expected.to_pandas()]
415-
assert actual_json == expected_json
413+
pd.testing.assert_series_equal(actual.to_pandas(), expected.to_pandas())
416414

417415

418416
def test_to_json_string_from_int():
@@ -425,8 +423,8 @@ def test_to_json_string_from_int():
425423
def test_to_json_string_from_struct():
426424
s = bpd.Series(
427425
[
428-
{"project": "pandas", "version": 1},
429-
{"project": "numpy", "version": 2},
426+
{"version": 1, "project": "pandas"},
427+
{"version": 2, "project": "numpy"},
430428
]
431429
)
432430
assert dtypes.is_struct_like(s.dtype)
@@ -437,9 +435,7 @@ def test_to_json_string_from_struct():
437435
dtype=dtypes.STRING_DTYPE,
438436
)
439437

440-
actual_json = [json.loads(x) for x in actual.to_pandas()]
441-
expected_json = [json.loads(x) for x in expected.to_pandas()]
442-
assert actual_json == expected_json
438+
pd.testing.assert_series_equal(actual.to_pandas(), expected.to_pandas())
443439

444440

445441
def test_json_keys():

packages/bigframes/tests/system/small/test_series.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,14 +1232,9 @@ def test_divmods_series(scalars_dfs, col_x, col_y, method):
12321232
scalars_pandas_df[col_y]
12331233
)
12341234
# BigQuery's mod functions return NUMERIC values for non-INT64 inputs.
1235-
if bf_div_result.dtype == pd.Int64Dtype():
1236-
bigframes.testing.utils.assert_series_equal(
1237-
pd_div_result, bf_div_result.to_pandas(), check_dtype=False
1238-
)
1239-
else:
1240-
bigframes.testing.utils.assert_series_equal(
1241-
pd_div_result, bf_div_result.astype("Float64").to_pandas()
1242-
)
1235+
bigframes.testing.utils.assert_series_equal(
1236+
pd_div_result, bf_div_result.astype("Float64").to_pandas()
1237+
)
12431238

12441239
if bf_mod_result.dtype == pd.Int64Dtype():
12451240
bigframes.testing.utils.assert_series_equal(
@@ -1277,14 +1272,9 @@ def test_divmods_scalars(scalars_dfs, col_x, other, method):
12771272
bf_div_result, bf_mod_result = getattr(scalars_df[col_x], method)(other)
12781273
pd_div_result, pd_mod_result = getattr(scalars_pandas_df[col_x], method)(other)
12791274
# BigQuery's mod functions return NUMERIC values for non-INT64 inputs.
1280-
if bf_div_result.dtype == pd.Int64Dtype():
1281-
bigframes.testing.utils.assert_series_equal(
1282-
pd_div_result, bf_div_result.to_pandas(), check_dtype=False
1283-
)
1284-
else:
1285-
bigframes.testing.utils.assert_series_equal(
1286-
pd_div_result, bf_div_result.astype("Float64").to_pandas()
1287-
)
1275+
bigframes.testing.utils.assert_series_equal(
1276+
pd_div_result, bf_div_result.astype("Float64").to_pandas()
1277+
)
12881278

12891279
if bf_mod_result.dtype == pd.Int64Dtype():
12901280
bigframes.testing.utils.assert_series_equal(

0 commit comments

Comments
 (0)