<commit_before># -*- coding: utf-8 -*-
#
# Copyright © 2014-2015 <NAME>
# Licensed under the terms of the MIT License
# (see qwt/LICENSE for details)

USE_THREADS = False  # QtConcurrent is not supported by PyQt

from qwt.qt.QtGui import QPolygon, QPolygonF, QImage, QPainter
from qwt.qt.QtCore import QThread, Qt, QPoint, QPointF, QRectF

from qwt.pixel_matrix import QwtPixelMatrix

import numpy as np


class QwtDotsCommand(object):
    def __init__(self):
        self.series = None
        self.from_ = None
        self.to = None
        self.rgb = None

def qwtRenderDots(xMap, yMap, command, pos, image):
    rgb = command.rgb
    bits = image.bits()
    w = image.width()
    h = image.height()
    x0 = pos.x()
    y0 = pos.y()
    for i in range(command.from_, command.to+1):
        sample = command.series.sample(i)
        x = int(xMap.transform(sample.x())+0.5)-x0
        y = int(yMap.transform(sample.y())+0.5)-y0
        if x >= 0 and x < w and y >= 0 and y < h:
            bits[y*w+x] = rgb


def qwtToPoints(boundingRect, xMap, yMap, series, from_, to, round_,
                Polygon):
    Point = QPointF if isinstance(Polygon, QPolygonF) else QPoint
    points = []
    if boundingRect.isValid():
        for i in range(from_, to+1):
            sample = series.sample(i)
            x = xMap.transform(sample.x())
            y = yMap.transform(sample.y())
            if boundingRect.contains(x, y):
                points.append(Point(round_(x), round_(y)))
    else:
        for i in range(from_, to+1):
            sample = series.sample(i)
            x = xMap.transform(sample.x())
            y = yMap.transform(sample.y())
            points.append(Point(round_(x), round_(y)))
    return Polygon(list(set(points)))

def qwtToPointsI(boundingRect, xMap, yMap, series, from_, to):
    return qwtToPoints(boundingRect, xMap, yMap, series, from_, to, round,
                       QPolygon)

def qwtToPointsF(boundingRect, xMap, yMap, series, from_, to, round_):
    return qwtToPoints(boundingRect, xMap, yMap, series, from_, to, round_,
                       QPolygonF)


def qwtToPolylineFiltered(xMap, yMap, series, from_, to, round_,
                          Polygon, Point):
    polyline = Polygon(to-from_+1)
    pointer = polyline.data()
    dtype = np.float if Polygon is QPolygonF else np.int
    pointer.setsize(2*polyline.size()*np.finfo(dtype).dtype.itemsize)
    memory = np.frombuffer(pointer, dtype)
    memory[from_*2:to*2+1:2] =\
                        np.round(xMap.transform(series.xData()))[from_:to+1]
    memory[from_*2+1:to*2+2:2] =\
                        np.round(yMap.transform(series.yData()))[from_:to+1]
    return polyline    
#    points = polyline.data()
#    sample0 = series.sample(from_)
#    points[0].setX(round_(xMap.transform(sample0.x())))
#    points[0].setY(round_(yMap.transform(sample0.y())))
#    pos = 0
#    for i in range(from_, to+1):
#        sample = series.sample(i)
#        p = Point(round_(xMap.transform(sample.x())),
#                  round_(yMap.transform(sample.y())))
#        if points[pos] != p:
#            pos += 1
#            points[pos] = p
#    polyline.resize(pos+1)
#    return polyline

def qwtToPolylineFilteredI(xMap, yMap, series, from_, to):
    return qwtToPolylineFiltered(xMap, yMap, series, from_, to, round,
                                 QPolygon, QPoint)

def qwtToPolylineFilteredF(xMap, yMap, series, from_, to, round_):
    return qwtToPolylineFiltered(xMap, yMap, series, from_, to, round_,
                                 QPolygonF, QPointF)


def qwtToPointsFiltered(boundingRect, xMap, yMap, series, from_, to,
                        Polygon):
    Point = QPointF if isinstance(Polygon, QPolygonF) else QPoint
    points = []
    for i in range(from_, to+1):
        sample = series.sample(i)
        x = int(round(xMap.transform(sample.x())))
        y = int(round(yMap.transform(sample.y())))
        points.append(Point(x, y))
    return Polygon(list(set(points)))

def qwtToPointsFilteredI(boundingRect, xMap, yMap, series, from_, to):
    return qwtToPointsFiltered(boundingRect, xMap, yMap, series, from_, to,
                               QPolygon)

def qwtToPointsFilteredF(boundingRect, xMap, yMap, series, from_, to):
    return qwtToPointsFiltered(boundingRect, xMap, yMap, series, from_, to,
                               QPolygonF)


class QwtPointMapper_PrivateData(object):
    def __init__(self):
        self.boundingRect = None
        self.flags = 0


class QwtPointMapper(object):
    RoundPoints = 0x01
    WeedOutPoints = 0x02
    
    def __init__(self):<commit_msg>Fixed: QwtPixelMatrix was not used in qwt/point_mapper<commit_after># -*- coding: utf-8 -*-
#
# Copyright © 2014-2015 <NAME>
# Licensed under the terms of the MIT License
# (see qwt/LICENSE for details)

USE_THREADS = False  # QtConcurrent is not supported by PyQt

from qwt.qt.QtGui import QPolygon, QPolygonF, QImage, QPainter
from qwt.qt.QtCore import QThread, Qt, QPoint, QPointF, QRectF

from qwt.pixel_matrix import QwtPixelMatrix

import numpy as np


class QwtDotsCommand(object):
    def __init__(self):
        self.series = None
        self.from_ = None
        self.to = None
        self.rgb = None

def qwtRenderDots(xMap, yMap, command, pos, image):
    rgb = command.rgb
    bits = image.bits()
    w = image.width()
    h = image.height()
    x0 = pos.x()
    y0 = pos.y()
    for i in range(command.from_, command.to+1):
        sample = command.series.sample(i)
        x = int(xMap.transform(sample.x())+0.5)-x0
        y = int(yMap.transform(sample.y())+0.5)-y0
        if x >= 0 and x < w and y >= 0 and y < h:
            bits[y*w+x] = rgb


def qwtToPoints(boundingRect, xMap, yMap, series, from_, to, round_,
                Polygon):
    Point = QPointF if isinstance(Polygon, QPolygonF) else QPoint
    points = []
    if boundingRect.isValid():
        for i in range(from_, to+1):
            sample = series.sample(i)
            x = xMap.transform(sample.x())
            y = yMap.transform(sample.y())
            if boundingRect.contains(x, y):
                points.append(Point(round_(x), round_(y)))
    else:
        for i in range(from_, to+1):
            sample = series.sample(i)
            x = xMap.transform(sample.x())
            y = yMap.transform(sample.y())
            points.append(Point(round_(x), round_(y)))
    return Polygon(list(set(points)))

def qwtToPointsI(boundingRect, xMap, yMap, series, from_, to):
    return qwtToPoints(boundingRect, xMap, yMap, series, from_, to, round,
                       QPolygon)

def qwtToPointsF(boundingRect, xMap, yMap, series, from_, to, round_):
    return qwtToPoints(boundingRect, xMap, yMap, series, from_, to, round_,
                       QPolygonF)


def qwtToPolylineFiltered(xMap, yMap, series, from_, to, round_,
                          Polygon, Point):
    polyline = Polygon(to-from_+1)
    pointer = polyline.data()
    dtype = np.float if Polygon is QPolygonF else np.int
    pointer.setsize(2*polyline.size()*np.finfo(dtype).dtype.itemsize)
    memory = np.frombuffer(pointer, dtype)
    memory[from_*2:to*2+1:2] =\
                        np.round(xMap.transform(series.xData()))[from_:to+1]
    memory[from_*2+1:to*2+2:2] =\
                        np.round(yMap.transform(series.yData()))[from_:to+1]
    return polyline    
#    points = polyline.data()
#    sample0 = series.sample(from_)
#    points[0].setX(round_(xMap.transform(sample0.x())))
#    points[0].setY(round_(yMap.transform(sample0.y())))
#    pos = 0
#    for i in range(from_, to+1):
#        sample = series.sample(i)
#        p = Point(round_(xMap.transform(sample.x())),
#                  round_(yMap.transform(sample.y())))
#        if points[pos] != p:
#            pos += 1
#            points[pos] = p
#    polyline.resize(pos+1)
#    return polyline

def qwtToPolylineFilteredI(xMap, yMap, series, from_, to):
    return qwtToPolylineFiltered(xMap, yMap, series, from_, to, round,
                                 QPolygon, QPoint)

def qwtToPolylineFilteredF(xMap, yMap, series, from_, to, round_):
    return qwtToPolylineFiltered(xMap, yMap, series, from_, to, round_,
                                 QPolygonF, QPointF)


def qwtToPointsFiltered(boundingRect, xMap, yMap, series, from_, to,
                        Polygon):
    Point = QPointF if isinstance(Polygon, QPolygonF) else QPoint
    if isinstance(boundingRect, QRectF):
        pixelMatrix = QwtPixelMatrix(boundingRect.toAlignedRect())
    else:
        pixelMatrix = QwtPixelMatrix(boundingRect)
    points = []
    for i in range(from_, to+1):
        sample = series.sample(i)
        x = int(round(xMap.transform(sample.x())))
        y = int(round(yMap.transform(sample.y())))
        if pixelMatrix.testAndSetPixel(x, y, True) == False:
            points.append(Point(x, y))
    return Polygon(list(set(points)))

def qwtToPointsFilteredI(boundingRect, xMap, yMap, series, from_, to):
    return qwtToPointsFiltered(boundingRect, xMap, yMap, series, from_, to,
                               QPolygon)

def qwtToPointsFilteredF(boundingRect, xMap, yMap, series, from_, to):
    return qwtToPointsFiltered(boundingRect, xMap, yMap, series, from_, to,
                               QPolygonF)


class QwtPointMapper_PrivateData(object):
    def __init__(self):
        self.boundingRect = None
        self.flags = 0


class QwtPointMapper(object):
    RoundPoints = 0x01
    WeedOutPoints = 0x02
    
    def __init__(self):
{'fraction_non_alphanumeric': 0.12461910265840076, 'fraction_numerical': 0.010927813386571398, 'mean_word_length': 2.540922619047619, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7349023', 'n_tokens_mistral': 3243, 'n_tokens_neox': 3176, 'n_words': 730}