A helper function for dealing with the way that matplotlib annoyingly allows multiple keyword arguments. For example, ``edgecolor`` and ``ec`` are generally equivalent but no exception is thrown if they are both used. *Note: This function does throw a :class:`TypeError` if more
(_dict, default, *args)
| 1350 | |
| 1351 | |
| 1352 | def _pop_multiple(_dict, default, *args): |
| 1353 | """ |
| 1354 | A helper function for dealing with the way that matplotlib annoyingly |
| 1355 | allows multiple keyword arguments. For example, ``edgecolor`` and ``ec`` |
| 1356 | are generally equivalent but no exception is thrown if they are both |
| 1357 | used. |
| 1358 | |
| 1359 | *Note: This function does throw a :class:`TypeError` if more than one |
| 1360 | of the equivalent arguments are provided.* |
| 1361 | |
| 1362 | :param _dict: |
| 1363 | A :class:`dict`-like object to "pop" from. |
| 1364 | |
| 1365 | :param default: |
| 1366 | The default value to return if none of the arguments are provided. |
| 1367 | |
| 1368 | :param *args: |
| 1369 | The arguments to try to retrieve. |
| 1370 | |
| 1371 | """ |
| 1372 | assert len(args) > 0, "You must provide at least one argument to `pop()`." |
| 1373 | |
| 1374 | results = [] |
| 1375 | for arg in args: |
| 1376 | try: |
| 1377 | results.append((arg, _dict.pop(arg))) |
| 1378 | except KeyError: |
| 1379 | pass |
| 1380 | |
| 1381 | if len(results) > 1: |
| 1382 | raise TypeError( |
| 1383 | "The arguments ({0}) are equivalent, you can only provide one of them.".format( |
| 1384 | ", ".join([key for key, value in results]) |
| 1385 | ) |
| 1386 | ) |
| 1387 | |
| 1388 | if len(results) == 0: |
| 1389 | return default |
| 1390 | |
| 1391 | return results[0][1] |
| 1392 | |
| 1393 | |
| 1394 | class SameLocationError(Exception): |