Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def update_graph(n):
infos = get_infos()
device_info = infos["devices"]
fig = tools.make_subplots(
rows=2,
cols=2,
subplot_titles=(
"GPU Util(%)",
"Memory Usage Rate(%)",
"Temperature(℃)",
"Fan Speed(%)",
),
shared_xaxes=False,
print_grid=False,
)
x = [f"{d.name} {d.id}" for d in device_info]
free = [d.free / (1024.0 ** 2) for d in device_info]
used = [d.used / (1024.0 ** 2) for d in device_info]
total = [d.total / (1024.0 ** 2) for d in device_info]
gpu_util = [d.gpu_util for d in device_info]
def graph_parsed_data(self, username, api_key):
'''
At this process the program will access the Plotly api and graph the features that/
were given by the first parsing process. The attributes that it will take in will be Api Username,
ApiPassword or api_key
:param username: this accesses is the api Username that you initially added in the first process.
:param api_key: this is the api key that you receive after registration.
:return: Final graph
'''
tls.set_credentials_file(username=username, api_key=api_key)
data = [
go.Scatter(
x=self.df['jobs'], # assign x as the dataframe column 'x'
y=self.df['number of openings']
)
]
final_graph = py.plot(data, filename='pandas/basic-bar')
return final_graph
else:
return [], []
df = pd.read_json(df_json, orient='split')
dff = pd.DataFrame(rows)
attributes = []
if len(selected_row_indices) != 0:
dff = dff.loc[selected_row_indices]
attributes = dff["Attribute"].values
types = dff["DataType"].values
if len(attributes) == 0:
fig = tools.make_subplots(rows=1, cols=1)
trace1 = go.Scatter(x=[0, 0, 0], y=[0, 0, 0])
fig.append_trace(trace1, 1, 1)
else:
numplots = len(attributes)
fig = tools.make_subplots(rows=numplots, cols=1)
i = 0
for attribute in attributes:
if types[i]=="numeric":
trace1 = {
"type": 'violin',
"x": df[attribute],
"box": {
"visible": True
},
"line": {
"color": 'black'
},
"meanline": {
"visible": True
},
"fillcolor": 'steelblue',
def update_figure(rows, selected_row_indices):
dff = pd.DataFrame(rows)
fig = plotly.tools.make_subplots(
rows=3, cols=1,
subplot_titles=('Life Expectancy', 'GDP Per Capita', 'Population',),
shared_xaxes=True)
marker = {'color': ['#0074D9']*len(dff)}
for i in (selected_row_indices or []):
marker['color'][i] = '#FF851B'
fig.append_trace({
'x': dff['country'],
'y': dff['lifeExp'],
'type': 'bar',
'marker': marker
}, 1, 1)
fig.append_trace({
'x': dff['country'],
'y': dff['gdpPercap'],
'type': 'bar',
# In[8]:
# find target gaps for each target resistance at v_read
for g_idx, g in enumerate(sim_read_r):
for t_idx, r in enumerate(g):
new_r, r_idx = find_nearest_sorted(last_r_read[g_idx, :], r)
sim_read_r[g_idx, t_idx] = new_r
required_loads[g_idx, t_idx] = r_loads[r_idx]
# In[9]:
if plot_2d:
fig_r = plotly.tools.make_subplots(rows=1, cols=2)
for g_idx, g in enumerate(required_loads):
fig_r.append_trace(
plotly.graph_objs.Scatter(
x=simple_index,
y=g,
mode='lines+markers',
name='load_r for initial gap ' + str(initial_gaps[g_idx]),
xaxis='x1',
yaxis='y1'
), 1, 1)
fig_r.append_trace(
plotly.graph_objs.Scatter(
x=simple_index,
y=sim_read_r[g_idx,:],
s_1.write(dict(x=x1,y=y1))
s_2.write(dict(x=x2,y=y2))
#predicted_metric_list.append(int(predicted_value))
print ("Next timestamp aggregate metric prediction: " + str(predicted_value))
if (-200 <= predicted_value <= 450):
print ("Forecast does not exceed threshold for alert!\n")
else:
print ("Forecast exceeds acceptable threshold - Alert Sent!\n")
del total_list_for_RNN[0]
IoT_Demo_Topic = '/user/user01/iot_stream:sensor_record'
max = 402
DIR="/user/user01/TFmodel"
stream_tokens = tls.get_credentials_file()['stream_ids']
token_1 = stream_tokens[0] # I'm getting my stream tokens from the end to ensure I'm not reusing tokens
token_2 = stream_tokens[1]
stream_id1 = dict(token=token_1, maxpoints=60)
stream_id2 = dict(token=token_2, maxpoints=60)
trace1 = go.Scatter(x=[],y=[],mode='lines',
line = dict(color = ('rgb(22, 96, 167)'),width = 4),
stream=stream_id1,
name='Sensor')
trace2 = go.Scatter(x=[],y=[],mode='markers',
stream=stream_id2,
marker=dict(color='rgb(255, 0, 0)',size=10),
name = 'Prediction')
mode="markers",
marker=dict(color=self._stats_option.highlight_color),
text=labels
)
# Set up the box plot.
box_plot = go.Box(
x0=0, # Initial position of the box plot
y=self._active_doc_term_matrix.sum(1).values,
hoverinfo="y",
marker=dict(color=self._stats_option.highlight_color),
jitter=.15
)
# Create a figure with two subplots and fill the figure.
figure = tools.make_subplots(rows=1, cols=2, shared_yaxes=False)
figure.append_trace(trace=scatter_plot, row=1, col=1)
figure.append_trace(trace=box_plot, row=1, col=2)
# Hide useless information on x-axis and set up title.
figure.layout.update(
dragmode="pan",
showlegend=False,
margin=dict(
r=0,
b=30,
t=10,
pad=4
),
xaxis=dict(
showgrid=False,
zeroline=False,
def traces_to_panels(traces, names=[], ylabs=None, xlabs=None):
r, c, locs = panel_arrangement(len(traces))
multi = tools.make_subplots(rows=r, cols=c, subplot_titles=names)
for idx, loc in enumerate(locs):
if idx < len(traces):
for component in traces[idx]:
multi.append_trace(component, *loc)
else:
multi = panel_invisible(multi, idx + 1)
multi.layout["showlegend"] = False
return multi
'Altitude': []
}
# Collect some data
for i in range(180):
time = datetime.datetime.now() - datetime.timedelta(seconds=i*20)
lon, lat, alt = satellite.get_lonlatalt(
time
)
data['Longitude'].append(lon)
data['Latitude'].append(lat)
data['Altitude'].append(alt)
data['time'].append(time)
# Create the graph with subplots
fig = plotly.tools.make_subplots(rows=2, cols=1, vertical_spacing=0.2)
fig['layout']['margin'] = {
'l': 30, 'r': 10, 'b': 30, 't': 10
}
fig['layout']['legend'] = {'x': 0, 'y': 1, 'xanchor': 'left'}
fig.append_trace({
'x': data['time'],
'y': data['Altitude'],
'name': 'Altitude',
'mode': 'lines+markers',
'type': 'scatter'
}, 1, 1)
fig.append_trace({
'x': data['Longitude'],
'y': data['Latitude'],
'text': data['time'],
def plot(l1000cds2_results, plot_counter, nr_drugs=7, height=300):
# Check if there are results
if not l1000cds2_results['mimic'] or not l1000cds2_results['reverse']:
display(Markdown('### No results were found.\n This is likely due to the fact that the gene identifiers were not recognized by L1000CDS<sup>2</sup>. Please note that L1000CDS<sup>2</sup> currently only supports HGNC gene symbols (https://www.genenames.org/). If your dataset uses other gene identifier systems, such as Ensembl IDs or Entrez IDs, consider converting them to HGNC. Automated gene identifier conversion is currently under development.'))
else:
# Links
if l1000cds2_results['signature_label']:
display(Markdown('\n### {signature_label} signature:'.format(**l1000cds2_results)))
display(Markdown(' **L1000CDS<sup>2</sup> Links:**'))
display(Markdown(' *Mimic Signature Query Results*: {url}'.format(**l1000cds2_results['mimic'])))
display(Markdown(' *Reverse Signature Query Results*: {url}'.format(**l1000cds2_results['reverse'])))
# Bar charts
fig = tools.make_subplots(rows=1, cols=2, print_grid=False);
for i, direction in enumerate(['mimic', 'reverse']):
drug_counts = l1000cds2_results[direction]['table'].groupby('pert_desc').size().sort_values(ascending=False).iloc[:nr_drugs].iloc[::-1]
# Get Bar
bar = go.Bar(
x=drug_counts.values,
y=drug_counts.index,
orientation='h',
name=direction.title(),
hovertext=drug_counts.index,
hoverinfo='text',
marker={'color': '#FF7F50' if direction=='mimic' else '#9370DB'}
)
fig.append_trace(bar, 1, i+1)
# Get text