Best Python code snippet using yandex-tank
histogram2D.py
Source:histogram2D.py
1# $Id$2from module_base import ModuleBase3from module_mixins import ScriptedConfigModuleMixin4import module_utils5import vtk6import vtkdevide7class histogram2D(ScriptedConfigModuleMixin, ModuleBase):8 """This module takes two inputs and creates a 2D histogram with input 29 vs input 1, i.e. input 1 on x-axis and input 2 on y-axis.10 The inputs have to have identical dimensions.11 """12 def __init__(self, module_manager):13 ModuleBase.__init__(self, module_manager)14 self._histogram = vtkdevide.vtkImageHistogram2D()15 module_utils.setup_vtk_object_progress(self, self._histogram,16 'Calculating 2D histogram')17 self._config.input1Bins = 25618 self._config.input2Bins = 25619 self._config.maxSamplesPerBin = 51220 configList = [21 ('Number of bins for input 1', 'input1Bins', 'base:int', 'text',22 'The full range of input 1 values will be divided into this many '23 'classes.'),24 ('Number of bins for input 2', 'input2Bins', 'base:int', 'text',25 'The full range of input 2 values will be divided into this many '26 'classes.'),27 ('Maximum samples per bin', 'maxSamplesPerBin', 'base:int', 'text',28 'The number of samples per 2D bin/class will be truncated to '29 'this value.')]30 ScriptedConfigModuleMixin.__init__(31 self, configList,32 {'Module (self)' : self,33 'vtkImageHistogram2D' : self._histogram})34 self.sync_module_logic_with_config()35 self._input0 = None36 self._input1 = None37 def close(self):38 self.set_input(0, None)39 self.set_input(1, None)40 ScriptedConfigModuleMixin.close(self)41 ModuleBase.close(self)42 del self._histogram43 def get_input_descriptions(self):44 return ('Image Data 1', 'Imaga Data 2')45 def set_input(self, idx, inputStream):46 def checkTypeAndReturnInput(inputStream):47 """Check type of input. None gets returned. The input is48 returned if it has a valid type. An exception is thrown if49 the input is invalid.50 """51 52 if inputStream == None:53 # disconnect54 return None55 56 else:57 # first check the type58 validType = False59 try:60 if inputStream.IsA('vtkImageData'):61 validType = True62 except AttributeError:63 # validType is already False64 pass65 if not validType:66 raise TypeError, 'Input has to be of type vtkImageData.'67 else:68 return inputStream69 70 71 if idx == 0:72 self._input0 = checkTypeAndReturnInput(inputStream)73 self._histogram.SetInput1(self._input0)74 elif idx == 1:75 self._input1 = checkTypeAndReturnInput(inputStream)76 self._histogram.SetInput2(self._input1)77 def get_output_descriptions(self):78 return (self._histogram.GetOutput().GetClassName(),)79 def get_output(self, idx):80 #raise NotImplementedError81 return self._histogram.GetOutput()82 def execute_module(self):83 self._histogram.Update()84 def logic_to_config(self):85 self._config.input1Bins = self._histogram.GetInput1Bins()86 self._config.input2Bins = self._histogram.GetInput2Bins()87 self._config.maxSamplesPerBin = self._histogram.GetMaxSamplesPerBin()88 89 def config_to_logic(self):90 self._histogram.SetInput1Bins(self._config.input1Bins)91 self._histogram.SetInput2Bins(self._config.input2Bins)92 self._histogram.SetMaxSamplesPerBin(self._config.maxSamplesPerBin)93 # ----------------------------------------------------------------------94 # non-API methods start here -------------------------------------------95 # ----------------------------------------------------------------------96 97 def _histogramSourceExecute(self):98 """Execute callback for the vtkProgrammableSource histogram instance.99 """...
GL.EXT.histogram.011f.py
Source:GL.EXT.histogram.011f.py
1# This file was created automatically by SWIG.2# Don't modify this file, modify the SWIG interface instead.3# This file is compatible with both classic and new-style classes.4import _histogram5def _swig_setattr_nondynamic(self,class_type,name,value,static=1):6 if (name == "this"):7 if isinstance(value, class_type):8 self.__dict__[name] = value.this9 if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown10 del value.thisown11 return12 method = class_type.__swig_setmethods__.get(name,None)13 if method: return method(self,value)14 if (not static) or hasattr(self,name) or (name == "thisown"):15 self.__dict__[name] = value16 else:17 raise AttributeError("You cannot add attributes to %s" % self)18def _swig_setattr(self,class_type,name,value):19 return _swig_setattr_nondynamic(self,class_type,name,value,0)20def _swig_getattr(self,class_type,name):21 method = class_type.__swig_getmethods__.get(name,None)22 if method: return method(self)23 raise AttributeError,name24import types25try:26 _object = types.ObjectType27 _newclass = 128except AttributeError:29 class _object : pass30 _newclass = 031del types32__version__ = _histogram.__version__33__date__ = _histogram.__date__34__api_version__ = _histogram.__api_version__35__author__ = _histogram.__author__36__doc__ = _histogram.__doc__37glResetHistogramEXT = _histogram.glResetHistogramEXT38glInitHistogramEXT = _histogram.glInitHistogramEXT39__info = _histogram.__info40GL_HISTOGRAM_EXT = _histogram.GL_HISTOGRAM_EXT41GL_PROXY_HISTOGRAM_EXT = _histogram.GL_PROXY_HISTOGRAM_EXT42GL_HISTOGRAM_WIDTH_EXT = _histogram.GL_HISTOGRAM_WIDTH_EXT43GL_HISTOGRAM_FORMAT_EXT = _histogram.GL_HISTOGRAM_FORMAT_EXT44GL_HISTOGRAM_RED_SIZE_EXT = _histogram.GL_HISTOGRAM_RED_SIZE_EXT45GL_HISTOGRAM_GREEN_SIZE_EXT = _histogram.GL_HISTOGRAM_GREEN_SIZE_EXT46GL_HISTOGRAM_BLUE_SIZE_EXT = _histogram.GL_HISTOGRAM_BLUE_SIZE_EXT47GL_HISTOGRAM_ALPHA_SIZE_EXT = _histogram.GL_HISTOGRAM_ALPHA_SIZE_EXT48GL_HISTOGRAM_LUMINANCE_SIZE_EXT = _histogram.GL_HISTOGRAM_LUMINANCE_SIZE_EXT49GL_HISTOGRAM_SINK_EXT = _histogram.GL_HISTOGRAM_SINK_EXT50GL_MINMAX_EXT = _histogram.GL_MINMAX_EXT51GL_MINMAX_FORMAT_EXT = _histogram.GL_MINMAX_FORMAT_EXT...
debugging_vars.py
Source:debugging_vars.py
1import numpy as np2DEBUGGING_VARS = {"FIND_NEIGHBOUR_DIST": False}3def extract_histogram(spatial_ops, normalize=True):4 out = []5 for idx, nf in enumerate(spatial_ops["neighbour_finder"]):6 dist_meters = nf.dist_meters7 temp = {}8 for dist_meter in dist_meters:9 hist = dist_meter.histogram.copy()10 if normalize:11 hist /= hist.sum()12 temp[str(dist_meter.radius)] = hist.tolist()13 dist_meter.reset()14 out.append(temp)15 return out16class DistributionNeighbour(object):17 def __init__(self, radius, bins=1000):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!