本文整理汇总了Python中dictset.DictSet类的典型用法代码示例。如果您正苦于以下问题:Python DictSet类的具体用法?Python DictSet怎么用?Python DictSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DictSet类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test1
def test1(self):
L = DictSet(s2d('a1 c5678'))
M=L.copy()
M.add('d','9')
R2 = s2l('a1 c5678 d9')
self.assertEqual(d2l(M),R2)
示例2: test0
def test0(self):
L = DictSet(s2d('a1 c5678'))
R1 = s2l('a1 c5678')
M=L.fromkeys(['a','b'])
self.assertEqual(d2l(L),R1)
self.assertEqual(d2l(M),s2l('a0b0'))
示例3: test99
def test99(self):
"""Make sure that direct calls to update
do not clear previous contents"""
L=DictSet(a='1',b='2')
L.__init__(b='3',c='4')
self.assertEqual(d2l(L),s2l('a1b23c4'))
示例4: test7
def test7(self):
L = DictSet(s2d('a123 b456'))
L.remove('a')
with self.assertRaises(KeyError) as cm:
L.remove('a')
self.assertEqual(str(cm.exception),"'a'")
示例5: test4
def test4(self):
L = DictSet(s2d('a12 c568 d123 e78'))
g=L.unique_combinations()
self.assertEqual(''.join([''.join(v) for v in g]),
'151715181527152815371538161716181627162816371638'
'181718181827182818371838251725182527252825372538'
'261726182627262826372638281728182827282828372838')
示例6: test3
def test3(self):
L = DictSet(s2d('a123 b324 c5 78 d0'))
M = s2d('a1 c56788 e0')
R = s2l('a 23 b324 c 6')
self.assertTrue(isinstance(L.symmetric_difference(M),DictSet))
self.assertEqual(d2l(L.symmetric_difference(M)),R)
self.assertEqual(d2l(L),s2l('a123 b234 c5 78 d0'))
self.assertEqual(d2l(M),s2l('a1 c56788 e0'))
示例7: test2
def test2(self):
L = DictSet(s2d('a1 c567889'))
M = s2d('a123 b324 c5 78')
R = s2l('a1 c5 78 ')
self.assertTrue(isinstance(L.intersection(M),DictSet))
self.assertEqual(d2l(L.intersection(M)),R)
self.assertEqual(d2l(L),s2l('a1 c56789'))
self.assertEqual(d2l(M),s2l('a123 b324 c5 78'))
示例8: test0
def test0(self):
df=DataFrame()
conditionsDict=DictSet({'A':[10,20,40,80],
'B':[100,800],
'rep':range(10)})
for A,B,rep in conditionsDict.unique_combinations():
df.insert({'A':A, 'B':B,'rep':rep})
for d,r in zip(df['A'],_rep_generator([10,20,40,80],4,20)):
self.assertAlmostEqual(d,r)
for d,r in zip(df['B'],_rep_generator([100,800],8,10)):
self.assertAlmostEqual(d,r)
for d,r in zip(df['rep'],_rep_generator(range(10),8,1)):
self.assertAlmostEqual(d,r)
示例9: test
def test(self):
# build the test data
V=[]
for i in range(300):
V.append(normalvariate(100.,10.))
# build some weight vectors to test
W1=[.001 for i in range(300)]
W2=[1. for i in range(300)]
W2[0]=10000.
W3=[-1. for i in range(300)]
W=[W1, W2, W3, None]
# factorially examine the conditions in this DictSet
# see: http://code.google.com/p/dictset/
ds = DictSet({'bins':[1,2,10,171,500],
'range':[(0,100),None],
'density':[True, False],
'weights':[0, 1, 2, 3],
'cumulative':[True, False]})
for b,r,d,w,c in ds.unique_combinations(
['bins','range','density','weights','cumulative']):
print(b,r,d,w,c)
DN, DB = pystaggrelite3.hist(V, b, r, d, W[w], c)
pylab.figure()
RN, RB, patches = pylab.hist(V, b, r, d, W[w], c)
pylab.close()
for d,r in zip(DN, RN):
self.assertAlmostEqual(d, r)
for d,r in zip(DB, RB):
self.assertAlmostEqual(d, r)