|
@@ -1,24 +1,14 @@
|
|
|
#
|
|
|
-# Copyright (c) Daniel Sheffield 2021 - 2022
|
|
|
+# Copyright (c) Daniel Sheffield 2021 - 2023
|
|
|
#
|
|
|
# All rights reserved
|
|
|
#
|
|
|
# THIS SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY
|
|
|
import numpy as np
|
|
|
-class Rating(object):
|
|
|
+class Rating():
|
|
|
def __init__(self, text_fields):
|
|
|
self.text_fields = text_fields
|
|
|
-
|
|
|
- def get_historic_prices(self, df):
|
|
|
- if df.empty:
|
|
|
- self.update_rating(None, None, None)
|
|
|
- return ''
|
|
|
-
|
|
|
- return df.drop(labels=[
|
|
|
- 'id', 'last', 'avg', 'min', 'max', 'price', 'quantity', 'ts_raw', 'product', 'category', 'group'
|
|
|
- ], axis=1).to_string(header=[
|
|
|
- 'Date', 'Store', '$/unit', 'Org',
|
|
|
- ], justify='justify-all', max_colwidth=16, index=False)
|
|
|
+ self.size = 14
|
|
|
|
|
|
def update_rating(self, _avg, _min, _max, unit, price=None, quantity=None):
|
|
|
if None in (_avg, _min, _max):
|
|
@@ -27,8 +17,8 @@ class Rating(object):
|
|
|
self.text_fields['marker'].set_text('')
|
|
|
return
|
|
|
current = None if None in (price, quantity or None) else float(price/quantity)
|
|
|
- size = 14
|
|
|
- chars = ['|', *['-']*(size - 2), '|' ]
|
|
|
+
|
|
|
+ chars = ['|', *['-']*(self.size - 2), '|' ]
|
|
|
rating = [' ']*len(chars)
|
|
|
_min, _max = min(_min, current or _min), max(_max, current or _max)
|
|
|
ls = np.linspace(_min, _max, len(chars))
|