MCPcopy Index your code
hub / github.com/clips/pattern / __call__

Method __call__

pattern/vector/__init__.py:646–657  ·  view source on GitHub ↗

Vector(vector) returns a new vector updated with values from the given vector. No new features are added. For example: Vector({1:1, 2:2})({1:0, 3:3}) => {1:0, 2:2}.

(self, vector={})

Source from the content-addressed store, hash-verified

644 return Vector(self, weight=self.weight)
645
646 def __call__(self, vector={}):
647 """ Vector(vector) returns a new vector updated with values from the given vector.
648 No new features are added. For example: Vector({1:1, 2:2})({1:0, 3:3}) => {1:0, 2:2}.
649 """
650 if isinstance(vector, (Document, Model)):
651 vector = vector.vector
652 v = self.copy()
653 s = dict.__setitem__
654 for f, w in vector.iteritems():
655 if f in v:
656 s(v, f, w)
657 return v
658
659#--- VECTOR DISTANCE -------------------------------------------------------------------------------
660# The "distance" between two vectors can be calculated using different metrics.

Callers

nothing calls this directly

Calls 3

copyMethod · 0.95
sFunction · 0.85
iteritemsMethod · 0.80

Tested by

no test coverage detected