This file is indexed.

/usr/lib/python3/dist-packages/xarray/tests/test_nputils.py is in python3-xarray 0.10.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import numpy as np
from numpy.testing import assert_array_equal

from xarray.core.nputils import (
    NumpyVIndexAdapter, _is_contiguous, rolling_window)


def test_is_contiguous():
    assert _is_contiguous([1])
    assert _is_contiguous([1, 2, 3])
    assert not _is_contiguous([1, 3])


def test_vindex():
    x = np.arange(3 * 4 * 5).reshape((3, 4, 5))
    vindex = NumpyVIndexAdapter(x)

    # getitem
    assert_array_equal(vindex[0], x[0])
    assert_array_equal(vindex[[1, 2], [1, 2]], x[[1, 2], [1, 2]])
    assert vindex[[0, 1], [0, 1], :].shape == (2, 5)
    assert vindex[[0, 1], :, [0, 1]].shape == (2, 4)
    assert vindex[:, [0, 1], [0, 1]].shape == (2, 3)

    # setitem
    vindex[:] = 0
    assert_array_equal(x, np.zeros_like(x))
    # assignment should not raise
    vindex[[0, 1], [0, 1], :] = vindex[[0, 1], [0, 1], :]
    vindex[[0, 1], :, [0, 1]] = vindex[[0, 1], :, [0, 1]]
    vindex[:, [0, 1], [0, 1]] = vindex[:, [0, 1], [0, 1]]


def test_rolling():
    x = np.array([1, 2, 3, 4], dtype=float)

    actual = rolling_window(x, axis=-1, window=3, center=True,
                            fill_value=np.nan)
    expected = np.array([[np.nan, 1, 2],
                         [1, 2, 3],
                         [2, 3, 4],
                         [3, 4, np.nan]], dtype=float)
    assert_array_equal(actual, expected)

    actual = rolling_window(x, axis=-1, window=3, center=False, fill_value=0.0)
    expected = np.array([[0, 0, 1],
                         [0, 1, 2],
                         [1, 2, 3],
                         [2, 3, 4]], dtype=float)
    assert_array_equal(actual, expected)

    x = np.stack([x, x * 1.1])
    actual = rolling_window(x, axis=-1, window=3, center=False, fill_value=0.0)
    expected = np.stack([expected, expected * 1.1], axis=0)
    assert_array_equal(actual, expected)