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

Function test_val_in_range

lib/matplotlib/tests/test_scale.py:420–464  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

418
419
420def test_val_in_range():
421
422 test_cases = [
423 # LinearScale: Always True (even for Inf/NaN)
424 ('linear', 10.0, True),
425 ('linear', -10.0, True),
426 ('linear', 0.0, True),
427 ('linear', np.inf, False),
428 ('linear', np.nan, False),
429
430 # LogScale: Only positive values (> 0)
431 ('log', 1.0, True),
432 ('log', 1e-300, True),
433 ('log', 0.0, False),
434 ('log', -1.0, False),
435 ('log', np.inf, False),
436 ('log', np.nan, False),
437
438 # LogitScale: Strictly between 0 and 1
439 ('logit', 0.5, True),
440 ('logit', 0.0, False),
441 ('logit', 1.0, False),
442 ('logit', -0.1, False),
443 ('logit', 1.1, False),
444 ('logit', np.inf, False),
445 ('logit', np.nan, False),
446
447 # SymmetricalLogScale: Valid for all real numbers
448 # Uses ScaleBase fallback. NaN returns False since NaN != NaN
449 ('symlog', 10.0, True),
450 ('symlog', -10.0, True),
451 ('symlog', 0.0, True),
452 ('symlog', np.inf, False),
453 ('symlog', np.nan, False),
454 ]
455
456 for name, val, expected in test_cases:
457 scale_cls = mscale._scale_mapping[name]
458 s = scale_cls(axis=None)
459
460 result = s.val_in_range(val)
461 assert result is expected, (
462 f"Failed {name}.val_in_range({val})."
463 f"Expected {expected}, got {result}"
464 )
465
466
467def test_val_in_range_base_fallback():

Callers

nothing calls this directly

Calls 1

val_in_rangeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…