MCPcopy
hub / github.com/pandas-dev/pandas / Term

Class Term

pandas/core/computation/pytables.py:70–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68
69
70class Term(ops.Term):
71 env: PyTablesScope
72
73 def __new__(cls, name, env, side=None, encoding=None):
74 if isinstance(name, str):
75 klass = cls
76 else:
77 klass = Constant
78 return object.__new__(klass)
79
80 def __init__(self, name, env: PyTablesScope, side=None, encoding=None) -> None:
81 super().__init__(name, env, side=side, encoding=encoding)
82
83 def _resolve_name(self):
84 # must be a queryables
85 if self.side == "left":
86 # Note: The behavior of __new__ ensures that self.name is a str here
87 if self.name not in self.env.queryables:
88 raise NameError(f"name {self.name!r} is not defined")
89 return self.name
90
91 # resolve the rhs (and allow it to be None)
92 try:
93 return self.env.resolve(self.name, is_local=False)
94 except UndefinedVariableError:
95 return self.name
96
97 # read-only property overwriting read/write property
98 @property # type: ignore[misc]
99 def value(self):
100 return self._value
101
102
103class Constant(Term):

Callers 3

test_encodingFunction · 0.90
test_frame_selectFunction · 0.90
test_invalid_termsFunction · 0.90

Calls

no outgoing calls

Tested by 3

test_encodingFunction · 0.72
test_frame_selectFunction · 0.72
test_invalid_termsFunction · 0.72