Пример #1
0
def test_repr_of_dataarray(dataarray):
    formatted = fh.array_repr(dataarray)
    assert "dim_0" in formatted
    # has an expandable data section
    assert formatted.count("class='xr-array-in' type='checkbox' >") == 1
    # coords and attrs don't have an items so they'll be be disabled and collapsed
    assert (formatted.count(
        "class='xr-section-summary-in' type='checkbox' disabled >") == 2)
Пример #2
0
def test_repr_of_dataarray(dataarray) -> None:
    formatted = fh.array_repr(dataarray)
    assert "dim_0" in formatted
    # has an expanded data section
    assert formatted.count("class='xr-array-in' type='checkbox' checked>") == 1
    # coords and attrs don't have an items so they'll be be disabled and collapsed
    assert (formatted.count(
        "class='xr-section-summary-in' type='checkbox' disabled >") == 2)

    with xr.set_options(display_expand_data=False):
        formatted = fh.array_repr(dataarray)
        assert "dim_0" in formatted
        # has an expanded data section
        assert formatted.count(
            "class='xr-array-in' type='checkbox' checked>") == 0
        # coords and attrs don't have an items so they'll be be disabled and collapsed
        assert (formatted.count(
            "class='xr-section-summary-in' type='checkbox' disabled >") == 2)
Пример #3
0
def test_repr_of_nonstr_dataarray(dataarray) -> None:
    da = dataarray.rename(dim_0=15)
    da.attrs[1] = "value"
    formatted = fh.array_repr(da)
    assert "<dt><span>1 :</span></dt><dd>value</dd>" in formatted
    assert "<li><span>15</span>: 4</li>" in formatted