This file is indexed.

/usr/lib/python3/dist-packages/pyregion/region_to_filter.py is in python3-pyregion 1.1.4-2build1.

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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import numpy as np
import pyregion._region_filter as region_filter
import warnings

def as_region_filter(shape_list, origin=1):
    """
    Often, the regions files implicitly assume the lower-left corner
    of the image as a coordinate (1,1). However, the python convetion
    is that the array index starts from 0. By default (origin = 1),
    coordinates of the returned mpl artists have coordinate shifted by
    (1, 1). If you do not want this shift, use origin=0.
    """

    filter_list = []
    for shape in shape_list:

        if shape.name == "composite":
            continue

        if shape.name == "polygon":
            xy = np.array(shape.coord_list) - origin
            f = region_filter.Polygon(xy[::2], xy[1::2])

        elif shape.name == "rotbox" or shape.name == "box":
            xc, yc, w, h, rot = shape.coord_list
            # -1 for change origin to 0,0
            xc, yc = xc-origin, yc-origin

            f = region_filter.Rotated(region_filter.Box(xc, yc, w, h),
                                      rot, xc, yc)

        elif shape.name == "ellipse":
            xc, yc  = shape.coord_list[:2]
            # -1 for change origin to 0,0
            xc, yc = xc-origin, yc-origin
            angle = shape.coord_list[-1]

            maj_list, min_list = shape.coord_list[2:-1:2], shape.coord_list[3:-1:2]

            if len(maj_list) > 1:
                w1, h1 = max(maj_list), max(min_list)
                w2, h2 = min(maj_list), min(min_list)

                f1 = region_filter.Ellipse(xc, yc, w1, h1) \
                    & ~region_filter.Ellipse(xc, yc, w2, h2)
                f = region_filter.Rotated(f1, angle, xc, yc)
            else:
                w, h = maj_list[0], min_list[0]
                f = region_filter.Rotated(region_filter.Ellipse(xc, yc, w, h),
                                          angle, xc, yc)



        elif shape.name == "annulus":
            xc, yc  = shape.coord_list[:2]
            # -1 for change origin to 0,0
            xc, yc = xc-origin, yc-origin
            r_list = shape.coord_list[2:]

            r1 = max(r_list)
            r2 = min(r_list)

            f = region_filter.Circle(xc, yc, r1) & ~region_filter.Circle(xc, yc, r2)

        elif shape.name == "circle":
            xc, yc, r = shape.coord_list
            # -1 for change origin to 0,0
            xc, yc = xc-origin, yc-origin

            f = region_filter.Circle(xc, yc, r)

        elif shape.name == "panda":
            xc, yc, a1, a2, an, r1, r2, rn = shape.coord_list
            # -1 for change origin to 0,0
            xc, yc = xc-origin, yc-origin

            f1 = region_filter.Circle(xc, yc, r2) & ~region_filter.Circle(xc, yc, r1)
            f = f1 & region_filter.AngleRange(xc, yc, a1, a2)

        elif shape.name == "pie":
            xc, yc, r1, r2, a1, a2 = shape.coord_list
            # -1 for change origin to 0,0
            xc, yc = xc-origin, yc-origin

            f1 = region_filter.Circle(xc, yc, r2) & ~region_filter.Circle(xc, yc, r1)
            f = f1 & region_filter.AngleRange(xc, yc, a1, a2)

        elif shape.name == "epanda":
            xc, yc, a1, a2, an, r11, r12, r21, r22, rn, angle = shape.coord_list
            # -1 for change origin to 0,0
            xc, yc = xc-origin, yc-origin

            f1 = region_filter.Ellipse(xc, yc, r21, r22) & ~region_filter.Ellipse(xc, yc, r11, r12)
            f2 = f1 & region_filter.AngleRange(xc, yc, a1, a2)
            f = region_filter.Rotated(f2, angle, xc, yc)
            #f = f2 & region_filter.AngleRange(xc, yc, a1, a2)

        elif shape.name == "bpanda":
            xc, yc, a1, a2, an, r11, r12, r21, r22, rn, angle = shape.coord_list
            # -1 for change origin to 0,0
            xc, yc = xc-origin, yc-origin

            f1 = region_filter.Box(xc, yc, r21, r22) & ~region_filter.Box(xc, yc, r11, r12)
            f2 = f1 & region_filter.AngleRange(xc, yc, a1, a2)
            f = region_filter.Rotated(f2, angle, xc, yc)
            #f = f2 & region_filter.AngleRange(xc, yc, a1, a2)

        else:
            warnings.warn("'as_region_filter' does not know how to convert '%s' to a region filter." % (shape.name,))
            continue

        if shape.exclude:
            filter_list = [region_filter.RegionOrList(*filter_list) & ~f]
        else:
            filter_list.append(f)


    return region_filter.RegionOrList(*filter_list)