Kirill Simonov avatar Kirill Simonov committed 88e0fc9

Renamed Function* -> Formula*.

Comments (0)

Files changed (10)

src/htsql/tr/assemble.py

 from .coerce import coerce
 from .code import (Code, LiteralCode, EqualityCode, TotalEqualityCode,
                    ConjunctionCode, DisjunctionCode, NegationCode,
-                   FunctionCode, CastCode, Unit, ColumnUnit)
+                   FormulaCode, CastCode, Unit, ColumnUnit)
 from .term import (PreTerm, Term, UnaryTerm, BinaryTerm, TableTerm,
                    ScalarTerm, FilterTerm, JoinTerm, CorrelationTerm,
                    EmbeddingTerm, ProjectionTerm, OrderTerm, SegmentTerm,
                     EqualityPhrase, TotalEqualityPhrase, CastPhrase,
                     ConjunctionPhrase, DisjunctionPhrase, NegationPhrase,
                     ColumnPhrase, ReferencePhrase, EmbeddingPhrase,
-                    FunctionPhrase, Anchor, LeadingAnchor)
+                    FormulaPhrase, Anchor, LeadingAnchor)
 from .signature import Signature
 
 
 
     @classmethod
     def dispatch(interface, code, *args, **kwds):
-        assert isinstance(code, FunctionCode)
+        assert isinstance(code, FormulaCode)
         return (type(code.signature),)
 
     def __init__(self, code, state):
-        assert isinstance(code, FunctionCode)
+        assert isinstance(code, FormulaCode)
         assert isinstance(state, AssemblingState)
         self.code = code
         self.state = state
             is_nullable = any(cell.is_nullable for cell in arguments.cells())
         else:
             is_nullable = self.is_nullable
-        return FunctionPhrase(self.signature,
-                              self.domain,
-                              is_nullable,
-                              self.code,
-                              **arguments)
+        return FormulaPhrase(self.signature,
+                             self.domain,
+                             is_nullable,
+                             self.code,
+                             **arguments)
 
 
-class EvaluateFunction(Evaluate):
+class EvaluateFormula(Evaluate):
 
-    adapts(FunctionCode)
+    adapts(FormulaCode)
 
     def __call__(self):
         evaluate = EvaluateBySignature(self.code, self.state)

src/htsql/tr/binding.py

         self.base = base
 
 
-class FunctionBinding(Binding):
+class FormulaBinding(Binding):
     """
     Represents a function or an operator binding.
 
         assert isinstance(signature, Signature)
         arguments = Bag(**arguments)
         assert arguments.admits(Binding, signature)
-        super(FunctionBinding, self).__init__(domain, syntax)
+        super(FormulaBinding, self).__init__(domain, syntax)
         self.signature = signature
         self.arguments = arguments
         arguments.impress(self)

src/htsql/tr/code.py

         self.base = base
 
 
-class FunctionCode(Code):
+class FormulaCode(Code):
     """
     Represents a function or an operator expression.
 
         for cell in arguments.cells():
             units.extend(cell.units)
         equality_vector = (signature, domain, arguments.freeze())
-        super(FunctionCode, self).__init__(
+        super(FormulaCode, self).__init__(
                     domain=domain,
                     units=units,
                     binding=binding,

src/htsql/tr/encode.py

                       SortBinding, EqualityBinding, TotalEqualityBinding,
                       ConjunctionBinding, DisjunctionBinding,
                       NegationBinding, CastBinding, WrapperBinding,
-                      DirectionBinding, FunctionBinding)
+                      DirectionBinding, FormulaBinding)
 from .code import (ScalarSpace, DirectProductSpace, FiberProductSpace,
                    FilteredSpace, OrderedSpace,
                    QueryExpr, SegmentExpr, LiteralCode,
-                   EqualityCode, TotalEqualityCode, FunctionCode,
+                   EqualityCode, TotalEqualityCode, FormulaCode,
                    ConjunctionCode, DisjunctionCode, NegationCode,
                    CastCode, ColumnUnit, ScalarUnit)
 from .signature import Signature
 
     @classmethod
     def dispatch(interface, binding, *args, **kwds):
-        assert isinstance(binding, FunctionBinding)
+        assert isinstance(binding, FormulaBinding)
         return (type(binding.signature),)
 
     def __init__(self, binding, state):
-        assert isinstance(binding, FunctionBinding)
+        assert isinstance(binding, FormulaBinding)
         assert isinstance(state, EncodingState)
         self.binding = binding
         self.state = state
 
     def __call__(self):
         arguments = self.arguments.map(self.state.encode)
-        return FunctionCode(self.signature,
-                            self.domain,
-                            self.binding,
-                            **arguments)
+        return FormulaCode(self.signature,
+                           self.domain,
+                           self.binding,
+                           **arguments)
 
 
 class RelateBySignature(EncodeBySignatureBase):
         return None
 
 
-class EncodeFunction(Encode):
+class EncodeFormula(Encode):
 
-    adapts(FunctionBinding)
+    adapts(FormulaBinding)
 
     def __call__(self):
         encode = EncodeBySignature(self.binding, self.state)
         return encode()
 
 
-class RelateFunction(Relate):
+class RelateFormula(Relate):
 
-    adapts(FunctionBinding)
+    adapts(FormulaBinding)
 
     def __call__(self):
         relate = RelateBySignature(self.binding, self.state)
         return relate()
 
 
-class DirectFunction(Direct):
+class DirectFormula(Direct):
 
-    adapts(FunctionBinding)
+    adapts(FormulaBinding)
 
     def __call__(self):
         direct = DirectBySignature(self.binding, self.state)

src/htsql/tr/fn/bind.py

                        DateDomain, EnumDomain)
 from ..syntax import NumberSyntax, StringSyntax, IdentifierSyntax
 from ..binding import (LiteralBinding, SortBinding, SieveBinding,
-                       FunctionBinding, EqualityBinding, TotalEqualityBinding,
+                       FormulaBinding, EqualityBinding, TotalEqualityBinding,
                        ConjunctionBinding, DisjunctionBinding, NegationBinding,
                        CastBinding, WrapperBinding, TitleBinding,
                        DirectionBinding)
                 value = [CastBinding(item, domain, item.syntax)
                          for item in value]
             cast_arguments[name] = value
-        return FunctionBinding(self.signature, coerce(self.codomain),
+        return FormulaBinding(self.signature, coerce(self.codomain),
                                self.syntax, **cast_arguments)
 
 
                 binding = NegationBinding(binding, self.syntax)
             return binding
         else:
-            return FunctionBinding(self.signature, coerce(BooleanDomain()),
+            return FormulaBinding(self.signature, coerce(BooleanDomain()),
                                    self.syntax, lop=lop, rops=rops)
 
 
         comparable = Comparable(domain)
         if not comparable():
             raise BindError("uncomparable arguments", self.syntax.mark)
-        return FunctionBinding(self.signature, coerce(BooleanDomain()),
+        return FormulaBinding(self.signature, coerce(BooleanDomain()),
                                self.syntax, lop=lop, rop=rop)
 
 
             value = correlated_arguments[name]
             value = CastBinding(value, coerce(domain), value.syntax)
             correlated_arguments[name] = value
-        return FunctionBinding(correlate.signature, coerce(correlate.codomain),
+        return FormulaBinding(correlate.signature, coerce(correlate.codomain),
                                self.syntax, **correlated_arguments)
 
 
             codomain = domain
         else:
             codomain = coerce(self.codomain)
-        return FunctionBinding(self.signature, codomain, self.syntax,
+        return FormulaBinding(self.signature, codomain, self.syntax,
                                **cast_arguments)
 
 
                        for consequent in consequents]
         if alternative is not None:
             alternative = CastBinding(alternative, domain, consequent.syntax)
-        return FunctionBinding(self.signature, domain, self.syntax,
+        return FormulaBinding(self.signature, domain, self.syntax,
                                predicates=predicates,
                                consequents=consequents,
                                alternative=alternative)
                        for consequent in consequents]
         if alternative is not None:
             alternative = CastBinding(alternative, domain, consequent.syntax)
-        return FunctionBinding(self.signature, domain, self.syntax,
+        return FormulaBinding(self.signature, domain, self.syntax,
                                variable=variable,
                                variants=variants,
                                consequents=consequents,
 
     def correlate(self, op):
         op = CastBinding(op, coerce(BooleanDomain()), op.syntax)
-        return FunctionBinding(self.bind_signature, op.domain, self.syntax,
+        return FormulaBinding(self.bind_signature, op.domain, self.syntax,
                                base=self.state.base, op=op)
 
 
 
     def correlate(self, op):
         op = CastBinding(op, coerce(BooleanDomain()), op.syntax)
-        return FunctionBinding(CountSig(), coerce(IntegerDomain()),
+        return FormulaBinding(CountSig(), coerce(IntegerDomain()),
                                self.syntax, base=self.state.base, op=op)
 
 
         if not correlate():
             raise BindError("incompatible argument", self.syntax.mark)
         op = CastBinding(op, coerce(correlate.domain), op.syntax)
-        return FunctionBinding(correlate.signature, coerce(correlate.codomain),
+        return FormulaBinding(correlate.signature, coerce(correlate.codomain),
                                self.syntax, base=self.state.base, op=op)
 
 

src/htsql/tr/fn/encode.py

 from ..coerce import coerce
 from ..binding import LiteralBinding, CastBinding
 from ..code import (NegationCode, LiteralCode, ScalarUnit, CorrelatedUnit,
-                    AggregateUnit, FilteredSpace, FunctionCode)
+                    AggregateUnit, FilteredSpace, FormulaCode)
 from .signature import (NullIfSig, IfNullSig, QuantifySig, WrapExistsSig,
                         AggregateSig, CountSig,TakeCountSig,
                         MinSig, TakeMinSig, MaxSig, TakeMaxSig,
         op = LiteralCode(True, op.domain, self.binding)
         aggregate = CorrelatedUnit(op, plural_space, space,
                                    self.binding)
-        wrapper = FunctionCode(WrapExistsSig(), op.domain, self.binding,
-                               op=aggregate)
+        wrapper = FormulaCode(WrapExistsSig(), op.domain, self.binding,
+                              op=aggregate)
         if self.signature.polarity == -1:
             wrapper = NegationCode(wrapper, self.binding)
         wrapper = ScalarUnit(wrapper, space, self.binding)
 
     def take(self, op):
         false = LiteralCode(False, op.domain, op.binding)
-        op = FunctionCode(NullIfSig(), op.domain, op.binding,
-                          lop=op, rops=[false])
-        return FunctionCode(TakeCountSig(), self.binding.domain, self.binding,
-                            op=op)
+        op = FormulaCode(NullIfSig(), op.domain, op.binding,
+                         lop=op, rops=[false])
+        return FormulaCode(TakeCountSig(), self.binding.domain, self.binding,
+                           op=op)
 
     def wrap(self, op):
         zero = LiteralBinding('0', UntypedDomain(), op.syntax)
         zero = CastBinding(zero, op.domain, op.syntax)
         zero = self.state.encode(zero)
-        return FunctionCode(IfNullSig(), op.domain, op.binding,
-                            lop=op, rops=[zero])
+        return FormulaCode(IfNullSig(), op.domain, op.binding,
+                           lop=op, rops=[zero])
 
 
 class EncodeMin(EncodeAggregate):
     adapts(MinSig)
 
     def take(self, op):
-        return FunctionCode(TakeMinSig(), self.binding.domain, self.binding,
-                            op=op)
+        return FormulaCode(TakeMinSig(), self.binding.domain, self.binding,
+                           op=op)
 
 
 class EncodeMax(EncodeAggregate):
     adapts(MaxSig)
 
     def take(self, op):
-        return FunctionCode(TakeMaxSig(), self.binding.domain, self.binding,
-                            op=op)
+        return FormulaCode(TakeMaxSig(), self.binding.domain, self.binding,
+                           op=op)
 
 
 class EncodeSum(EncodeAggregate):
     adapts(SumSig)
 
     def take(self, op):
-        return FunctionCode(TakeSumSig(), self.binding.domain, self.binding,
-                            op=op)
+        return FormulaCode(TakeSumSig(), self.binding.domain, self.binding,
+                           op=op)
 
     def wrap(self, op):
         zero = LiteralBinding('0', UntypedDomain(), op.syntax)
         zero = CastBinding(zero, op.domain, op.syntax)
         zero = self.state.encode(zero)
-        return FunctionCode(IfNullSig(), op.domain, op.binding,
-                            lop=op, rops=[zero])
+        return FormulaCode(IfNullSig(), op.domain, op.binding,
+                           lop=op, rops=[zero])
 
 
 class EncodeAvg(EncodeAggregate):
     adapts(AvgSig)
 
     def take(self, op):
-        return FunctionCode(TakeAvgSig(), self.binding.domain, self.binding,
-                            op=op)
+        return FormulaCode(TakeAvgSig(), self.binding.domain, self.binding,
+                           op=op)
 
 

src/htsql/tr/fn/reduce.py

 from ...adapter import adapts
 from ..reduce import ReduceBySignature
 from ..frame import (IsNullPhrase, NullIfPhrase, IfNullPhrase,
-                     LiteralPhrase, FunctionPhrase)
+                     LiteralPhrase, FormulaPhrase)
 from .signature import (IsNullSig, NullIfSig, IfNullSig,
                         NumericKeepPolaritySig, ConcatenateSig)
 
         rop = self.phrase.rop
         if rop.is_nullable:
             rop = IfNullPhrase(rop, empty, rop.domain, rop.expression)
-        return FunctionPhrase(self.phrase.signature, self.phrase.domain,
-                              False, self.phrase.expression,
-                              lop=self.state.reduce(lop),
-                              rop=self.state.reduce(rop))
+        return FormulaPhrase(self.phrase.signature, self.phrase.domain,
+                             False, self.phrase.expression,
+                             lop=self.state.reduce(lop),
+                             rop=self.state.reduce(rop))
 
 

src/htsql/tr/frame.py

         self.base = base
 
 
-class FunctionPhrase(Phrase):
+class FormulaPhrase(Phrase):
     """
     Represents a function or an operator expression.
 
         arguments = Bag(**arguments)
         assert arguments.admits(Phrase, signature)
         equality_vector = (signature, domain, arguments.freeze())
-        super(FunctionPhrase, self).__init__(domain, is_nullable, expression,
-                                             equality_vector)
+        super(FormulaPhrase, self).__init__(domain, is_nullable, expression,
+                                            equality_vector)
         self.signature = signature
         self.arguments = arguments
         # For convenience, we permit access to function arguments using

src/htsql/tr/reduce.py

                     TotalEqualityPhrase, TotalInequalityPhrase,
                     ConnectivePhraseBase, ConjunctionPhrase, NegationPhrase,
                     IsNullPhraseBase, IsNullPhrase, IsNotNullPhrase,
-                    IfNullPhrase, NullIfPhrase, CastPhrase, FunctionPhrase,
+                    IfNullPhrase, NullIfPhrase, CastPhrase, FormulaPhrase,
                     ExportPhrase, ReferencePhrase, Anchor, LeadingAnchor)
 from .signature import Signature
 
 
     @classmethod
     def dispatch(interface, phrase, *args, **kwds):
-        assert isinstance(phrase, FunctionPhrase)
+        assert isinstance(phrase, FormulaPhrase)
         return (type(phrase.signature),)
 
     def __init__(self, phrase, state):
-        assert isinstance(phrase, FunctionPhrase)
+        assert isinstance(phrase, FormulaPhrase)
         assert isinstance(state, ReducingState)
         self.phrase = phrase
         self.state = state
 
     def __call__(self):
         arguments = self.arguments.map(self.state.reduce)
-        return FunctionPhrase(self.signature,
-                              self.domain,
-                              self.is_nullable,
-                              self.phrase.expression,
-                              **arguments)
+        return FormulaPhrase(self.signature,
+                             self.domain,
+                             self.is_nullable,
+                             self.phrase.expression,
+                             **arguments)
 
 
-class ReduceFunction(Reduce):
+class ReduceFormula(Reduce):
 
-    adapts(FunctionPhrase)
+    adapts(FormulaPhrase)
 
     def __call__(self):
         reduce = ReduceBySignature(self.phrase, self.state)

src/htsql/tr/serialize.py

                     ConjunctionPhrase, DisjunctionPhrase, NegationPhrase,
                     IsNullPhrase, IsNotNullPhrase, IfNullPhrase, NullIfPhrase,
                     CastPhrase, LiteralPhrase, ColumnPhrase, ReferencePhrase,
-                    EmbeddingPhrase, FunctionPhrase, Anchor, LeadingAnchor)
+                    EmbeddingPhrase, FormulaPhrase, Anchor, LeadingAnchor)
 from .signature import Signature
 from .plan import Plan
 import decimal
         self.state.format("CAST({base} AS CHARACTER VARYING)", base=self.base)
 
 
-class SerializeFunction(Serialize):
+class SerializeFormula(Serialize):
 
-    adapts(FunctionPhrase)
+    adapts(FormulaPhrase)
 
     def __call__(self):
         serialize = SerializeBySignature(self.phrase, self.state)
 
     @classmethod
     def dispatch(interface, phrase, *args, **kwds):
-        assert isinstance(phrase, FunctionPhrase)
+        assert isinstance(phrase, FormulaPhrase)
         return (type(phrase.signature),)
 
     def __init__(self, phrase, state):
-        assert isinstance(phrase, FunctionPhrase)
+        assert isinstance(phrase, FormulaPhrase)
         assert isinstance(state, SerializingState)
         self.phrase = phrase
         self.state = state
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.