亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? testing.py

?? a very goog book
?? PY
字號:
""" This module attempts to make it easy to create VTK-Pythonunittests.  The module uses unittest for the test interface.  For moredocumentation on what unittests are and how to use them, please readthese:   http://www.python.org/doc/current/lib/module-unittest.html      http://www.diveintopython.org/roman_divein.htmlThis VTK-Python test module supports image based tests with multipleimages per test suite and multiple images per individual test as well.It also prints information appropriate for Dart(http://public.kitware.com/Dart/).This module defines several useful classes and functions to makewriting tests easy.  The most important of these are:class vtkTest:   Subclass this for your tests.  It also has a few useful internal   functions that can be used to do some simple blackbox testing.compareImage(renwin, img_fname, threshold=10):   Compares renwin with image and generates image if it does not   exist.  The threshold determines how closely the images must match.   The function also handles multiple images and finds the best   matching image.getAbsImagePath(img_basename):   Returns the full path to the image given the basic image name.main(cases):   Does the testing given a list of tuples containing test classes and   the starting string of the functions used for testing.interact():    Interacts with the user if necessary.  The behavior of this is    rather trivial and works best when using Tkinter.  It does not do    anything by default and stops to interact with the user when given    the appropriate command line arguments.Examples:  The best way to learn on how to use this module is to look at a few  examples.  The end of this file contains a trivial example.  Please  also look at the following examples:    Rendering/Testing/Python/TestTkRenderWidget.py,    Rendering/Testing/Python/TestTkRenderWindowInteractor.pyCreated: September, 2002Prabhu Ramachandran <prabhu@aero.iitm.ernet.in>"""import sys, os, timeimport unittest, getoptimport vtkimport BlackBox# location of the VTK data files.  Set via command line args or# environment variable.VTK_DATA_ROOT = ""# location of the VTK baseline images.  Set via command line args or# environment variable.VTK_BASELINE_ROOT = ""# Verbosity of the test messages (used by unittest)_VERBOSE = 0# Determines if it is necessary to interact with the user.  If zero# dont interact if 1 interact.  Set via command line args_INTERACT = 0# This will be set to 1 when the image test will not be performed.# This option is used internally by the script and set via command# line arguments._NO_IMAGE = 0class vtkTest(unittest.TestCase):    """A simple default VTK test class that defines a few useful    blackbox tests that can be readily used.  Derive your test cases    from this class and use the following if you'd like to.    Note: Unittest instantiates this class (or your subclass) each    time it tests a method.  So if you do not want that to happen when    generating VTK pipelines you should create the pipeline in the    class definition as done below for _blackbox.    """        _blackbox = BlackBox.Tester(debug=0)    def _testParse(self, obj):        """Does a blackbox test by attempting to parse the class for        its various methods using vtkMethodParser.  This is a useful        test because it gets all the methods of the vtkObject, parses        them and sorts them into different classes of objects."""        self._blackbox.testParse(obj)    def _testGetSet(self, obj):        """Checks the Get/Set method pairs by setting the value using        the current state and making sure that it equals the value it        was originally.  This effectively calls _testParse        internally. """        self._blackbox.testGetSet(obj)    def _testBoolean(self, obj):        """Checks the Boolean methods by setting the value on and off        and making sure that the GetMethod returns the the set value.        This effectively calls _testParse internally. """        self._blackbox.testBoolean(obj)        def interact():    """Interacts with the user if necessary. """    global _INTERACT    if _INTERACT:        raw_input("\nPress Enter/Return to continue with the testing. --> ")def getAbsImagePath(img_basename):        """Returns the full path to the image given the basic image    name."""    global VTK_BASELINE_ROOT    return os.path.join(VTK_BASELINE_ROOT, img_basename)def compareImage(renwin, img_fname, threshold=10):    """Compares renwin's (a vtkRenderWindow) contents with the image    file whose name is given in the second argument.  If the image    file does not exist the image is generated and stored.  If not the    image in the render window is compared to that of the figure.    This function also handles multiple images and finds the best    matching image.  """    global _NO_IMAGE    if _NO_IMAGE:        return        f_base, f_ext = os.path.splitext(img_fname)    w2if = vtk.vtkWindowToImageFilter()    w2if.ReadFrontBufferOff()    w2if.SetInput(renwin)    if not os.path.isfile(img_fname):        # generate the image        pngw = vtk.vtkPNGWriter()        pngw.SetFileName(img_fname)        pngw.SetInput(w2if.GetOutput())        pngw.Write()        return             pngr = vtk.vtkPNGReader()    pngr.SetFileName(img_fname)    idiff = vtk.vtkImageDifference()    idiff.SetInput(w2if.GetOutput())    idiff.SetImage(pngr.GetOutput())    idiff.Update()    del w2if    min_err = idiff.GetThresholdedError()    img_err = min_err    best_img = img_fname    err_index = 0    count = 0    if min_err > threshold:        count = 1        test_failed = 1        err_index = -1        while 1: # keep trying images till we get the best match.            new_fname = f_base + "_%d.png"%count            if not os.path.exists(new_fname):                # no other image exists.                break            # since file exists check if it matches.            pngr.SetFileName(new_fname)            pngr.Update()            idiff.Update()            alt_err = idiff.GetThresholdedError()            if alt_err < threshold:                # matched,                err_index = count                test_failed = 0                min_err = alt_err                img_err = alt_err                best_img = new_fname                break            else:                if alt_err < min_err:                    # image is a better match.                    err_index = count                    min_err = alt_err                    img_err = alt_err                    best_img = new_fname            count = count + 1        # closes while loop.        if test_failed:            _handleFailedImage(idiff, pngr, best_img)            # Print for Dart.            _printDartImageError(img_err, err_index, f_base)            msg = "Failed image test: %f\n"%idiff.GetThresholdedError()            raise AssertionError, msg    # output the image error even if a test passed    _printDartImageSuccess(img_err, err_index)def _printDartImageError(img_err, err_index, img_base):    """Prints the XML data necessary for Dart."""    print "Failed image test with error: %f"%img_err    print "<DartMeasurement name=\"ImageError\" type=\"numeric/double\">",    print "%f </DartMeasurement>"%img_err    if err_index <= 0:        print "<DartMeasurement name=\"BaselineImage\" type=\"text/string\">Standard</DartMeasurement>",    else:        print "<DartMeasurement name=\"BaselineImage\" type=\"numeric/integer\">",        print "%d </DartMeasurement>"%err_index	       print "<DartMeasurementFile name=\"TestImage\" type=\"image/jpeg\">",    print "%s </DartMeasurementFile>"%(img_base + '.test.small.jpg')    print "<DartMeasurementFile name=\"DifferenceImage\" type=\"image/jpeg\">",    print "%s </DartMeasurementFile>"%(img_base + '.diff.small.jpg')    print "<DartMeasurementFile name=\"ValidImage\" type=\"image/jpeg\">",    print "%s </DartMeasurementFile>"%(img_base + '.small.jpg')def _printDartImageSuccess(img_err, err_index):    "Prints XML data for Dart when image test succeeded."    print "<DartMeasurement name=\"ImageError\" type=\"numeric/double\">",    print "%f </DartMeasurement>"%img_err    if err_index <= 0:        print "<DartMeasurement name=\"BaselineImage\" type=\"text/string\">Standard</DartMeasurement>",    else:       print "<DartMeasurement name=\"BaselineImage\" type=\"numeric/integer\">",       print "%d </DartMeasurement>"%err_index    def _handleFailedImage(idiff, pngr, img_fname):    """Writes all the necessary images when an image comparison    failed."""    f_base, f_ext = os.path.splitext(img_fname)    # write out the difference file in full.    pngw = vtk.vtkPNGWriter()    pngw.SetFileName(f_base + ".diff.png")    pngw.SetInput(idiff.GetOutput())    pngw.Write()        # write the difference image scaled and gamma adjusted for the    # dashboard.    sz = pngr.GetOutput().GetDimensions()    if sz[1] <= 250.0:        mag = 1.0    else:        mag = 250.0/sz[1]    shrink = vtk.vtkImageResample()    shrink.SetInput(idiff.GetOutput())    shrink.InterpolateOn()    shrink.SetAxisMagnificationFactor(0, mag)    shrink.SetAxisMagnificationFactor(1, mag)    gamma = vtk.vtkImageShiftScale()    gamma.SetInput(shrink.GetOutput())    gamma.SetShift(0)    gamma.SetScale(10)    jpegw = vtk.vtkJPEGWriter()    jpegw.SetFileName(f_base + ".diff.small.jpg")    jpegw.SetInput(gamma.GetOutput())    jpegw.SetQuality(85)    jpegw.Write()    # write out the image that was generated.    shrink.SetInput(idiff.GetInput())    jpegw.SetInput(shrink.GetOutput())    jpegw.SetFileName(f_base + ".test.small.jpg")    jpegw.Write()    # write out the valid image that matched.    shrink.SetInput(idiff.GetImage())    jpegw.SetInput(shrink.GetOutput())    jpegw.SetFileName(f_base + ".small.jpg")    jpegw.Write()def main(cases):    """ Pass a list of tuples containing test classes and the starting    string of the functions used for testing.    Example:    main ([(vtkTestClass, 'test'), (vtkTestClass1, 'test')])    """    processCmdLine()    timer = vtk.vtkTimerLog()    s_time = timer.GetCPUTime()    s_wall_time = time.time()        # run the tests    result = test(cases)    tot_time = timer.GetCPUTime() - s_time    tot_wall_time = float(time.time() - s_wall_time)    # output measurements for Dart    print "<DartMeasurement name=\"WallTime\" type=\"numeric/double\">",    print " %f </DartMeasurement>"%tot_wall_time    print "<DartMeasurement name=\"CPUTime\" type=\"numeric/double\">",    print " %f </DartMeasurement>"%tot_time        if result.wasSuccessful():        sys.exit(0)    else:        sys.exit(1)def test(cases):    """ Pass a list of tuples containing test classes and the    functions used for testing.    It returns a unittest._TextTestResult object.    Example:      test = test_suite([(vtkTestClass, 'test'),                        (vtkTestClass1, 'test')])    """    # Make the test suites from the arguments.    suites = []    for case in cases:        suites.append(unittest.makeSuite(case[0], case[1]))    test_suite = unittest.TestSuite(suites)    # Now run the tests.    runner = unittest.TextTestRunner(verbosity=_VERBOSE)    result = runner.run(test_suite)    return result        def usage():    msg="""Usage:\nTestScript.py [options]\nWhere options are:\n    -D /path/to/VTKData    --data-dir /path/to/VTKData          Directory containing VTK Data use for tests.  If this option          is not set via the command line the environment variable          VTK_DATA_ROOT is used.  If the environment variable is not          set the value defaults to '../../../../VTKData'.        -B /path/to/valid/image_dir/    --baseline-root /path/to/valid/image_dir/          This is a path to the directory containing the valid images          for comparison.  If this option is not set via the command          line the environment variable VTK_BASELINE_ROOT is used.  If          the environment variable is not set the value defaults to          the same value set for -D (--data-dir).    -v level    --verbose level              Sets the verbosity of the test runner.  Valid values are 0,          1, and 2 in increasing order of verbosity.    -I    --interact          Interacts with the user when chosen.  If this is not chosen          the test will run and exit as soon as it is finished.  When          enabled, the behavior of this is rather trivial and works          best when the test uses Tkinter.    -n    --no-image          Does not do any image comparisons.  This is useful if you          want to run the test and not worry about test images or          image failures etc.    -h    --help                 Prints this message.                 """    return msg    def parseCmdLine():    arguments = sys.argv[1:]    options = "B:D:v:hnI"    long_options = ['baseline-root=', 'data-dir=', 'verbose=', 'help',                    'no-image', 'interact']    try:        opts, args = getopt.getopt(arguments, options, long_options)    except getopt.error, msg:        print usage()        print '-'*70        print msg        sys.exit (1)            return opts, args    def processCmdLine():    opts, args = parseCmdLine()    global VTK_DATA_ROOT, VTK_BASELINE_ROOT    global _VERBOSE, _NO_IMAGE, _INTERACT    # setup defaults    try:        VTK_DATA_ROOT = os.environ['VTK_DATA_ROOT']    except KeyError:        VTK_DATA_ROOT = os.path.normpath("../../../../VTKData")    try:        VTK_BASELINE_ROOT = os.environ['VTK_BASELINE_ROOT']    except KeyError:        pass    for o, a in opts:        if o in ('-D', '--data-dir'):            VTK_DATA_ROOT = os.path.abspath(a)        if o in ('-B', '--baseline-root'):            VTK_BASELINE_ROOT = os.path.abspath(a)        if o in ('-n', '--no-image'):            _NO_IMAGE = 1        if o in ('-I', '--interact'):            _INTERACT = 1        if o in ('-v', '--verbose'):            try:                _VERBOSE = int(a)            except:                msg="Verbosity should be an integer.  0, 1, 2 are valid."                print msg                sys.exit(1)        if o in ('-h', '--help'):                        print usage()            sys.exit()    if not VTK_BASELINE_ROOT: # default value.        VTK_BASELINE_ROOT = VTK_DATA_ROOT####################################################################### A Trivial test case to illustrate how this module works.class SampleTest(vtkTest):    obj = vtk.vtkActor()    def testParse(self):        "Test if class is parseable"        self._testParse(self.obj)    def testGetSet(self):        "Testing Get/Set methods"        self._testGetSet(self.obj)    def testBoolean(self):        "Testing Boolean methods"        self._testBoolean(self.obj)if __name__ == "__main__":    # Test with the above trivial sample test.    main( [ (SampleTest, 'test') ] )

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国成人在线视频| 一区二区三区国产精品| 激情综合色播五月| 欧美一区二区三区在线观看视频 | www一区二区| 国产一区二区三区免费在线观看| 久久视频一区二区| 国产白丝精品91爽爽久久| 亚洲欧美一区二区视频| 欧美性色黄大片| 男女视频一区二区| 久久精品亚洲精品国产欧美kt∨| av一区二区三区黑人| 亚洲专区一二三| 日韩欧美一区中文| 国产精品一区二区果冻传媒| 亚洲视频1区2区| 欧美日韩成人综合| 国产在线精品一区二区不卡了| 日本一区二区免费在线观看视频| 91色porny在线视频| 日日骚欧美日韩| 久久九九99视频| 欧美性感一区二区三区| 韩国欧美国产一区| 艳妇臀荡乳欲伦亚洲一区| 91精品国产高清一区二区三区蜜臀 | aaa欧美日韩| 三级欧美韩日大片在线看| 久久久久久一二三区| 在线视频亚洲一区| 国产精品白丝jk白祙喷水网站| 亚洲黄色小说网站| 久久久www免费人成精品| 欧美系列日韩一区| 不卡一卡二卡三乱码免费网站| 五月综合激情婷婷六月色窝| 国产精品素人一区二区| 欧美一级在线观看| 91蜜桃网址入口| 国产精品一区二区不卡| 日韩**一区毛片| 一区二区三区四区激情| 国产喷白浆一区二区三区| 欧美一区二区成人| 欧美视频一区在线| 成人国产电影网| 精品影院一区二区久久久| 亚洲一区二区三区四区的| 国产片一区二区三区| 日韩欧美中文一区| 欧美三级在线看| 91视频免费观看| 成人免费观看av| 国产乱对白刺激视频不卡| 蜜桃av噜噜一区| 午夜视频一区二区三区| 一区二区三区四区乱视频| 中文字幕中文字幕一区| 国产欧美综合在线| 久久精品亚洲麻豆av一区二区| 日韩欧美色电影| 91精品久久久久久久99蜜桃 | 亚洲欧洲日产国码二区| 久久影院午夜论| 欧美精品一区二区三区一线天视频| 欧美精品一卡二卡| 欧美日韩国产电影| 精品视频在线视频| 欧美性猛片xxxx免费看久爱| 色婷婷国产精品久久包臀| www.日韩av| 91色九色蝌蚪| 欧美天堂亚洲电影院在线播放| 北岛玲一区二区三区四区| 成人免费视频一区| 粉嫩av亚洲一区二区图片| 国产乱对白刺激视频不卡| 国产在线不卡视频| 麻豆精品视频在线观看免费| 亚洲福中文字幕伊人影院| 亚洲午夜久久久久| 亚洲小说春色综合另类电影| 亚洲成人精品影院| 蜜臀久久久99精品久久久久久| 青青草97国产精品免费观看| 美女精品自拍一二三四| 精品一区二区免费| 福利一区福利二区| caoporn国产一区二区| 一本大道综合伊人精品热热| 在线电影一区二区三区| 91精品国产综合久久小美女 | 久久新电视剧免费观看| 久久久久9999亚洲精品| 亚洲欧洲国产专区| 夜夜精品视频一区二区| 日本系列欧美系列| 国产一区日韩二区欧美三区| 成人app网站| 欧美综合久久久| 日韩区在线观看| 亚洲国产精品av| 亚洲成人自拍一区| 裸体一区二区三区| 成人黄色在线看| 欧美三级视频在线观看| 久久欧美一区二区| 国产精品久久久久久亚洲毛片| 亚洲自拍偷拍麻豆| 九九精品视频在线看| 不卡欧美aaaaa| 51精品久久久久久久蜜臀| 久久九九影视网| 亚洲一区二区在线免费看| 麻豆精品一区二区av白丝在线| 波多野结衣中文字幕一区| 欧美日韩不卡在线| 国产精品久久久久久亚洲毛片| 婷婷一区二区三区| 99精品欧美一区| 日韩午夜激情av| 亚洲乱码国产乱码精品精小说| 美女网站在线免费欧美精品| 日本乱人伦一区| 久久久亚洲综合| 日日骚欧美日韩| 97久久超碰国产精品| 精品国产一区二区三区av性色| 亚洲男人都懂的| 国产麻豆一精品一av一免费 | 国产超碰在线一区| 777亚洲妇女| 自拍偷拍亚洲激情| 国产一区二区中文字幕| 欧美日韩三级在线| 国产精品不卡在线| 国产一本一道久久香蕉| 5月丁香婷婷综合| 亚洲免费观看高清完整版在线观看 | 午夜日韩在线观看| 色综合天天狠狠| 国产人伦精品一区二区| 麻豆国产欧美日韩综合精品二区| 在线一区二区三区四区五区| 国产喷白浆一区二区三区| 久久丁香综合五月国产三级网站| 欧美日本韩国一区二区三区视频 | 精品日韩欧美一区二区| 亚洲综合男人的天堂| 不卡的av在线| 中文字幕不卡的av| 成人午夜免费av| 日本一区二区三区四区在线视频| 狠狠狠色丁香婷婷综合激情| 7777精品伊人久久久大香线蕉经典版下载 | 精品夜夜嗨av一区二区三区| 5月丁香婷婷综合| 视频在线观看91| 欧美在线色视频| 亚洲国产视频一区二区| 欧美性三三影院| 天天影视涩香欲综合网| 欧美日韩在线播放一区| 亚洲高清免费观看| 欧美日韩成人高清| 日韩电影在线观看网站| 欧美一区二区美女| 久久99深爱久久99精品| 欧美r级在线观看| 韩国欧美国产1区| 亚洲国产精品高清| 95精品视频在线| 伊人婷婷欧美激情| 欧美日韩极品在线观看一区| 天涯成人国产亚洲精品一区av| 欧美高清hd18日本| 美脚の诱脚舐め脚责91| 2019国产精品| 成人精品免费网站| 亚洲卡通动漫在线| 欧美喷潮久久久xxxxx| 麻豆国产欧美日韩综合精品二区| 精品国产网站在线观看| 成人一级视频在线观看| 亚洲天堂成人网| 在线播放国产精品二区一二区四区| 天天亚洲美女在线视频| 欧美大白屁股肥臀xxxxxx| 国产一区三区三区| 亚洲天堂精品视频| 欧美xxxxx裸体时装秀| 国产成人在线视频网站| 国产精品进线69影院| 在线观看不卡一区| 蜜桃精品在线观看| 国产精品盗摄一区二区三区| 在线视频中文字幕一区二区| 久久99国产精品久久99果冻传媒| 国产肉丝袜一区二区|