<commit_before>import wx
import wx.xrc as xrc
import pkg_resources
import numpy
import motmot.imops.imops as imops
import pyglet.gl as gl
import warnings

from pygarrayimage.arrayimage import ArrayInterfaceImage

import motmot.wxglvideo.wxglvideo as vid

class PointDisplayCanvas( vid.DynamicImageCanvas ):
    def __init__(self,*args,**kw):
        super(PointDisplayCanvas, self).__init__(*args,**kw)
        self.extra_points_linesegs = None, None, None, None
        self.red_points = None

    def core_draw(self):
        super(PointDisplayCanvas, self).core_draw()

        points,point_colors, linesegs,lineseg_colors = self.extra_points_linesegs
        gl.glColor4f(0.0,1.0,0.0,1.0) # green point

        if points is not None:
            if point_colors is None:
                point_colors = [ (0,1,0,1) ] * len(points)
            gl.glBegin(gl.GL_POINTS)
            for color_4tuple,pt in zip(point_colors,points):
                gl.glColor4f(*color_4tuple)
                gl.glVertex2f(pt[0],pt[1])
            gl.glEnd()

        if linesegs is not None:
            if lineseg_colors is None:
                lineseg_colors = [ (0,1,0,1) ] * len(linesegs)
            gl.glBegin(gl.GL_LINES)
            for color_4tuple,(x0,y0,x1,y1) in zip(lineseg_colors,linesegs):
                gl.glColor4f(*color_4tuple)
                gl.glVertex2f(x0,y0)
                gl.glVertex2f(x1,y1)
            gl.glEnd()

        if self.red_points is not None:
            gl.glColor4f(1.0,0.0,0.0,1.0)
            gl.glBegin(gl.GL_POINTS)
            for pt in self.red_points:
                gl.glVertex2f(pt[0],pt[1])
            gl.glEnd()

        gl.glColor4f(1.0,1.0,1.0,1.0) # restore white color

    def extra_initgl(self):
        gl.glEnable( gl.GL_POINT_SMOOTH )
        gl.glPointSize(5)

class DynamicImageCanvas(wx.Panel):
    def __init__(self,*args,**kw):
        super(DynamicImageCanvas, self).__init__(*args,**kw)

        self.rotate_180 = False
        self.flip_lr = False

        self.children = {}
        self.children_full_roi_arr = {}
        self.lbrt = {}

        self.box = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(self.box)
        #wx.EVT_IDLE( self, self.OnIdle )

    def _new_child(self,id_val,image,sort_add=False):
        self.Hide()
        try:
            child = PointDisplayCanvas(self,-1)
        finally:
            self.Show()
        child.set_fullcanvas(True)
        pygim = ArrayInterfaceImage( image, allow_copy=False )
        child.new_image( pygim )
        child.set_rotate_180( self.rotate_180 )
        child.set_flip_lr( self.flip_lr )

        self.children[id_val] = child
        self.lbrt[id_val] = ()

        id_vals = self.children.keys()
        id_vals.sort()

        if sort_add:
            # maintain ordering
            self.box = wx.BoxSizer(wx.HORIZONTAL)
            self.SetSizer(self.box)
            for id_val in id_vals:
                child = self.children[id_val]
                self.box.Add( child, 1, wx.EXPAND|wx.ALL, border=1)
        else:<commit_msg>allow passing of arguments to children<commit_after>import wx
import wx.xrc as xrc
import pkg_resources
import numpy
import motmot.imops.imops as imops
import pyglet.gl as gl
import warnings

from pygarrayimage.arrayimage import ArrayInterfaceImage

import motmot.wxglvideo.wxglvideo as vid

class PointDisplayCanvas( vid.DynamicImageCanvas ):
    def __init__(self,*args,**kw):
        super(PointDisplayCanvas, self).__init__(*args,**kw)
        self.extra_points_linesegs = None, None, None, None
        self.red_points = None

    def core_draw(self):
        super(PointDisplayCanvas, self).core_draw()

        points,point_colors, linesegs,lineseg_colors = self.extra_points_linesegs
        gl.glColor4f(0.0,1.0,0.0,1.0) # green point

        if points is not None:
            if point_colors is None:
                point_colors = [ (0,1,0,1) ] * len(points)
            gl.glBegin(gl.GL_POINTS)
            for color_4tuple,pt in zip(point_colors,points):
                gl.glColor4f(*color_4tuple)
                gl.glVertex2f(pt[0],pt[1])
            gl.glEnd()

        if linesegs is not None:
            if lineseg_colors is None:
                lineseg_colors = [ (0,1,0,1) ] * len(linesegs)
            gl.glBegin(gl.GL_LINES)
            for color_4tuple,(x0,y0,x1,y1) in zip(lineseg_colors,linesegs):
                gl.glColor4f(*color_4tuple)
                gl.glVertex2f(x0,y0)
                gl.glVertex2f(x1,y1)
            gl.glEnd()

        if self.red_points is not None:
            gl.glColor4f(1.0,0.0,0.0,1.0)
            gl.glBegin(gl.GL_POINTS)
            for pt in self.red_points:
                gl.glVertex2f(pt[0],pt[1])
            gl.glEnd()

        gl.glColor4f(1.0,1.0,1.0,1.0) # restore white color

    def extra_initgl(self):
        gl.glEnable( gl.GL_POINT_SMOOTH )
        gl.glPointSize(5)

class DynamicImageCanvas(wx.Panel):
    def __init__(self,*args,**kw):
        if 'child_kwargs' in kw:
            self.child_kwargs=kw['child_kwargs']
            del kw['child_kwargs']
        else:
            self.child_kwargs=None
        super(DynamicImageCanvas, self).__init__(*args,**kw)

        self.rotate_180 = False
        self.flip_lr = False

        self.children = {}
        self.children_full_roi_arr = {}
        self.lbrt = {}

        self.box = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(self.box)
        #wx.EVT_IDLE( self, self.OnIdle )

    def _new_child(self,id_val,image,sort_add=False):
        self.Hide()
        try:
            if self.child_kwargs is None:
                kws = {}
            else:
                kws = self.child_kwargs
            child = PointDisplayCanvas(self,-1,**kws)
        finally:
            self.Show()
        child.set_fullcanvas(True)
        pygim = ArrayInterfaceImage( image, allow_copy=False )
        child.new_image( pygim )
        child.set_rotate_180( self.rotate_180 )
        child.set_flip_lr( self.flip_lr )

        self.children[id_val] = child
        self.lbrt[id_val] = ()

        id_vals = self.children.keys()
        id_vals.sort()

        if sort_add:
            # maintain ordering
            self.box = wx.BoxSizer(wx.HORIZONTAL)
            self.SetSizer(self.box)
            for id_val in id_vals:
                child = self.children[id_val]
                self.box.Add( child, 1, wx.EXPAND|wx.ALL, border=1)
        else:
{'fraction_non_alphanumeric': 0.10734200743494424, 'fraction_numerical': 0.02168525402726146, 'mean_word_length': 2.0343045112781954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2536360', 'n_tokens_mistral': 2254, 'n_tokens_neox': 2174, 'n_words': 377}