WGierke / informatiCup2018

Predicting the optimal strategy for fueling for a given route
http://tofill.dyndns.info:7080
MIT License
1 stars 1 forks source link

WIP: Fix operand error when calculating the price #44

Closed Baschdl closed 6 years ago

Baschdl commented 6 years ago

Fix error which occurs when multiplying cost and liters because "*" is not defined for 'decimal.Decimal' (cost) and 'float' (liters). @feeds I hope you didn't use decimal on purpose.

Baschdl commented 6 years ago

There is still an error

ERROR:root:can't multiply sequence by non-int of type 'decimal.Decimal'
Traceback (most recent call last):
  File "/usr/lib64/python3.4/site-packages/pandas/core/ops.py", line 676, in na_op
    result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)
  File "/usr/lib64/python3.4/site-packages/pandas/core/computation/expressions.py", line 204, in evaluate
    return _evaluate(op, op_str, a, b, **eval_kwargs)
  File "/usr/lib64/python3.4/site-packages/pandas/core/computation/expressions.py", line 64, in _evaluate_standard
    return op(a, b)
TypeError: unsupported operand type(s) for *: 'decimal.Decimal' and 'float'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.4/site-packages/pandas/core/ops.py", line 700, in safe_na_op
    return na_op(lvalues, rvalues)
  File "/usr/lib64/python3.4/site-packages/pandas/core/ops.py", line 686, in na_op
    result[mask] = op(x[mask], y)
TypeError: unsupported operand type(s) for *: 'decimal.Decimal' and 'float'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/informatiCup2018/src/serving/server.py", line 95, in get_prediction
    start_fuel_l=fuel)
  File "/root/informatiCup2018/src/serving/route_prediction.py", line 97, in get_fill_instructions_for_google_path
    positions_df['payment'] = positions_df.price * result.fill_liters
  File "/usr/lib64/python3.4/site-packages/pandas/core/ops.py", line 739, in wrapper
    result = wrap_results(safe_na_op(lvalues, rvalues))
  File "/usr/lib64/python3.4/site-packages/pandas/core/ops.py", line 710, in safe_na_op
    lambda x: op(x, rvalues))
  File "pandas/_libs/algos_common_helper.pxi", line 1212, in pandas._libs.algos.arrmap_object
  File "/usr/lib64/python3.4/site-packages/pandas/core/ops.py", line 710, in <lambda>
    lambda x: op(x, rvalues))
TypeError: can't multiply sequence by non-int of type 'decimal.Decimal'
feeds commented 6 years ago

45 fixes this