fixed pep8 styling problems
This commit is contained in:
parent
78d7e02285
commit
14e3e12571
|
@ -1,5 +1,5 @@
|
|||
# encoding: utf-8
|
||||
import sys
|
||||
# import sys
|
||||
import os
|
||||
import re
|
||||
import datetime
|
||||
|
@ -23,12 +23,14 @@ import matplotlib.pyplot as plt
|
|||
import matplotlib.dates
|
||||
import abc
|
||||
|
||||
from SimpaDbUtil import SqlDatabaseReader, SqlFile
|
||||
from inventory import Inventory
|
||||
# from SimpaDbUtil import SqlDatabaseReader, SqlFile
|
||||
# from inventory import Inventory
|
||||
|
||||
|
||||
def is_cluster_node_name(name):
|
||||
return re.match('^simpatix[0-9]+$', name) is not None or re.match('^physix[0-9]+$', name) is not None
|
||||
|
||||
|
||||
def get_investment_over_time(time_value, price, purchase_time):
|
||||
percent_decay_per_day = 0.0 # 1.0/(7.0*365.0)
|
||||
f1 = (purchase_time - time_value) * percent_decay_per_day + 1.0
|
||||
|
@ -37,12 +39,14 @@ def get_investment_over_time(time_value, price, purchase_time):
|
|||
|
||||
return f3 * price
|
||||
|
||||
|
||||
def get_flops_over_time(inventory, time_value, computer_id, purchase_time):
|
||||
"""
|
||||
:param Inventory inventory:
|
||||
"""
|
||||
return np.where(time_value < purchase_time, 0.0, inventory.get_computer_dflops(computer_id))
|
||||
|
||||
|
||||
def get_flops_price_over_time(inventory, time_value):
|
||||
"""
|
||||
:param Inventory inventory: the inventory database
|
||||
|
@ -75,9 +79,9 @@ def get_flops_price_over_time(inventory, time_value):
|
|||
# print(item)
|
||||
flops_price_over_time = np.where(time_value < item['time'], flops_price_over_time, item['flops_price'])
|
||||
|
||||
|
||||
return flops_price_over_time
|
||||
|
||||
|
||||
def get_computer_value_over_time(inventory, computer_id, time_value, flops_price_over_time, purchase_time):
|
||||
# print('flops_price_over_time = ', flops_price_over_time)
|
||||
computer_flops = inventory.get_computer_dflops(computer_id)
|
||||
|
@ -110,6 +114,8 @@ def get_computer_value_over_time(inventory, computer_id, time_value, flops_price
|
|||
# from_signal = y_stack[series_index-1,:]
|
||||
# ax.fill_between(x_signal, from_signal, y_stack[series_index,:], color=colors[series_index], lw=0.0, label=y_signals.keys()[series_index])
|
||||
# plt.legend()
|
||||
|
||||
|
||||
def stackplot(ax, x_signal, y_signals):
|
||||
"""
|
||||
:param matplotlib.Axes ax:
|
||||
|
@ -136,6 +142,7 @@ def stackplot(ax, x_signal, y_signals):
|
|||
ax.add_patch(p)
|
||||
plt.legend(list(y_signals.keys()))
|
||||
|
||||
|
||||
def draw_cluster_value_over_time_graph(inventory, from_date, to_date, graph_type):
|
||||
time_value = matplotlib.dates.drange(dstart=from_date, dend=to_date, delta=datetime.timedelta(days=1))
|
||||
flops_price_over_time = get_flops_price_over_time(inventory, time_value)
|
||||
|
@ -181,8 +188,8 @@ def draw_cluster_value_over_time_graph(inventory, from_date, to_date, graph_type
|
|||
stackplot(ax, time_value, cluster_value)
|
||||
|
||||
plt.xlabel('time')
|
||||
plt.ylabel(
|
||||
{'cluster_cost_over_time':u'cluster investment (€)',
|
||||
plt.ylabel({
|
||||
'cluster_cost_over_time': u'cluster investment (€)',
|
||||
'cluster_value_over_time': u'cluster value (€)',
|
||||
'cluster_dp_gflops_over_time': u'double prec gflops'}[graph_type])
|
||||
|
||||
|
@ -208,6 +215,7 @@ def draw_cluster_value_over_time_graph(inventory, from_date, to_date, graph_type
|
|||
# plt.plot(X,S)
|
||||
return fig
|
||||
|
||||
|
||||
def draw_dp_gflops_price_over_time_over_time_graph(inventory, from_date, to_date):
|
||||
"""
|
||||
:param Inventory inventory: the inventory database
|
||||
|
@ -235,6 +243,7 @@ def draw_dp_gflops_price_over_time_over_time_graph(inventory, from_date, to_date
|
|||
ax.grid(True)
|
||||
return fig
|
||||
|
||||
|
||||
def draw_age_pyramid_graph(inventory):
|
||||
"""
|
||||
:param Inventory inventory: the inventory database
|
||||
|
@ -251,7 +260,7 @@ def draw_age_pyramid_graph(inventory):
|
|||
if is_cluster_node:
|
||||
purchase_date = inventory.get_machine_purchase_date(name)
|
||||
if purchase_date is not None:
|
||||
purchase_time = matplotlib.dates.date2num(purchase_date.date())
|
||||
purchase_time = matplotlib.dates.date2num(purchase_date.date()) # noqa: F841
|
||||
age = datetime.datetime.now() - purchase_date
|
||||
age_histogram[age.days / 365] += 1
|
||||
# print(name, age)
|
||||
|
@ -288,6 +297,7 @@ class IFigureHandler(object):
|
|||
"""
|
||||
pass
|
||||
|
||||
|
||||
class ScreenFigureHandler(IFigureHandler):
|
||||
"""
|
||||
displays figures on screen
|
||||
|
@ -301,12 +311,11 @@ class ScreenFigureHandler(IFigureHandler):
|
|||
def on_finalize(self):
|
||||
plt.show()
|
||||
|
||||
|
||||
class SvgFigureHandler(IFigureHandler):
|
||||
"""
|
||||
saves figures as svg files
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __init__(self, out_svg_dir_path):
|
||||
"""
|
||||
|
@ -320,6 +329,7 @@ class SvgFigureHandler(IFigureHandler):
|
|||
def on_finalize(self):
|
||||
pass
|
||||
|
||||
|
||||
def draw_graphs(inventory, from_time, to_time, figure_handler):
|
||||
"""
|
||||
:param Inventory inventory: the inventory database
|
||||
|
|
Loading…
Reference in New Issue