MCPcopy Create free account
hub / github.com/PythonOT/POT / check_number_threads

Function check_number_threads

ot/utils.py:1459–1480  ·  view source on GitHub ↗

Checks whether or not the requested number of threads has a valid value. Parameters ---------- numThreads : int or str The requested number of threads, should either be a strictly positive integer or "max" or None Returns ------- numThreads : int Corrected n

(numThreads)

Source from the content-addressed store, hash-verified

1457
1458
1459def check_number_threads(numThreads):
1460 """Checks whether or not the requested number of threads has a valid value.
1461
1462 Parameters
1463 ----------
1464 numThreads : int or str
1465 The requested number of threads, should either be a strictly positive integer or "max" or None
1466
1467 Returns
1468 -------
1469 numThreads : int
1470 Corrected number of threads
1471 """
1472 if (numThreads is None) or (
1473 isinstance(numThreads, str) and numThreads.lower() == "max"
1474 ):
1475 return -1
1476 if (not isinstance(numThreads, int)) or numThreads < 1:
1477 raise ValueError(
1478 'numThreads should either be "max" or a strictly positive integer'
1479 )
1480 return numThreads
1481
1482
1483def fun_to_numpy(fun, arr, nx, warn=True):

Callers 2

emdFunction · 0.85
emd2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected