This file is indexed.

/usr/lib/python2.7/dist-packages/chaco/tests/hittest_test_case.py is in python-chaco 4.4.1-1.2.

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Test cases for the LinePlot's hittest() function
"""

import unittest
from numpy import arange, array, linalg
from chaco.api import (ArrayDataSource, ArrayPlotData,
                       Plot, LinearMapper, DataRange1D)

class HittestTestCase(unittest.TestCase):
    def make_plot(self, orientation):
        # make some data points
        x = arange(3)
        x = ArrayDataSource(x, sort_order="ascending")
        y = array([2,0,1])

        # Plot the data
        pd = ArrayPlotData(x=x, y=y)

        plot = Plot(pd, orientation=orientation)
        line_plot = plot.plot(("x", "y"))[0]

        # Construct a fake screen space for the plots
        # otherwise would need to actually display the plots to get this
        index_mapper = LinearMapper(data_range=DataRange1D(low=0,high=2),
                                    high_pos=380, low_pos=20)
        value_mapper = LinearMapper(data_range=DataRange1D(low=0,high=2),
                                    high_pos=380, low_pos=20)
        plot.index_mapper = index_mapper
        plot.value_mapper = value_mapper
        line_plot.index_mapper = index_mapper
        line_plot.value_mapper = value_mapper

        return  plot, line_plot

    def test_horizontal(self):
        plot, line_plot = self.make_plot("h")

        self._test_plot(plot, line_plot, point=[0.5,1])
        self._test_plot(plot, line_plot, point=[1,0])

    def test_vertical(self):
        plot, line_plot = self.make_plot("v")

        self._test_plot(plot, line_plot, point=[0.5,1])
        self._test_plot(plot, line_plot, point=[1,0])

    def _test_plot(self, plot, line_plot, point):
        threshold = 2 # In pixels

        screen_pt = plot.map_screen(point).flatten()
        result = line_plot.hittest(screen_pt, threshold=threshold)

        self.assertTrue(result is not None)

        # Check that the result is close by threshold in screenspace
        screen_result = plot.map_screen(result)

        self.assertTrue(linalg.norm(screen_pt - screen_result) < threshold)

        # check the return_distance = True case:
        x, y, d = line_plot.hittest(screen_pt, threshold=threshold,
                                    return_distance=True)
        self.assertEqual(x, result[0])
        self.assertEqual(y, result[1])
        self.assertTrue(d < threshold)

if __name__ == '__main__':
    import nose
    nose.run()