<commit_before>from pmst.geometry import Point, Ray, Plane
import numpy as np

class Detector(Plane):
    """Plane detector with square pixels"""
    
    def __init__(self, p1, p2, p3, xnpix, ynpix):
        Plane.__init__(self, p1, p2, p3)
        self.xextent = 2*(p2 - p1).length
        self.yextent = 2*(p3 - p1).length
        self.xnpix = xnpix
        self.ynpix = ynpix
        self.pc = p1
        self.px = p2
        self.py = p3

        # Make this a property?
        self.pixel_values = np.zeros((xnpix, ynpix))

    def intersection(self, o):
        i = Plane.intersection(self, o)

        # TODO: Find which pixel to increment
        if i != []:
            i0 = (i[0] - self.pc)
            x0 = (self.px - self.pc).normalize()
            y0 = (self.py - self.pc).normalize()
            xlen = i0.dot(x0)
            ylen = i0.dot(y0)

            # TODO: Clarify xextent (half or full width)
            if abs(xlen) > self.xextent/2 or abs(ylen) > self.yextent/2:
                pass
            else:
                xfrac = xlen/self.xextent
                yfrac = ylen/self.yextent
                xind = np.round((self.xnpix - 1)*xfrac + (self.xnpix/2))
                yind = np.round((self.ynpix - 1)*yfrac + (self.ynpix/2))
                self.pixel_values[xind, yind] += 1
            
        return i
        <commit_msg>Index with integer to avoid deprecation<commit_after>from pmst.geometry import Point, Ray, Plane
import numpy as np

class Detector(Plane):
    """Plane detector with square pixels"""
    
    def __init__(self, p1, p2, p3, xnpix, ynpix):
        Plane.__init__(self, p1, p2, p3)
        self.xextent = 2*(p2 - p1).length
        self.yextent = 2*(p3 - p1).length
        self.xnpix = xnpix
        self.ynpix = ynpix
        self.pc = p1
        self.px = p2
        self.py = p3

        # Make this a property?
        self.pixel_values = np.zeros((xnpix, ynpix))

    def intersection(self, o):
        i = Plane.intersection(self, o)

        # TODO: Find which pixel to increment
        if i != []:
            i0 = (i[0] - self.pc)
            x0 = (self.px - self.pc).normalize()
            y0 = (self.py - self.pc).normalize()
            xlen = i0.dot(x0)
            ylen = i0.dot(y0)

            # TODO: Clarify xextent (half or full width)
            if abs(xlen) > self.xextent/2 or abs(ylen) > self.yextent/2:
                pass
            else:
                xfrac = xlen/self.xextent
                yfrac = ylen/self.yextent
                xind = np.round((self.xnpix - 1)*xfrac + (self.xnpix/2))
                yind = np.round((self.ynpix - 1)*yfrac + (self.ynpix/2))
                self.pixel_values[int(xind), int(yind)] += 1
            
        return i
        
{'fraction_non_alphanumeric': 0.12327773749093546, 'fraction_numerical': 0.021754894851341553, 'mean_word_length': 1.5452029520295203, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '61114', 'n_tokens_mistral': 986, 'n_tokens_neox': 954, 'n_words': 225}