@@ -264,18 +264,7 @@ def set_option(*args) -> None:
264264 """
265265 # Handle dictionary input
266266 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 )
279268
280269 # Handle single option-value pair
281270 if len (args ) == 2 :
@@ -485,9 +474,10 @@ def option_context(*args) -> Generator[None]:
485474
486475 Parameters
487476 ----------
488- *args : str | object
477+ *args : str | object | dict
489478 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.
491481
492482 Returns
493483 -------
@@ -516,7 +506,12 @@ def option_context(*args) -> Generator[None]:
516506 >>> from pandas import option_context
517507 >>> with option_context("display.max_rows", 10, "display.max_columns", 5):
518508 ... pass
509+ >>> with option_context({"display.max_rows": 10, "display.max_columns": 5}):
510+ ... pass
519511 """
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+
520515 if len (args ) % 2 != 0 or len (args ) < 2 :
521516 raise ValueError (
522517 "Provide an even amount of arguments as "
0 commit comments