MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _parse_args

Function _parse_args

lib/matplotlib/quiver.py:441–490  ·  view source on GitHub ↗

Helper function to parse positional parameters for colored vector plots. This is currently used for Quiver and Barbs. Parameters ---------- *args : list list of 2-5 arguments. Depending on their number they are parsed to:: U, V U, V, C

(*args, caller_name='function')

Source from the content-addressed store, hash-verified

439
440
441def _parse_args(*args, caller_name='function'):
442 """
443 Helper function to parse positional parameters for colored vector plots.
444
445 This is currently used for Quiver and Barbs.
446
447 Parameters
448 ----------
449 *args : list
450 list of 2-5 arguments. Depending on their number they are parsed to::
451
452 U, V
453 U, V, C
454 X, Y, U, V
455 X, Y, U, V, C
456
457 caller_name : str
458 Name of the calling method (used in error messages).
459 """
460 X = Y = C = None
461
462 nargs = len(args)
463 if nargs == 2:
464 # The use of atleast_1d allows for handling scalar arguments while also
465 # keeping masked arrays
466 U, V = np.atleast_1d(*args)
467 elif nargs == 3:
468 U, V, C = np.atleast_1d(*args)
469 elif nargs == 4:
470 X, Y, U, V = np.atleast_1d(*args)
471 elif nargs == 5:
472 X, Y, U, V, C = np.atleast_1d(*args)
473 else:
474 raise _api.nargs_error(caller_name, takes="from 2 to 5", given=nargs)
475
476 nr, nc = (1, U.shape[0]) if U.ndim == 1 else U.shape
477
478 if X is not None:
479 X = X.ravel()
480 Y = Y.ravel()
481 if len(X) == nc and len(Y) == nr:
482 X, Y = (a.ravel() for a in np.meshgrid(X, Y))
483 elif len(X) != len(Y):
484 raise ValueError('X and Y must be the same size, but '
485 f'X.size is {X.size} and Y.size is {Y.size}.')
486 else:
487 indexgrid = np.meshgrid(np.arange(nc), np.arange(nr))
488 X, Y = (np.ravel(a) for a in indexgrid)
489 # Size validation for U, V, C is left to the set_UVC method.
490 return X, Y, U, V, C
491
492
493def _check_consistent_shapes(*arrays):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…