Did I find the right examples for you? yes no      Crawl my project      Python Jobs

# BTrees.IIBTree.weightedIntersection

All Samples(21)  |  Call(11)  |  Derive(0)  |  Import(10)
```weightedIntersection(o1, o2 [, w1, w2]) -- compute the intersection of o1 and o2

w1 and w2 are weights.
```

```
from BTrees.IIBTree import IIBucket
from BTrees.IIBTree import weightedIntersection
from BTrees.IIBTree import weightedUnion

```
```    L.sort(lambda x, y: cmp(len(x), len(y)))
(x, wx), (y, wy) = L[:2]
dummy, result = weightedIntersection(x, y, wx, wy)
for x, wx in L[2:]:
dummy, result = weightedIntersection(result, x, 1, wx)
```

```from BTrees.IIBTree import difference
from BTrees.IIBTree import IIBucket
from BTrees.IIBTree import weightedIntersection
from BTrees.IIBTree import weightedUnion
from BTrees.OOBTree import OOSet
```
```    def __and__(self, x):
return self.__class__(
weightedIntersection(self._dict, x._dict),
union(self._words, x._words),
self._index,
```

```from time import time

from BTrees.IIBTree import intersection, weightedIntersection
from BTrees.IIBTree import IIBucket, IIBTree, IISet

```
```                r, u = r
result_len = len(r)
w, rs = weightedIntersection(rs, r)

```
```                    _i = '%s_weightedIntersection'%i
index_times[_i] = time()
w, rs = weightedIntersection(rs, r)
index_times[_i] = time() - index_times[_i]
else:
```

```import BTrees.Length
from BTrees.IIBTree import intersection, IISet
from BTrees.IIBTree import weightedIntersection
from BTrees.OIBTree import OIBTree
from BTrees.IOBTree import IOBTree
```
```                # we get, as some indexes don't return simple sets
if hasattr(rs, 'items') or hasattr(r, 'items'):
_, rs = weightedIntersection(rs, r)
else:
rs = intersection(rs, r)
```

```from zope.schema.interfaces import IVocabularyFactory
from zope.component import queryUtility
from BTrees.IIBTree import weightedIntersection, IISet

from Products.CMFCore.utils import getToolByName
```
```            rset = ctool.apply_index(self.context, index, normalized_value)
rset = IISet(rset)
rset = weightedIntersection(brains, rset)
if isinstance(value, unicode):
res[value] = len(rset)
```

```from zope.schema.interfaces import IVocabularyFactory
from zope.component import queryUtility
from BTrees.IIBTree import weightedIntersection, IISet

from Products.CMFCore.utils import getToolByName
```
```            rset = ctool.apply_index(self.context, index, normalized_value)
rset = IISet(rset)
rset = weightedIntersection(brains, rset)
if isinstance(value, unicode):
res[value] = len(rset)
```

```import BTrees.Length
from BTrees.IIBTree import intersection, weightedIntersection, IISet
from BTrees.OIBTree import OIBTree
from BTrees.IOBTree import IOBTree
from Products.ZCatalog.Lazy import LazyMap, LazyCat
```
```            if r is not None:
r, u = r
w, rs = weightedIntersection(rs, r)

search_indexes = self._get_search_indexes(request)
```

```
from BTrees.IIBTree import intersection as iiintersection
from BTrees.IIBTree import weightedIntersection as iiweightedIntersection
from BTrees.IIBTree import difference as iidifference
from BTrees.IIBTree import IISet, IITreeSet, IIBTree, IIBucket
```
```    def weightedIntersection(self, o1, o2, w1=1, w2=1):
return iiweightedIntersection(o1, o2, w1, w2)
from BTrees.IIBTree import weightedUnion, union
from BTrees.IIBTree import IIBucket as mkbucket
builders = IIBucket, IIBTree, testSetOps.itemsToSet(IISet), testSetOps.itemsToSet(IITreeSet)
```

```from experimental.btree import setpatches
setpatches.apply()

from BTrees.IIBTree import intersection as iiintersection
from BTrees.IIBTree import weightedIntersection as iiweightedIntersection
```
```    def weightedIntersection(self, o1, o2, w1=1, w2=1):
return iiweightedIntersection(o1, o2, w1, w2)
from BTrees.IIBTree import weightedUnion, union
from BTrees.IIBTree import IIBucket as mkbucket
builders = IIBucket, IIBTree, testSetOps.itemsToSet(IISet), testSetOps.itemsToSet(IITreeSet)
```

```    def weightedIntersection(self):