@@ -264,18 +264,7 @@ def set_option(*args) -> None:
264
264
"""
265
265
# Handle dictionary input
266
266
if len (args ) == 1 and isinstance (args [0 ], dict ):
267
- options_dict = args [0 ]
268
- for k , v in options_dict .items ():
269
- key = _get_single_key (k )
270
- opt = _get_registered_option (key )
271
- if opt and opt .validator :
272
- opt .validator (v )
273
- # walk the nested dict
274
- root , k_root = _get_root (key )
275
- root [k_root ] = v
276
- if opt .cb :
277
- opt .cb (key )
278
- return
267
+ args = tuple (kv for item in args [0 ].items () for kv in item )
279
268
280
269
# Handle single option-value pair
281
270
if len (args ) == 2 :
@@ -485,9 +474,10 @@ def option_context(*args) -> Generator[None]:
485
474
486
475
Parameters
487
476
----------
488
- *args : str | object
477
+ *args : str | object | dict
489
478
An even amount of arguments provided in pairs which will be
490
- interpreted as (pattern, value) pairs.
479
+ interpreted as (pattern, value) pairs. Alternatively, a single
480
+ dictionary of {pattern: value} may be provided.
491
481
492
482
Returns
493
483
-------
@@ -516,7 +506,12 @@ def option_context(*args) -> Generator[None]:
516
506
>>> from pandas import option_context
517
507
>>> with option_context("display.max_rows", 10, "display.max_columns", 5):
518
508
... pass
509
+ >>> with option_context({"display.max_rows": 10, "display.max_columns": 5}):
510
+ ... pass
519
511
"""
512
+ if len (args ) == 1 and isinstance (args [0 ], dict ):
513
+ args = tuple (kv for item in args [0 ].items () for kv in item )
514
+
520
515
if len (args ) % 2 != 0 or len (args ) < 2 :
521
516
raise ValueError (
522
517
"Provide an even amount of arguments as "
0 commit comments