MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / _env_optional_float

Function _env_optional_float

deeplabcut/core/debug/_debug_utils.py:42–59  ·  view source on GitHub ↗

Parse an optional float environment variable. Empty strings / unset values return ``default``. Invalid values also fall back to ``default``.

(name: str, default: float | None = None)

Source from the content-addressed store, hash-verified

40
41
42def _env_optional_float(name: str, default: float | None = None) -> float | None:
43 """Parse an optional float environment variable.
44
45 Empty strings / unset values return ``default``.
46 Invalid values also fall back to ``default``.
47 """
48 value = os.getenv(name)
49 if value is None:
50 return default
51
52 value = value.strip()
53 if not value:
54 return default
55
56 try:
57 return float(value)
58 except ValueError:
59 return default
60
61
62def _which(command: str) -> str:

Callers 2

debug_logger.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected