<commit_before>

import sys
import wx
import wx.lib.newevent
import numpy
import copy
import math
import time
from sans.models.dispersion_models import ArrayDispersion, GaussianDispersion
from DataLoader.data_info import Data1D
from sans.guicomm.events import StatusEvent   
from sans.guiframe.utils import format_number,check_float

## event to post model to fit to fitting plugins
(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()

## event to know the selected fit engine
(FitterTypeEvent, EVT_FITTER_TYPE)   = wx.lib.newevent.NewEvent()
(FitStopEvent, EVT_FIT_STOP)   = wx.lib.newevent.NewEvent()
_BOX_WIDTH = 76
_DATA_BOX_WIDTH = 300
SMEAR_SIZE_L = 0.005
SMEAR_SIZE_H = 0.01

import basepage
from basepage import BasicPage
from basepage import PageInfoEvent
from DataLoader.qsmearing import smear_selection

class FitPage(BasicPage):
    """
        FitPanel class contains fields allowing to display results when
        fitting  a model and one data
        @note: For Fit to be performed the user should check at least one parameter
        on fit Panel window.
  
    """
    
    def __init__(self,parent, page_info):
        BasicPage.__init__(self, parent, page_info)

        """ 
            Initialization of the Panel
        """
        ## fit page does not content npts txtcrtl
        self.npts=None
        ## thread for compute Chisqr
        self.calc_Chisqr=None
        ## default fitengine type
        self.engine_type = None
        ## smear default
        self.smearer = None
        self.current_smearer = None
        self.dxl = None
        self.dxw = None
        self.dx_min = None
        self.dx_max = None
        
        ## draw sizer
        self._fill_datainfo_sizer()
        
        # get smear info from data
        self._get_smear_info()
        
        self._fill_model_sizer( self.sizer1)
        
        self._get_defult_custom_smear()
        
        self._fill_range_sizer() 
        
        if self.data is None:
            self.formfactorbox.Disable()
            self.structurebox.Disable()
        else:
            self.smearer = smear_selection( self.data )
            if self.smearer ==None:
                self.enable_smearer.Disable()
                #self.disable_smearer.Disable()

        self.disp_cb_dict = {}
        ## to update the panel according to the fit engine type selected
        self.Bind(EVT_FITTER_TYPE,self._on_engine_change)
        self.Bind(EVT_FIT_STOP,self._on_fit_complete)
        

    def _on_fit_complete(self, event):
        """
            When fit is complete ,reset the fit button label.
        """
        #self.btFit.SetLabel("Fit")
        #self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId())
        #self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit,id=self.btFit.GetId())
        pass
        
        
    def _on_engine_change(self, event):
        """
            get an event containing the current name of the fit engine type
            @param event: FitterTypeEvent containing  the name of the current engine
        """
        self.engine_type = event.type
        if len(self.parameters)==0:
            self.Layout()
            return
        if event.type =="park":
            self.btFit.SetLabel("Fit")

        for item in self.parameters:
            if event.type =="scipy" :
                item[5].SetValue("")
                item[5].Hide()
                item[6].SetValue("")
                item[6].Hide()
                self.text2_min.Hide()
                self.text2_max.Hide()

            else:
                item[5].Show(True)
                item[6].Show(True)
                self.text2_min.Show(True)
                self.text2_max.Show(True)
        for item in self.fittable_param:
            if item[5]!=None and item[6]!=None and not item in self.orientation_params_disp:
                if event.type =="scipy" and not item in self.orientation_params:
                    item[5].SetValue("")
                    item[5].Hide()
                    item[6].SetValue("")
                    item[6].Hide()
                    self.text2_min.Hide()
                    self.text2_max.Hide()
                    self.text_disp_min.Hide()
                    self.text_disp_max.Hide()
                else:
                    item[5].Show(True)
                    item[6].Show(True)
                    self.text2_min.Show(True)
                    self.text2_max.Show(True)
                    self.text_disp_min.Show(True)
                    self.text_disp_max.Show(True)
            
        for item in self.orientation_params:
            if item[5]!=None and item[6]!=None:
                if event.type =="scipy" or self.data.__class__.__name__ !="Data2D":
                    item[5].SetValue("")
                    item[5].Hide()
                    item[6].SetValue("")
                    item[6].Hide()
                else:
                    item[5].Show(True)
                    item[6].Show(True)
                    
        for item in self.orientation_params_disp:         
            if item[5]!=None and item[6]!=None:
                if event.type =="scipy" or self.data.__class__.__name__ !="Data2D":
                    item[5].SetValue("")
                    item[5].Hide()
                    item[6].SetValue("")
                    item[6].Hide()
                else:
                    item[5].Show(True)
                    item[6].Show(True)
        self.Layout()
        self.Refresh()

    def _fill_range_sizer(self):
        """
            Fill the sizer containing the plotting range
            add  access to npts
        """
        title = "Fitting"
        #smear messages & titles
        smear_message_none  =  "No smearing is selected..."
        smear_message_dqdata  =  "The dQ data is being used for smearing..."
        smear_message_2d  =  "No smearing is supported for 2D model fitting..."
        smear_message_new_ssmear  =  "Please enter only the value of interest to customize smearing..."
        smear_message_new_psmear  =  "Please enter both; the dQ will be generated by interpolation..."
        smear_message_pinhole_min_title = "dQ_min[1/A]:"
        smear_message_pinhole_max_title = "dQ_max[1/A]:"
        smear_message_slit_height_title = "Slit height[1/A]:"
        smear_message_slit_width_title = "Slit width[1/A]:"
        
        self._get_smear_info()

        box_description_range = wx.StaticBox(self, -1,str(title))
        boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL)

        sizer_fit = wx.GridSizer(1, 1,0, 0)
    
        self.btFit = wx.Button(self,wx.NewId(),'Fit', size=(80,23))
        self.btFit.Bind(wx.EVT_BUTTON, self._onFit,id= self.btFit.GetId())
        self.btFit.SetToolTipString("Perform fit.")
      
        
        sizer_fit.Add((5,5),1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)        
        sizer_fit.Add(self.btFit,0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 63) 
        sizer_fit.Layout()
        self.sizer_set_smearer = wx.BoxSizer(wx.VERTICAL)
        sizer_smearer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer_new_smear= wx.BoxSizer(wx.HORIZONTAL)
        self.sizer_set_masking = wx.BoxSizer(wx.HORIZONTAL)
        sizer_chi2 = wx.BoxSizer(wx.VERTICAL)
        smear_set_box= wx.StaticBox(self, -1,'Set Instrumental Smearing')
        sizer_smearer_box = wx.StaticBoxSizer(smear_set_box, wx.HORIZONTAL)
        sizer_smearer_box.SetMinSize((_DATA_BOX_WIDTH,85))
        
        #textcntrl for new resolution
        self.smear_pinhole_max = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-20,20),style=wx.TE_PROCESS_ENTER,
                                            text_enter_callback = self.onPinholeSmear)
        self.smear_pinhole_min = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-20,20),style=wx.TE_PROCESS_ENTER,
                                            text_enter_callback = self.onPinholeSmear)
        self.smear_slit_height= self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-20,20),style=wx.TE_PROCESS_ENTER,
                                            text_enter_callback = self.onSlitSmear)
        self.smear_slit_width = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-20,20),style=wx.TE_PROCESS_ENTER,
                                            text_enter_callback = self.onSlitSmear)
        self.smear_data_left= BGTextCtrl(self, -1, size=(_BOX_WIDTH-20,20), style=0)
        self.smear_data_left.SetValue(str(self.dq_l))
        self.smear_data_right = BGTextCtrl(self, -1, size=(_BOX_WIDTH-20,20), style=0)
        self.smear_data_right.SetValue(str(self.dq_r))

        #set default values
        self.smear_pinhole_max.SetValue(str(self.dx_max))
        self.smear_pinhole_min.SetValue(str(self.dx_min))
        self.smear_slit_height.SetValue(str(self.dxl))
        self.smear_slit_width.SetValue(str(self.dxw))

        #Filling the sizer containing instruments smearing info.
        self.disable_smearer = wx.RadioButton(self, -1, 'None', style=wx.RB_GROUP)
        self.enable_smearer = wx.RadioButton(self, -1, 'Use dQ Data')
        #self.enable_smearer.SetToolTipString("Click to use the loaded dQ data for smearing.")
        self.pinhole_smearer = wx.RadioButton(self, -1, 'Custom Pinhole Smear')
        #self.pinhole_smearer.SetToolTipString("Click to input custom resolution for pinhole smearing.")
        self.slit_smearer = wx.RadioButton(self, -1, 'Custom Slit Smear')
        #self.slit_smearer.SetToolTipString("Click to input custom resolution for slit smearing.")
        self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, id=self.disable_smearer.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, id=self.enable_smearer.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.onPinholeSmear, id=self.pinhole_smearer.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.onSlitSmear, id=self.slit_smearer.GetId())
        self.disable_smearer.SetValue(True)
        
        # add 4 types of smearing to the sizer
        sizer_smearer.Add( self.disable_smearer,0, wx.LEFT, 10)
        sizer_smearer.Add((10,10))
        sizer_smearer.Add( self.enable_smearer)
        sizer_smearer.Add((10,10))
        sizer_smearer.Add( self.pinhole_smearer ) 
        sizer_smearer.Add((10,10))
        sizer_smearer.Add( self.slit_smearer ) 
        sizer_smearer.Add((10,10))       
        
        # static box for chi2
        box_description= wx.StaticBox(self, -1,'Chi2/dof')
        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
        boxsizer1.SetMinSize((70,40))
        
        
        
        # StaticText for chi2 and smear
        self.tcChi    =  wx.StaticText(self, -1, "-", style=wx.ALIGN_LEFT)
        self.smear_description_none    =  wx.StaticText(self, -1, smear_message_none , style=wx.ALIGN_LEFT)
        self.smear_description_dqdata    =  wx.StaticText(self, -1, smear_message_dqdata , style=wx.ALIGN_LEFT)
        self.smear_description_type    =  wx.StaticText(self, -1, "Type:" , style=wx.ALIGN_LEFT)
        self.smear_description_smear_type    =  BGTextCtrl(self, -1, size=(45,20), style=0)
        self.smear_description_smear_type.SetValue(str(self.dq_l))
        self.SetBackgroundColour(self.GetParent().GetBackgroundColour())
        self.smear_description_2d     =  wx.StaticText(self, -1, smear_message_2d  , style=wx.ALIGN_LEFT)
        self.smear_message_new_s = wx.StaticText(self, -1, smear_message_new_ssmear  , style=wx.ALIGN_LEFT)
        self.smear_message_new_p = wx.StaticText(self, -1, smear_message_new_psmear  , style=wx.ALIGN_LEFT)
        self.smear_description_pin_min     =  wx.StaticText(self, -1, smear_message_pinhole_min_title  , style=wx.ALIGN_LEFT)
        self.smear_description_pin_max     =  wx.StaticText(self, -1, smear_message_pinhole_max_title  , style=wx.ALIGN_LEFT)
        self.smear_description_slit_height    =  wx.StaticText(self, -1, smear_message_slit_height_title   , style=wx.ALIGN_LEFT)
        self.smear_description_slit_width    =  wx.StaticText(self, -1, smear_message_slit_width_title   , style=wx.ALIGN_LEFT)
        
        #arrange sizers 
        boxsizer1.Add( self.tcChi )  
        self.sizer_set_smearer.Add(sizer_smearer )
        self.sizer_set_smearer.Add((10,10))
        self.sizer_set_smearer.Add( self.smear_description_none,0, wx.CENTER, 10 ) 
        self.sizer_set_smearer.Add( self.smear_description_dqdata,0, wx.CENTER, 10 )
        self.sizer_set_smearer.Add( self.smear_description_2d,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_description_type,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_description_smear_type,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add((15,-1))
        self.sizer_new_smear.Add( self.smear_description_pin_min,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_description_slit_height,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_pinhole_min,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_slit_height,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_data_left,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add((20,-1))
        self.sizer_new_smear.Add( self.smear_description_pin_max,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_description_slit_width,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_pinhole_max,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_slit_width,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_data_right,0, wx.CENTER, 10 )
           
        self.sizer_set_smearer.Add( self.smear_message_new_s,0, wx.CENTER, 10)
        self.sizer_set_smearer.Add( self.smear_message_new_p,0, wx.CENTER, 10)
        self.sizer_set_smearer.Add((5,2))
        self.sizer_set_smearer.Add( self.sizer_new_smear,0, wx.CENTER, 10 )
        
        # add all to chi2 sizer
        
        sizer_smearer_box.Add(self.sizer_set_smearer) 
        
        sizer_chi2.Add(sizer_smearer_box)
        sizer_chi2.Add((-1,5))
        self.sizer_set_masking.Add((305,-1))
        self.sizer_set_masking.Add(boxsizer1,0, wx.RIGHT, 10)
        sizer_chi2.Add(self.sizer_set_masking )

        #sizer_smearer_box.Add(sizer_chi2)
        # hide all smear messages and textctrl
        self._hide_all_smear_info()
        
        # get smear_selection
        self.current_smearer= smear_selection( self.data )
        print "self.current_smearer",self.current_smearer,self.data.__class__.__name__
        # Show only the relevant smear messages, etc
        if self.current_smearer == None:
            if self.data.__class__.__name__ != 'Data2D':
                self.smear_description_none.Show(True)
                self.enable_smearer.Disable()  
            else:
                print "2dl"
                self.smear_description_2d.Show(True) 
                self.pinhole_smearer.Disable() 
                self.slit_smearer.Disable()   <commit_msg>removed printing<commit_after>

import sys
import wx
import wx.lib.newevent
import numpy
import copy
import math
import time
from sans.models.dispersion_models import ArrayDispersion, GaussianDispersion
from DataLoader.data_info import Data1D
from sans.guicomm.events import StatusEvent   
from sans.guiframe.utils import format_number,check_float

## event to post model to fit to fitting plugins
(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()

## event to know the selected fit engine
(FitterTypeEvent, EVT_FITTER_TYPE)   = wx.lib.newevent.NewEvent()
(FitStopEvent, EVT_FIT_STOP)   = wx.lib.newevent.NewEvent()
_BOX_WIDTH = 76
_DATA_BOX_WIDTH = 300
SMEAR_SIZE_L = 0.005
SMEAR_SIZE_H = 0.01

import basepage
from basepage import BasicPage
from basepage import PageInfoEvent
from DataLoader.qsmearing import smear_selection

class FitPage(BasicPage):
    """
        FitPanel class contains fields allowing to display results when
        fitting  a model and one data
        @note: For Fit to be performed the user should check at least one parameter
        on fit Panel window.
  
    """
    
    def __init__(self,parent, page_info):
        BasicPage.__init__(self, parent, page_info)

        """ 
            Initialization of the Panel
        """
        ## fit page does not content npts txtcrtl
        self.npts=None
        ## thread for compute Chisqr
        self.calc_Chisqr=None
        ## default fitengine type
        self.engine_type = None
        ## smear default
        self.smearer = None
        self.current_smearer = None
        self.dxl = None
        self.dxw = None
        self.dx_min = None
        self.dx_max = None
        
        ## draw sizer
        self._fill_datainfo_sizer()
        
        # get smear info from data
        self._get_smear_info()
        
        self._fill_model_sizer( self.sizer1)
        
        self._get_defult_custom_smear()
        
        self._fill_range_sizer() 
        
        if self.data is None:
            self.formfactorbox.Disable()
            self.structurebox.Disable()
        else:
            self.smearer = smear_selection( self.data )
            if self.smearer ==None:
                self.enable_smearer.Disable()
                #self.disable_smearer.Disable()

        self.disp_cb_dict = {}
        ## to update the panel according to the fit engine type selected
        self.Bind(EVT_FITTER_TYPE,self._on_engine_change)
        self.Bind(EVT_FIT_STOP,self._on_fit_complete)
        

    def _on_fit_complete(self, event):
        """
            When fit is complete ,reset the fit button label.
        """
        #self.btFit.SetLabel("Fit")
        #self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId())
        #self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit,id=self.btFit.GetId())
        pass
        
        
    def _on_engine_change(self, event):
        """
            get an event containing the current name of the fit engine type
            @param event: FitterTypeEvent containing  the name of the current engine
        """
        self.engine_type = event.type
        if len(self.parameters)==0:
            self.Layout()
            return
        if event.type =="park":
            self.btFit.SetLabel("Fit")

        for item in self.parameters:
            if event.type =="scipy" :
                item[5].SetValue("")
                item[5].Hide()
                item[6].SetValue("")
                item[6].Hide()
                self.text2_min.Hide()
                self.text2_max.Hide()

            else:
                item[5].Show(True)
                item[6].Show(True)
                self.text2_min.Show(True)
                self.text2_max.Show(True)
        for item in self.fittable_param:
            if item[5]!=None and item[6]!=None and not item in self.orientation_params_disp:
                if event.type =="scipy" and not item in self.orientation_params:
                    item[5].SetValue("")
                    item[5].Hide()
                    item[6].SetValue("")
                    item[6].Hide()
                    self.text2_min.Hide()
                    self.text2_max.Hide()
                    self.text_disp_min.Hide()
                    self.text_disp_max.Hide()
                else:
                    item[5].Show(True)
                    item[6].Show(True)
                    self.text2_min.Show(True)
                    self.text2_max.Show(True)
                    self.text_disp_min.Show(True)
                    self.text_disp_max.Show(True)
            
        for item in self.orientation_params:
            if item[5]!=None and item[6]!=None:
                if event.type =="scipy" or self.data.__class__.__name__ !="Data2D":
                    item[5].SetValue("")
                    item[5].Hide()
                    item[6].SetValue("")
                    item[6].Hide()
                else:
                    item[5].Show(True)
                    item[6].Show(True)
                    
        for item in self.orientation_params_disp:         
            if item[5]!=None and item[6]!=None:
                if event.type =="scipy" or self.data.__class__.__name__ !="Data2D":
                    item[5].SetValue("")
                    item[5].Hide()
                    item[6].SetValue("")
                    item[6].Hide()
                else:
                    item[5].Show(True)
                    item[6].Show(True)
        self.Layout()
        self.Refresh()

    def _fill_range_sizer(self):
        """
            Fill the sizer containing the plotting range
            add  access to npts
        """
        title = "Fitting"
        #smear messages & titles
        smear_message_none  =  "No smearing is selected..."
        smear_message_dqdata  =  "The dQ data is being used for smearing..."
        smear_message_2d  =  "No smearing is supported for 2D model fitting..."
        smear_message_new_ssmear  =  "Please enter only the value of interest to customize smearing..."
        smear_message_new_psmear  =  "Please enter both; the dQ will be generated by interpolation..."
        smear_message_pinhole_min_title = "dQ_min[1/A]:"
        smear_message_pinhole_max_title = "dQ_max[1/A]:"
        smear_message_slit_height_title = "Slit height[1/A]:"
        smear_message_slit_width_title = "Slit width[1/A]:"
        
        self._get_smear_info()

        box_description_range = wx.StaticBox(self, -1,str(title))
        boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL)

        sizer_fit = wx.GridSizer(1, 1,0, 0)
    
        self.btFit = wx.Button(self,wx.NewId(),'Fit', size=(80,23))
        self.btFit.Bind(wx.EVT_BUTTON, self._onFit,id= self.btFit.GetId())
        self.btFit.SetToolTipString("Perform fit.")
      
        
        sizer_fit.Add((5,5),1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)        
        sizer_fit.Add(self.btFit,0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 63) 
        sizer_fit.Layout()
        self.sizer_set_smearer = wx.BoxSizer(wx.VERTICAL)
        sizer_smearer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer_new_smear= wx.BoxSizer(wx.HORIZONTAL)
        self.sizer_set_masking = wx.BoxSizer(wx.HORIZONTAL)
        sizer_chi2 = wx.BoxSizer(wx.VERTICAL)
        smear_set_box= wx.StaticBox(self, -1,'Set Instrumental Smearing')
        sizer_smearer_box = wx.StaticBoxSizer(smear_set_box, wx.HORIZONTAL)
        sizer_smearer_box.SetMinSize((_DATA_BOX_WIDTH,85))
        
        #textcntrl for new resolution
        self.smear_pinhole_max = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-20,20),style=wx.TE_PROCESS_ENTER,
                                            text_enter_callback = self.onPinholeSmear)
        self.smear_pinhole_min = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-20,20),style=wx.TE_PROCESS_ENTER,
                                            text_enter_callback = self.onPinholeSmear)
        self.smear_slit_height= self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-20,20),style=wx.TE_PROCESS_ENTER,
                                            text_enter_callback = self.onSlitSmear)
        self.smear_slit_width = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-20,20),style=wx.TE_PROCESS_ENTER,
                                            text_enter_callback = self.onSlitSmear)
        self.smear_data_left= BGTextCtrl(self, -1, size=(_BOX_WIDTH-20,20), style=0)
        self.smear_data_left.SetValue(str(self.dq_l))
        self.smear_data_right = BGTextCtrl(self, -1, size=(_BOX_WIDTH-20,20), style=0)
        self.smear_data_right.SetValue(str(self.dq_r))

        #set default values
        self.smear_pinhole_max.SetValue(str(self.dx_max))
        self.smear_pinhole_min.SetValue(str(self.dx_min))
        self.smear_slit_height.SetValue(str(self.dxl))
        self.smear_slit_width.SetValue(str(self.dxw))

        #Filling the sizer containing instruments smearing info.
        self.disable_smearer = wx.RadioButton(self, -1, 'None', style=wx.RB_GROUP)
        self.enable_smearer = wx.RadioButton(self, -1, 'Use dQ Data')
        #self.enable_smearer.SetToolTipString("Click to use the loaded dQ data for smearing.")
        self.pinhole_smearer = wx.RadioButton(self, -1, 'Custom Pinhole Smear')
        #self.pinhole_smearer.SetToolTipString("Click to input custom resolution for pinhole smearing.")
        self.slit_smearer = wx.RadioButton(self, -1, 'Custom Slit Smear')
        #self.slit_smearer.SetToolTipString("Click to input custom resolution for slit smearing.")
        self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, id=self.disable_smearer.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, id=self.enable_smearer.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.onPinholeSmear, id=self.pinhole_smearer.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.onSlitSmear, id=self.slit_smearer.GetId())
        self.disable_smearer.SetValue(True)
        
        # add 4 types of smearing to the sizer
        sizer_smearer.Add( self.disable_smearer,0, wx.LEFT, 10)
        sizer_smearer.Add((10,10))
        sizer_smearer.Add( self.enable_smearer)
        sizer_smearer.Add((10,10))
        sizer_smearer.Add( self.pinhole_smearer ) 
        sizer_smearer.Add((10,10))
        sizer_smearer.Add( self.slit_smearer ) 
        sizer_smearer.Add((10,10))       
        
        # static box for chi2
        box_description= wx.StaticBox(self, -1,'Chi2/dof')
        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
        boxsizer1.SetMinSize((70,40))
        
        
        
        # StaticText for chi2 and smear
        self.tcChi    =  wx.StaticText(self, -1, "-", style=wx.ALIGN_LEFT)
        self.smear_description_none    =  wx.StaticText(self, -1, smear_message_none , style=wx.ALIGN_LEFT)
        self.smear_description_dqdata    =  wx.StaticText(self, -1, smear_message_dqdata , style=wx.ALIGN_LEFT)
        self.smear_description_type    =  wx.StaticText(self, -1, "Type:" , style=wx.ALIGN_LEFT)
        self.smear_description_smear_type    =  BGTextCtrl(self, -1, size=(45,20), style=0)
        self.smear_description_smear_type.SetValue(str(self.dq_l))
        self.SetBackgroundColour(self.GetParent().GetBackgroundColour())
        self.smear_description_2d     =  wx.StaticText(self, -1, smear_message_2d  , style=wx.ALIGN_LEFT)
        self.smear_message_new_s = wx.StaticText(self, -1, smear_message_new_ssmear  , style=wx.ALIGN_LEFT)
        self.smear_message_new_p = wx.StaticText(self, -1, smear_message_new_psmear  , style=wx.ALIGN_LEFT)
        self.smear_description_pin_min     =  wx.StaticText(self, -1, smear_message_pinhole_min_title  , style=wx.ALIGN_LEFT)
        self.smear_description_pin_max     =  wx.StaticText(self, -1, smear_message_pinhole_max_title  , style=wx.ALIGN_LEFT)
        self.smear_description_slit_height    =  wx.StaticText(self, -1, smear_message_slit_height_title   , style=wx.ALIGN_LEFT)
        self.smear_description_slit_width    =  wx.StaticText(self, -1, smear_message_slit_width_title   , style=wx.ALIGN_LEFT)
        
        #arrange sizers 
        boxsizer1.Add( self.tcChi )  
        self.sizer_set_smearer.Add(sizer_smearer )
        self.sizer_set_smearer.Add((10,10))
        self.sizer_set_smearer.Add( self.smear_description_none,0, wx.CENTER, 10 ) 
        self.sizer_set_smearer.Add( self.smear_description_dqdata,0, wx.CENTER, 10 )
        self.sizer_set_smearer.Add( self.smear_description_2d,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_description_type,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_description_smear_type,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add((15,-1))
        self.sizer_new_smear.Add( self.smear_description_pin_min,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_description_slit_height,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_pinhole_min,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_slit_height,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_data_left,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add((20,-1))
        self.sizer_new_smear.Add( self.smear_description_pin_max,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_description_slit_width,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_pinhole_max,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_slit_width,0, wx.CENTER, 10 )
        self.sizer_new_smear.Add( self.smear_data_right,0, wx.CENTER, 10 )
           
        self.sizer_set_smearer.Add( self.smear_message_new_s,0, wx.CENTER, 10)
        self.sizer_set_smearer.Add( self.smear_message_new_p,0, wx.CENTER, 10)
        self.sizer_set_smearer.Add((5,2))
        self.sizer_set_smearer.Add( self.sizer_new_smear,0, wx.CENTER, 10 )
        
        # add all to chi2 sizer
        
        sizer_smearer_box.Add(self.sizer_set_smearer) 
        
        sizer_chi2.Add(sizer_smearer_box)
        sizer_chi2.Add((-1,5))
        self.sizer_set_masking.Add((305,-1))
        self.sizer_set_masking.Add(boxsizer1,0, wx.RIGHT, 10)
        sizer_chi2.Add(self.sizer_set_masking )

        #sizer_smearer_box.Add(sizer_chi2)
        # hide all smear messages and textctrl
        self._hide_all_smear_info()
        
        # get smear_selection
        self.current_smearer= smear_selection( self.data )

        # Show only the relevant smear messages, etc
        if self.current_smearer == None:
            if self.data.__class__.__name__ != 'Data2D':
                self.smear_description_none.Show(True)
                self.enable_smearer.Disable()  
            else:
                print "2dl"
                self.smear_description_2d.Show(True) 
                self.pinhole_smearer.Disable() 
                self.slit_smearer.Disable()   
{'fraction_non_alphanumeric': 0.10226165272036832, 'fraction_numerical': 0.016937191249117856, 'mean_word_length': 2.2593647316538883, 'pattern_counts': {'":': 6, '<': 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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6802507', 'n_tokens_mistral': 10398, 'n_tokens_neox': 9969, 'n_words': 1613}