How to use _getdict method in tox

Best Python code snippet using tox_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...68 heapq.heappush(trees, parent)69 self.tree = trees[0]70 def encoder(self):71 "get decoder instance"72 return HuffEncoder(HuffTree._getdict(self.tree))73 def decoder(self):74 "get decoder instance"75 return HuffDecoder(HuffTree._flatten(self.tree))76 @staticmethod77 def _getdict(huffTree,bits=BitArray()):78 if len(huffTree) == 2:79 yield huffTree[1],bits80 else:81 for ix,h in enumerate(huffTree[1:3]):82 for y in HuffTree._getdict(h,bits+(ix,)):83 yield y84 85 @staticmethod86 def _flatten(huffTree):87 assert len(huffTree) > 288 l = []89 for h in huffTree[1:3]:90 if len(h) == 2:91 l.append(0)92 l.append(h[1])93 else:94 t = HuffTree._flatten(h)95 l.append(len(t))96 l += t...

Full Screen

Full Screen

hash_demo.py

Source:hash_demo.py Github

copy

Full Screen

1#coding=utf-82'''3Created on 2016-7-3145@author: kemin.yu6'''78num = 69factor = 210#table = [None] * num*factor11size = 10012table = [None] * size1314def _print_table():15 print "====== table ======"16 line1 = line2 = ""17 for i in range(size):18 line1 += " %4s ," % i19 if table[i] is None:20 line2 += " %4s ," % ""21 else:22 line2 += " %4s ," % table[i]23 if (i+1) % 20 == 0:24 print line125 print line226 print "--------------------"27 line1 = line2 = ""2829def _getDict(n):30 import random31 result = {}32 for i in range(n):33 k = random.randint(0, n*factor-1)34 result[k] = str(i)35 return result36 37# hash(k, v)38# t: table39# k: int40# v: str4142# 直接定址法 43def hash1(k, v, t):44 t[k] = v45 46def demo1():47 d = _getDict(num)48 for k, v in d.items():49 hash1(k, v, table)50 print sorted(d.items())51 _print_table()52 53def hash1b(k, v, t):54 def linear(a, b):55 return a*k+b56 t[linear(2, 3)] = v57 58def demo1b():59 d = _getDict(num)60 for k, v in d.items():61 hash1b(k, v, table)62 print sorted(d.items())63 _print_table()6465#数字分析法66# 平方取中67def hash2(k, v, t):68 index = k * k / 100 % 10069 t[index] = v70 71def demo2():72 d = {1123: "zero", 2356: "mike", 3921: "john"}73 for k, v in d.items():74 hash2(k, v, table)75 print sorted(d.items())76 _print_table()77 78# 折叠法79def hash2b(k, v, t):80 rest = k;81 sum = 082 while rest > 100:83 sum += rest % 10084 rest = rest / 10085 sum += rest86 sum %= 10087 t[sum] = v88 89def demo2b():90 d = {11234578: "zero", 23212356: "mike", 39215672: "john"}91 for k, v in d.items():92 hash2b(k, v, table)93 print sorted(d.items())94 _print_table()95 96# 除留余数法97def hash2c(k, v, t):98 t[k%100] = v99 100def demo2c():101 d = {11234578: "zero", 23212356: "mike", 39215672: "john"}102 for k, v in d.items():103 hash2c(k, v, table)104 print sorted(d.items())105 _print_table()106 107# 随机数法108def hash2d(k, v, t):109 import random110 t[random.randint(0, 99)] = v111 112def demo2d():113 d = _getDict(num)114 for k, v in d.items():115 hash2d(k, v, table)116 print sorted(d.items())117 _print_table()118119def demo():120 d = _getDict(10)121 print d, len(d)122 print table123 _print_table()124125if __name__ == '__main__':126 demo2d() ...

Full Screen

Full Screen

test_peak_validation.py

Source:test_peak_validation.py Github

copy

Full Screen

1# flake8: noqa2import unittest3import pytest4from lmfit import Model5import raman_fitting6from raman_fitting.deconvolution_models.peak_validation import (7 NotFoundAnyModelsWarning,8 PeakModelValidator,9)10class TestPeakModelValidator(unittest.TestCase):11 def setUp(self):12 self.pmv = PeakModelValidator()13 def test_pmv_valid_models(self):14 self.assertTrue(self.pmv.valid_models)15 def test_pmv_set_debug(self):16 self.assertFalse(self.pmv.debug)17 self.assertTrue(self.pmv._set_debug(**{"debug": True}))18 def test_get_subclasses_from_base(self):19 with self.assertWarns(NotFoundAnyModelsWarning):20 self.pmv.get_subclasses_from_base("")21 with self.assertWarns(NotFoundAnyModelsWarning):22 self.pmv.get_subclasses_from_base(str)23 def test_validation_inspect_models(self):24 _valid = self.pmv.validation_inspect_models([str])25 self.assertTrue(_valid)26 self.assertFalse(_valid[1][0].valid)27 self.assertIn("has no attr", _valid[1][0].message)28 _valid = self.pmv.validation_inspect_models([Model])29 self.assertTrue(_valid)30 self.assertFalse(_valid[1][0].valid)31 self.assertIn("Unable to initialize model", _valid[1][0].message)32 def test_get_cmap_list(self):33 _cmap = self.pmv.get_cmap_list([], cmap_options=())34 self.assertEqual(_cmap, [])35 _cmap = self.pmv.get_cmap_list(36 [1] * 50, cmap_options=(), fallback_color=self.pmv.fallback_color37 )38 self.assertEqual(_cmap, [self.pmv.fallback_color] * 50)39 _cmap = self.pmv.get_cmap_list([1] * 5)40 self.assertEqual(len(_cmap), 5)41 def test___getattr__(self):42 with self.assertRaises(AttributeError):43 self.pmv.fake_attr44 def test___iter__(self):45 _iter = [i for i in self.pmv]46 self.assertIsInstance(_iter, list)47 def test_if_lmfit_models(self):48 if self.pmv.lmfit_models:49 _getdict = self.pmv.get_dict()50 self.assertIsInstance(_getdict, dict)51 _getdict = self.pmv.get_model_dict(self.pmv.lmfit_models)52 self.assertIsInstance(_getdict, dict)53def _debugging():54 self = TestPeakModelValidator()55 peaks = PeakModelValidator()56 self.pmv = peaks57 # all([isinstance(i.peak_model, Model) for i in peaks.lmfit_models])58 # all([isinstance(i.peak_model, Model) for i in peaks.get_dict().values()])59if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful