• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / #758

04 Sep 2023 08:37PM UTC coverage: 0.0% (-78.3%) from 78.333%
#758

push

circle-ci

hershd23
Increased underline length in at line 75 in text_summarization.rst
	modified:   docs/source/benchmarks/text_summarization.rst

0 of 11303 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/evadb/expression/constant_value_expression.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
from typing import Any
×
16

17
import numpy as np
×
18
import pandas as pd
×
19

20
from evadb.catalog.catalog_type import ColumnType
×
21
from evadb.expression.abstract_expression import AbstractExpression, ExpressionType
×
22
from evadb.models.storage.batch import Batch
×
23

24

25
class ConstantValueExpression(AbstractExpression):
×
26
    # Todo Implement generic value class
27
    # for now we don't assign any class to value
28
    # it can have types like string, int etc
29
    # return type not set, handle that based on value
30
    def __init__(self, value: Any, v_type: ColumnType = ColumnType.INTEGER):
×
31
        super().__init__(ExpressionType.CONSTANT_VALUE)
×
32
        self._value = value
×
33
        self._v_type = v_type
×
34

35
    def evaluate(self, batch: Batch, **kwargs):
×
36
        batch = Batch(pd.DataFrame({0: [self._value] * len(batch)}))
×
37
        return batch
×
38

39
    def signature(self) -> str:
×
40
        return str(self)
×
41

42
    @property
×
43
    def value(self):
×
44
        return self._value
×
45

46
    @property
×
47
    def v_type(self):
×
48
        return self._v_type
×
49

50
    # Todo implement other functionalities like maintaining hash
51
    # comparing two objects of this class(==)
52

53
    def __eq__(self, other):
×
54
        is_subtree_equal = super().__eq__(other)
×
55
        if not isinstance(other, ConstantValueExpression):
×
56
            return False
×
57
        # if the value type is NDARRAY, we need to reduce the
58
        # iterator to bool
59
        is_equal = is_subtree_equal and self.v_type == other.v_type
×
60

61
        if self.v_type == ColumnType.NDARRAY:
×
62
            return is_equal and all(self.value == other.value)
×
63
        else:
64
            return is_equal and self.value == other.value
×
65

66
    def __str__(self) -> str:
×
67
        expr_str = ""
×
68
        if not isinstance(self._value, np.ndarray):
×
69
            expr_str = f"{str(self._value)}"
×
70
        else:
71
            expr_str = f"{np.array_str(self._value)}"
×
72
        return expr_str
×
73

74
    def __hash__(self) -> int:
×
75
        return hash((super().__hash__(), self.v_type, str(self.value)))
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc