@@ -2416,13 +2416,15 @@ def test_to_arrow_error_if_pyarrow_is_none(self):
2416
2416
row_iterator .to_arrow ()
2417
2417
2418
2418
def test_to_arrow (self ):
2419
+ pytest .importorskip ("numpy" )
2419
2420
pyarrow = pytest .importorskip ("pyarrow" )
2420
2421
row_iterator = self ._make_one ()
2421
2422
tbl = row_iterator .to_arrow ()
2422
2423
self .assertIsInstance (tbl , pyarrow .Table )
2423
2424
self .assertEqual (tbl .num_rows , 0 )
2424
2425
2425
2426
def test_to_arrow_iterable (self ):
2427
+ pytest .importorskip ("numpy" )
2426
2428
pyarrow = pytest .importorskip (
2427
2429
"pyarrow" , minversion = self .PYARROW_MINIMUM_VERSION
2428
2430
)
@@ -3089,6 +3091,7 @@ def test_to_arrow_iterable_w_bqstorage(self):
3089
3091
bqstorage_client ._transport .grpc_channel .close .assert_not_called ()
3090
3092
3091
3093
def test_to_arrow (self ):
3094
+ pytest .importorskip ("numpy" )
3092
3095
pyarrow = pytest .importorskip (
3093
3096
"pyarrow" , minversion = self .PYARROW_MINIMUM_VERSION
3094
3097
)
@@ -3173,6 +3176,7 @@ def test_to_arrow(self):
3173
3176
)
3174
3177
3175
3178
def test_to_arrow_w_nulls (self ):
3179
+ pytest .importorskip ("numpy" )
3176
3180
pyarrow = pytest .importorskip (
3177
3181
"pyarrow" , minversion = self .PYARROW_MINIMUM_VERSION
3178
3182
)
@@ -3209,6 +3213,7 @@ def test_to_arrow_w_nulls(self):
3209
3213
self .assertEqual (ages , [32 , 29 , None , 111 ])
3210
3214
3211
3215
def test_to_arrow_w_unknown_type (self ):
3216
+ pytest .importorskip ("numpy" )
3212
3217
pyarrow = pytest .importorskip (
3213
3218
"pyarrow" , minversion = self .PYARROW_MINIMUM_VERSION
3214
3219
)
@@ -3254,6 +3259,7 @@ def test_to_arrow_w_unknown_type(self):
3254
3259
self .assertTrue (all ("sport" in str (warning ) for warning in warned ))
3255
3260
3256
3261
def test_to_arrow_w_empty_table (self ):
3262
+ pytest .importorskip ("numpy" )
3257
3263
pyarrow = pytest .importorskip (
3258
3264
"pyarrow" , minversion = self .PYARROW_MINIMUM_VERSION
3259
3265
)
@@ -3295,6 +3301,7 @@ def test_to_arrow_w_empty_table(self):
3295
3301
self .assertEqual (child_field .type .value_type [1 ].name , "age" )
3296
3302
3297
3303
def test_to_arrow_max_results_w_explicit_bqstorage_client_warning (self ):
3304
+ pytest .importorskip ("numpy" )
3298
3305
pytest .importorskip ("pyarrow" )
3299
3306
pytest .importorskip ("google.cloud.bigquery_storage" )
3300
3307
from google .cloud .bigquery .schema import SchemaField
@@ -3337,6 +3344,7 @@ def test_to_arrow_max_results_w_explicit_bqstorage_client_warning(self):
3337
3344
mock_client ._ensure_bqstorage_client .assert_not_called ()
3338
3345
3339
3346
def test_to_arrow_max_results_w_create_bqstorage_client_no_warning (self ):
3347
+ pytest .importorskip ("numpy" )
3340
3348
pytest .importorskip ("pyarrow" )
3341
3349
pytest .importorskip ("google.cloud.bigquery_storage" )
3342
3350
from google .cloud .bigquery .schema import SchemaField
@@ -3375,6 +3383,7 @@ def test_to_arrow_max_results_w_create_bqstorage_client_no_warning(self):
3375
3383
mock_client ._ensure_bqstorage_client .assert_not_called ()
3376
3384
3377
3385
def test_to_arrow_w_bqstorage (self ):
3386
+ pytest .importorskip ("numpy" )
3378
3387
pyarrow = pytest .importorskip ("pyarrow" )
3379
3388
pytest .importorskip ("google.cloud.bigquery_storage" )
3380
3389
from google .cloud .bigquery import schema
@@ -3458,6 +3467,7 @@ def test_to_arrow_w_bqstorage(self):
3458
3467
bqstorage_client ._transport .grpc_channel .close .assert_not_called ()
3459
3468
3460
3469
def test_to_arrow_w_bqstorage_creates_client (self ):
3470
+ pytest .importorskip ("numpy" )
3461
3471
pytest .importorskip ("pyarrow" )
3462
3472
pytest .importorskip ("google.cloud.bigquery_storage" )
3463
3473
from google .cloud .bigquery import schema
@@ -3491,6 +3501,7 @@ def test_to_arrow_w_bqstorage_creates_client(self):
3491
3501
bqstorage_client ._transport .grpc_channel .close .assert_called_once ()
3492
3502
3493
3503
def test_to_arrow_ensure_bqstorage_client_wo_bqstorage (self ):
3504
+ pytest .importorskip ("numpy" )
3494
3505
pyarrow = pytest .importorskip (
3495
3506
"pyarrow" , minversion = self .PYARROW_MINIMUM_VERSION
3496
3507
)
@@ -3524,6 +3535,7 @@ def mock_verify_version(raise_if_error: bool = False):
3524
3535
self .assertEqual (tbl .num_rows , 2 )
3525
3536
3526
3537
def test_to_arrow_w_bqstorage_no_streams (self ):
3538
+ pytest .importorskip ("numpy" )
3527
3539
pyarrow = pytest .importorskip ("pyarrow" )
3528
3540
pytest .importorskip ("google.cloud.bigquery_storage" )
3529
3541
from google .cloud .bigquery import schema
@@ -3563,6 +3575,7 @@ def test_to_arrow_w_bqstorage_no_streams(self):
3563
3575
self .assertEqual (actual_table .schema [2 ].name , "colB" )
3564
3576
3565
3577
def test_to_arrow_progress_bar (self ):
3578
+ pytest .importorskip ("numpy" )
3566
3579
pytest .importorskip ("pyarrow" )
3567
3580
pytest .importorskip ("tqdm" )
3568
3581
pytest .importorskip ("tqdm.notebook" )
@@ -3696,6 +3709,7 @@ def test_to_dataframe_iterable_with_dtypes(self):
3696
3709
self .assertEqual (df_2 ["age" ][0 ], 33 )
3697
3710
3698
3711
def test_to_dataframe_iterable_w_bqstorage (self ):
3712
+ pytest .importorskip ("numpy" )
3699
3713
pandas = pytest .importorskip ("pandas" )
3700
3714
pyarrow = pytest .importorskip ("pyarrow" )
3701
3715
pytest .importorskip ("google.cloud.bigquery_storage" )
@@ -3770,6 +3784,7 @@ def test_to_dataframe_iterable_w_bqstorage(self):
3770
3784
bqstorage_client ._transport .grpc_channel .close .assert_not_called ()
3771
3785
3772
3786
def test_to_dataframe_iterable_w_bqstorage_max_results_warning (self ):
3787
+ pytest .importorskip ("numpy" )
3773
3788
pandas = pytest .importorskip ("pandas" )
3774
3789
pytest .importorskip ("google.cloud.bigquery_storage" )
3775
3790
from google .cloud .bigquery import schema
@@ -4513,7 +4528,7 @@ def test_to_dataframe_w_none_dtypes_mapper(self):
4513
4528
4514
4529
def test_to_dataframe_w_unsupported_dtypes_mapper (self ):
4515
4530
pytest .importorskip ("pandas" )
4516
- import numpy
4531
+ numpy = pytest . importorskip ( " numpy" )
4517
4532
from google .cloud .bigquery .schema import SchemaField
4518
4533
4519
4534
schema = [
@@ -4797,6 +4812,7 @@ def test_to_dataframe_max_results_w_create_bqstorage_client_no_warning(self):
4797
4812
mock_client ._ensure_bqstorage_client .assert_not_called ()
4798
4813
4799
4814
def test_to_dataframe_w_bqstorage_creates_client (self ):
4815
+ pytest .importorskip ("numpy" )
4800
4816
pytest .importorskip ("pandas" )
4801
4817
pytest .importorskip ("google.cloud.bigquery_storage" )
4802
4818
from google .cloud .bigquery import schema
@@ -4830,6 +4846,7 @@ def test_to_dataframe_w_bqstorage_creates_client(self):
4830
4846
bqstorage_client ._transport .grpc_channel .close .assert_called_once ()
4831
4847
4832
4848
def test_to_dataframe_w_bqstorage_no_streams (self ):
4849
+ pytest .importorskip ("numpy" )
4833
4850
pytest .importorskip ("pandas" )
4834
4851
pytest .importorskip ("google.cloud.bigquery_storage" )
4835
4852
from google .cloud .bigquery import schema
@@ -4858,6 +4875,7 @@ def test_to_dataframe_w_bqstorage_no_streams(self):
4858
4875
self .assertTrue (got .empty )
4859
4876
4860
4877
def test_to_dataframe_w_bqstorage_logs_session (self ):
4878
+ pytest .importorskip ("numpy" )
4861
4879
pytest .importorskip ("google.cloud.bigquery_storage" )
4862
4880
pytest .importorskip ("pandas" )
4863
4881
pytest .importorskip ("pyarrow" )
@@ -4882,6 +4900,7 @@ def test_to_dataframe_w_bqstorage_logs_session(self):
4882
4900
)
4883
4901
4884
4902
def test_to_dataframe_w_bqstorage_empty_streams (self ):
4903
+ pytest .importorskip ("numpy" )
4885
4904
pytest .importorskip ("google.cloud.bigquery_storage" )
4886
4905
pytest .importorskip ("pandas" )
4887
4906
pyarrow = pytest .importorskip ("pyarrow" )
@@ -4936,6 +4955,7 @@ def test_to_dataframe_w_bqstorage_empty_streams(self):
4936
4955
self .assertTrue (got .empty )
4937
4956
4938
4957
def test_to_dataframe_w_bqstorage_nonempty (self ):
4958
+ pytest .importorskip ("numpy" )
4939
4959
pytest .importorskip ("google.cloud.bigquery_storage" )
4940
4960
pytest .importorskip ("pandas" )
4941
4961
pyarrow = pytest .importorskip ("pyarrow" )
@@ -5018,6 +5038,7 @@ def test_to_dataframe_w_bqstorage_nonempty(self):
5018
5038
bqstorage_client ._transport .grpc_channel .close .assert_not_called ()
5019
5039
5020
5040
def test_to_dataframe_w_bqstorage_multiple_streams_return_unique_index (self ):
5041
+ pytest .importorskip ("numpy" )
5021
5042
bigquery_storage = pytest .importorskip ("google.cloud.bigquery_storage" )
5022
5043
pytest .importorskip ("pandas" )
5023
5044
pyarrow = pytest .importorskip ("pyarrow" )
@@ -5070,6 +5091,7 @@ def test_to_dataframe_w_bqstorage_multiple_streams_return_unique_index(self):
5070
5091
self .assertTrue (got .index .is_unique )
5071
5092
5072
5093
def test_to_dataframe_w_bqstorage_updates_progress_bar (self ):
5094
+ pytest .importorskip ("numpy" )
5073
5095
bigquery_storage = pytest .importorskip ("google.cloud.bigquery_storage" )
5074
5096
pytest .importorskip ("pandas" )
5075
5097
pyarrow = pytest .importorskip ("pyarrow" )
@@ -5147,6 +5169,7 @@ def blocking_to_arrow(*args, **kwargs):
5147
5169
tqdm_mock ().close .assert_called_once ()
5148
5170
5149
5171
def test_to_dataframe_w_bqstorage_exits_on_keyboardinterrupt (self ):
5172
+ pytest .importorskip ("numpy" )
5150
5173
bigquery_storage = pytest .importorskip ("google.cloud.bigquery_storage" )
5151
5174
pytest .importorskip ("pandas" )
5152
5175
pyarrow = pytest .importorskip ("pyarrow" )
@@ -5322,6 +5345,7 @@ def test_to_dataframe_w_bqstorage_snapshot(self):
5322
5345
row_iterator .to_dataframe (bqstorage_client )
5323
5346
5324
5347
def test_to_dataframe_concat_categorical_dtype_w_pyarrow (self ):
5348
+ pytest .importorskip ("numpy" )
5325
5349
pytest .importorskip ("google.cloud.bigquery_storage" )
5326
5350
pandas = pytest .importorskip ("pandas" )
5327
5351
pyarrow = pytest .importorskip ("pyarrow" )
@@ -5604,7 +5628,7 @@ def test_rowiterator_to_geodataframe_delegation(self, to_dataframe):
5604
5628
"""
5605
5629
pandas = pytest .importorskip ("pandas" )
5606
5630
geopandas = pytest .importorskip ("geopandas" )
5607
- import numpy
5631
+ numpy = pytest . importorskip ( " numpy" )
5608
5632
from shapely import wkt
5609
5633
5610
5634
row_iterator = self ._make_one_from_data (
0 commit comments