MCPcopy Index your code
hub / github.com/msgspec/msgspec / get_bounds_cases

Method get_bounds_cases

tests/unit/test_constraints.py:355–384  ·  view source on GitHub ↗
(self, name, bound)

Source from the content-addressed store, hash-verified

353 msgspec.json.Decoder(typ)
354
355 def get_bounds_cases(self, name, bound):
356 def ceilp1(x):
357 return int(math.ceil(x + 1))
358
359 def floorm1(x):
360 return int(math.floor(x - 1))
361
362 if name.startswith("g"):
363 good_dir = math.inf
364 good_round = ceilp1
365 bad_round = floorm1
366 else:
367 good_dir = -math.inf
368 good_round = floorm1
369 bad_round = ceilp1
370
371 if name.endswith("e"):
372 good = bound
373 bad = math.nextafter(bound, -good_dir)
374 else:
375 good = math.nextafter(bound, good_dir)
376 bad = bound
377 good_cases = [good, good_round(good), float(good_round(good))]
378 bad_cases = [bad, bad_round(bad), float(bad_round(bad))]
379
380 op = ">" if name.startswith("g") else "<"
381 if name.endswith("e"):
382 op += "="
383
384 return good_cases, bad_cases, op
385
386 @pytest.mark.parametrize("name", ["ge", "gt", "le", "lt"])
387 @pytest.mark.parametrize("bound", [1.5, -1.5, 10.0])

Callers 1

test_boundsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected