-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
INSTALLATION
Python 3.11 virtual environment
❯ pip list
Package Version Editable project location
--------------- ----------- ----------------------------------------------------------
colorama 0.4.6
devind-yearfrac 1.0.0
et_xmlfile 2.0.0
iniconfig 2.0.0
jsonpickle 2.2.0
mock 4.0.3
numpy 1.26.4
numpy-financial 1.0.0
openpyxl 3.0.10
packaging 24.1
pandas 1.5.3
pip 24.3.1
pluggy 1.5.0
pytest 8.3.3
python-dateutil 2.9.0.post0
pytz 2024.2
scipy 1.14.1
setuptools 65.5.0
six 1.16.0
xlsx_evaluate 0.5.0 D:\code-d\pub\analytic_dev\ast\xlsx-evaluate\xlsx_evaluateISSUE: pytest Failures
> pytest
==================================================================================== FAILURES ====================================================================================
_________________________________________________________________________ ChooseTest.test_evaluation_A1 __________________________________________________________________________
self = <tests.functions_vs_excel.choose_test.ChooseTest testMethod=test_evaluation_A1>
def test_evaluation_A1(self):
excel_value = self.evaluator.get_cell_value('Sheet1!A1')
value_00 = self.evaluator.evaluate('Sheet1!A1')
> self.assertEqual(excel_value, value_00)
E AssertionError: 12 != <Number 3>
tests\functions_vs_excel\choose_test.py:10: AssertionError
_________________________________________________________________________ ChooseTest.test_evaluation_A2 __________________________________________________________________________
self = <tests.functions_vs_excel.choose_test.ChooseTest testMethod=test_evaluation_A2>
def test_evaluation_A2(self):
excel_value = self.evaluator.get_cell_value('Sheet1!A2')
value_01 = self.evaluator.evaluate('Sheet1!A2')
> self.assertEqual(excel_value, value_01)
E AssertionError: 4 != <Number 2>
tests\functions_vs_excel\choose_test.py:15: AssertionError
_________________________________________________________________________ ChooseTest.test_evaluation_A3 __________________________________________________________________________
self = <tests.functions_vs_excel.choose_test.ChooseTest testMethod=test_evaluation_A3>
def test_evaluation_A3(self):
excel_value = [[1, 2, 3]]
value_00 = self.evaluator.evaluate('Sheet1!A3')
> self.assertEqual(excel_value, value_00.values.tolist())
E AttributeError: 'Number' object has no attribute 'values'
tests\functions_vs_excel\choose_test.py:20: AttributeError
__________________________________________________________________________ TestEvaluator.test_evaluate ___________________________________________________________________________
self = <xlsx_evaluate.evaluator.Evaluator object at 0x000002A6D1D40990>, addr = 'Ninth!B1'
def evaluate(self, addr):
# 1. Resolve the address to a cell.
addr = self.resolve_names(addr)
if addr not in self.model.cells:
# Blank cell that has no stored value in the model.
return func_xltypes.BLANK
cell = self.model.cells[addr]
# 2. If there is no formula, we simply return the cell value.
if cell.formula is None or cell.formula.evaluate is False:
return func_xltypes.ExcelType.cast_from_native(self.model.cells[addr].value)
# 3. Prepare the execution environment and evaluate the formula.
# (Note: Range nodes will automatically evaluate all their
# dependencies.)
context = self.get_context(addr)
try:
> value = cell.formula.ast.eval(context)
xlsx_evaluate\evaluator.py:91:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xlsx_evaluate\ast_nodes.py:195: in eval
self.right.eval(context),
xlsx_evaluate\ast_nodes.py:146: in eval
addr = self.full_address(context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <RangeNode tvalue: XLCell(address='Eighth!B1', sheet='Eighth', value=100.0, formula=None, defined_names=['Hundred']), ttype: operand, tsubtype: range>
context = <xlsx_evaluate.evaluator.EvaluatorContext object at 0x000002A6FAA34250>
def full_address(self, context):
addr = self.address
> if '!' not in addr:
E TypeError: argument of type 'XLCell' is not iterable
xlsx_evaluate\ast_nodes.py:141: TypeError
During handling of the above exception, another exception occurred:
self = <tests.test_evaluator.TestEvaluator testMethod=test_evaluate>
def test_evaluate(self):
evaluated_result_00 = self.evaluator.evaluate('First!A2')
result_00 = 0.1
self.assertEqual(result_00, evaluated_result_00)
evaluated_result_01 = self.evaluator.evaluate('Seventh!C1')
result_01 = 3
self.assertEqual(result_01, evaluated_result_01)
> evaluated_result_02 = self.evaluator.evaluate('Ninth!B1')
tests\test_evaluator.py:24:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xlsx_evaluate\evaluator.py:93: in evaluate
raise RuntimeError(
xlsx_evaluate\evaluator.py:91: in evaluate
value = cell.formula.ast.eval(context)
xlsx_evaluate\ast_nodes.py:195: in eval
self.right.eval(context),
xlsx_evaluate\ast_nodes.py:146: in eval
addr = self.full_address(context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <RangeNode tvalue: XLCell(address='Eighth!B1', sheet='Eighth', value=100.0, formula=None, defined_names=['Hundred']), ttype: operand, tsubtype: range>
context = <xlsx_evaluate.evaluator.EvaluatorContext object at 0x000002A6FAA34250>
def full_address(self, context):
addr = self.address
> if '!' not in addr:
E RuntimeError: Problem evaluating cell Ninth!B1 formula A1+Hundred: TypeError("argument of type 'XLCell' is not iterable")
xlsx_evaluate\ast_nodes.py:141: RuntimeError
============================================================================ short test summary info =============================================================================
FAILED tests/functions_vs_excel/choose_test.py::ChooseTest::test_evaluation_A1 - AssertionError: 12 != <Number 3>
FAILED tests/functions_vs_excel/choose_test.py::ChooseTest::test_evaluation_A2 - AssertionError: 4 != <Number 2>
FAILED tests/functions_vs_excel/choose_test.py::ChooseTest::test_evaluation_A3 - AttributeError: 'Number' object has no attribute 'values'
FAILED tests/test_evaluator.py::TestEvaluator::test_evaluate - RuntimeError: Problem evaluating cell Ninth!B1 formula A1+Hundred: TypeError("argument of type 'XLCell' is not iterable")
=================================================================== 4 failed, 826 passed, 3 skipped in 14.71s ====================================================================Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels