MCPcopy Index your code
hub / github.com/pydata/xarray / test__infer_interval_breaks

Method test__infer_interval_breaks

xarray/tests/test_plot.py:525–548  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

523 self.pass_in_axis(self.darray.plot)
524
525 def test__infer_interval_breaks(self) -> None:
526 assert_array_equal([-0.5, 0.5, 1.5], _infer_interval_breaks([0, 1]))
527 assert_array_equal(
528 [-0.5, 0.5, 5.0, 9.5, 10.5], _infer_interval_breaks([0, 1, 9, 10])
529 )
530 assert_array_equal(
531 pd.date_range("20000101", periods=4) - np.timedelta64(12, "h"),
532 _infer_interval_breaks(pd.date_range("20000101", periods=3)),
533 )
534
535 # make a bounded 2D array that we will center and re-infer
536 xref, yref = np.meshgrid(np.arange(6), np.arange(5))
537 cx = (xref[1:, 1:] + xref[:-1, :-1]) / 2
538 cy = (yref[1:, 1:] + yref[:-1, :-1]) / 2
539 x = _infer_interval_breaks(cx, axis=1)
540 x = _infer_interval_breaks(x, axis=0)
541 y = _infer_interval_breaks(cy, axis=1)
542 y = _infer_interval_breaks(y, axis=0)
543 np.testing.assert_allclose(xref, x)
544 np.testing.assert_allclose(yref, y)
545
546 # test that ValueError is raised for non-monotonic 1D inputs
547 with pytest.raises(ValueError):
548 _infer_interval_breaks(np.array([0, 2, 1]), check_monotonic=True)
549
550 def test__infer_interval_breaks_logscale(self) -> None:
551 """

Callers

nothing calls this directly

Calls 2

_infer_interval_breaksFunction · 0.85
arangeMethod · 0.80

Tested by

no test coverage detected