diff --git a/src/Modules/General/callbacks.py b/src/Modules/General/callbacks.py index 35206d7a19104f103ecacb7e4c5377a24df82250..1d0726a06c24346a2144793aad908db09c89d6c1 100755 --- a/src/Modules/General/callbacks.py +++ b/src/Modules/General/callbacks.py @@ -6,7 +6,7 @@ from collections import deque import dash import pymongo -import numpy as np +import traceback from bson.json_util import dumps from bson.json_util import loads import plotly.graph_objects as go @@ -209,8 +209,8 @@ class callbacks(callbacksOp): return fig - except Exception as e: - print("processGeneralGraph "+str(e)) + except Exception: + print("processGeneralGraph " + traceback.format_exc()) def processLabelInfoTreemap(data): """ Return a Treemap visualization of actual inputs @@ -253,8 +253,8 @@ class callbacks(callbacksOp): uirevision='no reset of zoom', margin={'l': 0, 'r': 0, 't': 30, 'b': 0}, )} - except Exception as e: - print("processLabelInfoTreemap:"+str(e)) + except Exception: + print("processLabelInfoTreemap:"+ traceback.format_exc()) # ---------------------------------------------------- # Callbacks @@ -365,8 +365,8 @@ class callbacks(callbacksOp): return [super.label, sliderValue, 1, g.stepMax, sliderValue, clearGraphs, g.updateInterval] - except Exception as e: - print("progress:" + str(e)) + except Exception: + print("progress:" + traceback.format_exc()) # Callback to controle play/stop button @app.callback( [Output("btnControle", "children"), Output("btnControle", "className"),Output("vis-update", "disabled")], @@ -519,8 +519,8 @@ class callbacks(callbacksOp): speedValue = 5 return [speedValue * 1000,speedValue] - except Exception as e: - print("speedControle:" + str(e)) + except Exception: + print("speedControle:" + traceback.format_exc()) # Callback to handle information tab (open or close) @app.callback( @@ -541,8 +541,8 @@ class callbacks(callbacksOp): return [not isTabOpen] else: return [isTabOpen] - except Exception as e: - print("informationTabController:" + str(e)) + except Exception: + print("informationTabController:" + traceback.format_exc()) # Callback to handle the 2D view spiking visualization @app.callback( @@ -592,13 +592,13 @@ class callbacks(callbacksOp): matrix = super.toMatrix(super.AccumulatedSpikes2D,5) indices = super.toMatrix([i for i in range(0,len(super.AccumulatedSpikes2D))],5) return [elements,{'name': 'grid','animate': False},f"Neuron {mouseOverNodeData['label']} : {mouseOverNodeData['spikes']}", {"data":[go.Heatmap(z = matrix, zsmooth= 'best', colorscale= 'Reds',showscale= False, customdata = indices, hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 10, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}}] - except Exception as e: + except Exception: return [elements,{'name': 'grid','animate': False},[],{"data":[go.Heatmap(z = matrix, zsmooth= 'best', colorscale= 'Reds',showscale= False, customdata = indices, hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 10, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}}] - except Exception as e: - print("animation2DViewController:" + str(e)) + except Exception: + print("animation2DViewController:" + traceback.format_exc()) - except Exception as e: - print("Done loading:"+str(e)) + except Exception: + print("Done loading:"+traceback.format_exc()) try: @@ -830,5 +830,5 @@ class callbacks(callbacksOp): return min(100,round((loss*100) / len(spikes), 2)) # --------------------------------------------------------------------- - except Exception as e: - print("Helper functions and MongoDB operations: "+str(e)) + except Exception: + print("Helper functions and MongoDB operations: "+ traceback.format_exc()) \ No newline at end of file diff --git a/src/Modules/General/layout.py b/src/Modules/General/layout.py index fc292914b201eb3b3becd5c636993a67d7c6b946..8809379ed862aa8bb94087dd3461cb58eba32ca9 100755 --- a/src/Modules/General/layout.py +++ b/src/Modules/General/layout.py @@ -2,6 +2,7 @@ """ import importlib +import traceback import dash_daq as daq from collections import deque import dash_cytoscape as cyto @@ -287,8 +288,8 @@ class layout(layoutOp): try: tabs.append(dcc.Tab(importlib.import_module( ".Modules."+m+".layout", package="src").layout().load(self.app, self.g), label=m)) - except Exception as e: - print("Tabs appending:"+str(e)) + except Exception: + print("Tabs appending:"+traceback.format_exc()) # App layout self.app.layout = html.Div([ diff --git a/src/Modules/General/spark.py b/src/Modules/General/spark.py index cb1cf8608e1bbfffb0898436a5d1b857f0b19f0c..8f40d7e242f728e1766abeb46c64af4e16f355a8 100755 --- a/src/Modules/General/spark.py +++ b/src/Modules/General/spark.py @@ -69,8 +69,8 @@ class spark(sparkOp): else: print("No labels") - except Exception as e: - print("MongoError:" + str(e)) + except Exception: + print("GlobalSparkMongoError:" + traceback.format_exc()) pass self.g.Max = M self.g.stepMax = int(M/self.g.updateInterval)+1 @@ -78,14 +78,14 @@ class spark(sparkOp): try: data = next(col, None) self.g.Accuracy = data["Acc"] - except Exception as e: + except Exception: self.g.Accuracy = "--" print("No accuracy recorded") pass try: self.g.finalLabels = data["NLabel"] - except Exception as e: + except Exception: print("No output neuron classes recorded") self.g.finalLabels = None pass @@ -93,7 +93,6 @@ class spark(sparkOp): # ------------------------------------------------------------ print("done ", self.MODULE_NAME) - except Exception as e: - print("Error:" + str(e)) - traceback.print_exc() + except Exception: + print("GlobalSpark:" + traceback.format_exc()) pass diff --git a/src/Modules/MultiLayer/callbacks.py b/src/Modules/MultiLayer/callbacks.py index 89f40c7496202fd719aa1415de7ccf277b8a4eb9..d9065d6384c2b142e02eb4912838db2d2a38037f 100755 --- a/src/Modules/MultiLayer/callbacks.py +++ b/src/Modules/MultiLayer/callbacks.py @@ -11,6 +11,7 @@ import plotly.graph_objects as go from dash import dcc, html from bson.json_util import dumps, loads from dash.exceptions import PreventUpdate +import traceback from dash.dependencies import ALL, MATCH, Input, Output, State from src.templates.callbacksOp import callbacksOp @@ -49,11 +50,11 @@ class callbacks(callbacksOp): super.clearData() return [display, clear] - except Exception as e: - print("display:"+str(e)) + except Exception: + print("display:" + traceback.format_exc()) - except Exception as e: - print("CallbackName:" + str(e)) + except Exception: + print("CallbackName:" + traceback.format_exc()) # ---------------------------------------------------------------- # Callback related Data retreiving functions @@ -67,5 +68,5 @@ class callbacks(callbacksOp): print("Add MongoDB functions here") - except Exception as e: - print("Data process loading:"+str(e)) \ No newline at end of file + except Exception: + print("Data process loading:" + traceback.format_exc()) \ No newline at end of file diff --git a/src/Modules/MultiLayer/layout.py b/src/Modules/MultiLayer/layout.py index 07af6ad30c26f69c9c9333038917f5ec0bef8ba5..275cf2cb3ab237def4a0309bddd261907640bfcc 100755 --- a/src/Modules/MultiLayer/layout.py +++ b/src/Modules/MultiLayer/layout.py @@ -3,6 +3,7 @@ from collections import deque from dash import dcc, html +import traceback import dash_bootstrap_components as dbc from .callbacks import callbacks from src.templates.layoutOp import layoutOp @@ -49,5 +50,5 @@ class layout(layoutOp): # callbacks(self.app, self.g) # Return the Layer return layer - except Exception as e: - print("MultiLayer:" + str(e)) \ No newline at end of file + except Exception: + print("MultiLayer:" + traceback.format_exc()) \ No newline at end of file diff --git a/src/Modules/MultiLayer/spark.py b/src/Modules/MultiLayer/spark.py index cf2195eef34f09798c0a44436bc3b292068b1847..835b30725336698c947e8f934e5f1caebf513e4c 100755 --- a/src/Modules/MultiLayer/spark.py +++ b/src/Modules/MultiLayer/spark.py @@ -54,7 +54,6 @@ class spark(sparkOp): self.g.modules = [module for module in self.g.modules if module != MODULE_NAME] print("done ", MODULE_NAME) - except Exception as e: - print("Error:" + str(e)) - traceback.print_exc() + except Exception: + print("Error:" + traceback.format_exc()) pass \ No newline at end of file diff --git a/src/Modules/Neuron/callbacks.py b/src/Modules/Neuron/callbacks.py index 766871b1b508916cfeb56d4f025de3de238e3dd8..96ea315b799782e9641aa65a8be94f880c6eb771 100755 --- a/src/Modules/Neuron/callbacks.py +++ b/src/Modules/Neuron/callbacks.py @@ -6,6 +6,7 @@ import dash import pymongo import statistics +import traceback import dash_daq as daq from collections import deque import plotly.graph_objects as go @@ -101,8 +102,8 @@ class callbacks(callbacksOp): if(len(graphsArea) == 0): graphsArea.append(addSpaceHolder(app)) return graphsArea - except Exception as e: - print("InsertRemoveNewElement: " + str(e)) + except Exception: + print("InsertRemoveNewElement: " + traceback.format_exc()) try: @@ -121,8 +122,8 @@ class callbacks(callbacksOp): return [[{'label': str(i), 'value': str(i)} for i in range(g.Layer_Neuron[selectedLayer])], ""] else: return [[], ""] - except Exception as e: - print("NeuronSelection: " + str(e)) + except Exception: + print("NeuronSelection: " + traceback.format_exc()) try: # Callback to handle filtering when 3D view clicked @@ -140,8 +141,8 @@ class callbacks(callbacksOp): return [super.SpikesSameClass(filterClass, g), {"visibility": "hidden"}] else: return [super.SpikesSameClass(filterClass["points"][0], g), {"visibility": "visible"}] - except Exception as e: - print("NeuronFreqFilter: " + str(e)) + except Exception: + print("NeuronFreqFilter: " + traceback.format_exc()) try: # Callback to handle clearing content when received a clear signal @@ -165,8 +166,8 @@ class callbacks(callbacksOp): super.clearData(existingIndexes) return [displayContent, clearGraphs] - except Exception as e: - print("clearProcess: "+str(e)) + except Exception: + print("clearProcess: "+ traceback.format_exc()) try: # Callback to handle spikes per interval graph and spike class representation @app.callback([Output({"index": MATCH, "layer": MATCH, "neuron": MATCH, "type": "FreqGraph"}, "figure"), @@ -248,8 +249,8 @@ class callbacks(callbacksOp): return output else: raise PreventUpdate - except Exception as e: - print("processSpikeRelatedGraphs: " + str(e)) + except Exception: + print("processSpikeRelatedGraphs: " + traceback.format_exc()) try: # Callback to handle neuron potential graph @@ -326,8 +327,8 @@ class callbacks(callbacksOp): return output else: raise PreventUpdate - except Exception as e: - print("processPotential: " + str(e)) + except Exception: + print("processPotential: " + traceback.format_exc()) try: @@ -492,8 +493,8 @@ class callbacks(callbacksOp): paper_bgcolor= "rgba(255, 255, 255,0)", plot_bgcolor= "rgba(255, 255, 255,0)" )} - except Exception as e: - print("spikeCountDrawGraph: "+str(e)) + except Exception: + print("spikeCountDrawGraph: "+ traceback.format_exc()) def neuronPotentialDrawGraph(index, data, xAxis, xAxisLabel, yAxisList, isOn): """ Create scatter plot for selected neuron, that contains @@ -595,8 +596,8 @@ class callbacks(callbacksOp): paper_bgcolor= "rgba(255, 255, 255,0)", plot_bgcolor= "rgba(255, 255, 255,0)" )} - except Exception as e: - print("neuronPotentialDrawGraph: "+str(e)) + except Exception: + print("neuronPotentialDrawGraph: "+ traceback.format_exc()) def classDrawGraph(index, data, isOn, labels): """ Create scatter polar plot for selected neuron, that represents @@ -690,8 +691,8 @@ class callbacks(callbacksOp): margin={'l': 0, 'r': 0, 't': 25, 'b': 30}, ) } - except Exception as e: - print("classDrawGraph: "+str(e)) + except Exception: + print("classDrawGraph: "+ traceback.format_exc()) # ------------------------------------------------------------ # MongoDB operations @@ -753,5 +754,5 @@ class callbacks(callbacksOp): return None return FreqForNeuron - except Exception as e: - print("Helper functions: "+str(e)) \ No newline at end of file + except Exception: + print("Helper functions: "+ traceback.format_exc()) \ No newline at end of file diff --git a/src/Modules/Neuron/layout.py b/src/Modules/Neuron/layout.py index b0679f189c213a9f237e1bf14ccd273c3d7e485d..1ac5a3c2d43b0a3906ac47d4b9f190e9beb4b786 100755 --- a/src/Modules/Neuron/layout.py +++ b/src/Modules/Neuron/layout.py @@ -4,6 +4,7 @@ import pymongo from itertools import product from collections import deque +import traceback from .callbacks import callbacks from bson.json_util import dumps from bson.json_util import loads @@ -87,8 +88,8 @@ class layout(layoutOp): callbacks(self,self.app, self.g) # Return the Layer return layer - except Exception as e: - print("NeuronLayer: " + str(e)) + except Exception: + print("NeuronLayer: " + traceback.format_exc()) # ---------------------------------------------------------------- # Helper functions diff --git a/src/Modules/Neuron/spark.py b/src/Modules/Neuron/spark.py index 89dd65c52e621af4013f8fac958657cbc9748b8c..02c4dec4f691f0002cb287a2497ee82b511da34f 100755 --- a/src/Modules/Neuron/spark.py +++ b/src/Modules/Neuron/spark.py @@ -55,7 +55,6 @@ class spark(sparkOp): self.g.modules = [module for module in self.g.modules if module != self.MODULE_NAME] print("done ", self.MODULE_NAME) - except Exception as e: - print("Error:" + str(e)) - traceback.print_exc() + except Exception: + print("Error:" + traceback.format_exc()) pass diff --git a/src/Modules/Synapse/callbacks.py b/src/Modules/Synapse/callbacks.py index 6d73376175a3a3322817a0bae883610728ef8a3e..739dca484918c2832d4cac5e31e45024ab895862 100755 --- a/src/Modules/Synapse/callbacks.py +++ b/src/Modules/Synapse/callbacks.py @@ -3,20 +3,17 @@ Dash callbacks are the responsible on updating graphs each step. """ -import time from dash.dependencies import Input, Output, State, MATCH, ALL import dash import pymongo +import traceback from dash import dcc, html import dash_daq as daq from bson.json_util import loads -from bson.json_util import dumps from dash.exceptions import PreventUpdate import plotly.graph_objects as go from plotly.subplots import make_subplots from collections import deque -import statistics -from itertools import groupby import numpy as np import pandas as pd from src.templates.callbacksOp import callbacksOp @@ -45,9 +42,8 @@ class callbacks(callbacksOp): {"type": "DeleteComponent", "index": ALL}, "n_clicks")], [State({"type": "GraphsAreaSynapse"}, "children"), State({"type": "GlobalHeatMapAreaSynapse"}, "children"), State("LayerFilterSynapse", "value"), State( - "NeuronFilterSynapse", "value"), State("HeatMapX", "value"), - State("HeatMapY", "value")]) - def InsertRemoveNewElement(addButtonClick, deleteButtonsClick, graphsArea, GlobalHeatmap, selectedLayer, selectedNeuron, HeatMapX, HeatMapY): + "NeuronFilterSynapse", "value")]) + def InsertRemoveNewElement(addButtonClick, deleteButtonsClick, graphsArea, GlobalHeatmap, selectedLayer, selectedNeuron): """ Insert of remove element. Args: @@ -57,8 +53,6 @@ class callbacks(callbacksOp): GlobalHeatmap (list): list of GLobalHeatma component children selectedLayer (String): name of the selected layer selectedNeuron (int): id of selected neuron - HeatMapX (int): X dimension for heatmaps - HeatMapY (int): Y dimension for heatmaps Returns: the updated content of 'GraphsAreaSynapse' and 'GlobalHeatMapAreaSynapse' @@ -86,7 +80,7 @@ class callbacks(callbacksOp): data = self.getGlobalSynapseWeights(g,selectedLayer) super.globalHeatMap[selectedLayer] = data - return [graphsArea, self.AddGlobalHeatmap(g, selectedLayer, data, HeatMapX, HeatMapY) if not data.empty else []] + return [graphsArea, self.AddGlobalHeatmap(g, selectedLayer, data) if not data.empty else []] else: if(context[0]['prop_id'] != "."): # Delete item @@ -119,8 +113,8 @@ class callbacks(callbacksOp): if(len(graphsArea) == 0): graphsArea.append(self.addSpaceHolder(g,app)) return [graphsArea, GlobalHeatmap] - except Exception as e: - print("InsertRemoveNewElement: " + str(e)) + except Exception: + print("InsertRemoveNewElement: "+ traceback.format_exc()) try: # Callback to get neurons of seleced layer @@ -138,8 +132,8 @@ class callbacks(callbacksOp): return [[{'label': str(i), 'value': str(i)} for i in range(g.Layer_Neuron[selectedLayer])], ""] else: return [[], ""] - except Exception as e: - print("NeuronSelection: " + str(e)) + except Exception: + print("NeuronSelection: " + traceback.format_exc()) try: # Callback to handle clearing content when received a clear signal @@ -163,8 +157,8 @@ class callbacks(callbacksOp): super.clearData(existingIndexes) return [displayContent, clearGraphs] - except Exception as e: - print("clearProcess: "+str(e)) + except Exception: + print("clearProcess: "+ traceback.format_exc()) try: # Callback to handle spikes per interval graph and spike class representation @@ -173,9 +167,8 @@ class callbacks(callbacksOp): [Input("display-Synapse", "children")], [State("v-step", "children"), State("interval", "value"), State({"index": MATCH, "layer": MATCH, "neuron": MATCH, "type": "SynapseFreqGraph"}, "id"), State({"index": MATCH, "layer": MATCH, "neuron": MATCH, "type": 'Synapse-frequency-switch'}, 'on'), - State({"index": MATCH, "layer": MATCH, "neuron": MATCH, "type": 'Synapse-HeatMap-switch'}, 'on'), - State("HeatMapX", "value"), State("HeatMapY", "value")]) - def processSynapseData(displayContent, sliderValue, updateInterval, selectedItem, isOnSynapseFreqGraph, isOnHeatmap, heatMapX, heatMapY): + State({"index": MATCH, "layer": MATCH, "neuron": MATCH, "type": 'Synapse-HeatMap-switch'}, 'on')]) + def processSynapseData(displayContent, sliderValue, updateInterval, selectedItem, isOnSynapseFreqGraph, isOnHeatmap): """ Create two graphs using neuron synapses ('SynapseFreqGraph' and 'Heatmap') Args: @@ -185,8 +178,6 @@ class callbacks(callbacksOp): selectedItem (list): selected neuron isOnSynapseFreqGraph (bool): whether SynapseFreq graph is active or not isOnHeatmap (bool): whether Heatmap graph is active or not - heatMapX (int): X dimension for heatmaps - heatMapY (int): Y dimension for heatmaps Raises: PreventUpdate: in case we don't want to update the content we rise this execption @@ -210,7 +201,7 @@ class callbacks(callbacksOp): output = [self.synapseFreqDrawGraph(g, selectedItem["index"], data, super.xAxisSynapseFreqGraph[selectedItem["index"]], super.xAxisLabel[selectedItem["index"]], super.yAxisSynapseFreqGraph, super.HeatMapSynapseFreqGraph, isOnSynapseFreqGraph), - self.heatMap(g, selectedItem["index"], data, super.heatmaps, isOnHeatmap, heatMapX, heatMapY)] + self.heatMap(g, selectedItem["index"], data, super.heatmaps, isOnHeatmap)] return output else: @@ -226,7 +217,7 @@ class callbacks(callbacksOp): output = [self.synapseFreqDrawGraph(g, selectedItem["index"], data, super.xAxisSynapseFreqGraph[selectedItem["index"]], super.xAxisLabel[selectedItem["index"]], super.yAxisSynapseFreqGraph, super.HeatMapSynapseFreqGraph, isOnSynapseFreqGraph), - self.heatMap(g, selectedItem["index"], data, super.heatmaps, isOnHeatmap, heatMapX, heatMapY)] + self.heatMap(g, selectedItem["index"], data, super.heatmaps, isOnHeatmap)] return output else: @@ -246,13 +237,13 @@ class callbacks(callbacksOp): output = [self.synapseFreqDrawGraph(g, selectedItem["index"], data, super.xAxisSynapseFreqGraph[selectedItem["index"]], super.xAxisLabel[selectedItem["index"]], super.yAxisSynapseFreqGraph, super.HeatMapSynapseFreqGraph, isOnSynapseFreqGraph), - self.heatMap(g, selectedItem["index"], data, super.heatmaps, isOnHeatmap, heatMapX, heatMapY)] + self.heatMap(g, selectedItem["index"], data, super.heatmaps, isOnHeatmap)] return output else: raise PreventUpdate - except Exception as e: - print("processSynapseData: " + str(e)) + except Exception: + print("processSynapseData: "+ traceback.format_exc()) try: @@ -273,8 +264,8 @@ class callbacks(callbacksOp): return [not isTabOpen] else: return [isTabOpen] - except Exception as e: - print("GlobalHeatMapTab: " + str(e)) + except Exception: + print("GlobalHeatMapTab: "+ traceback.format_exc()) try: @@ -340,15 +331,13 @@ class callbacks(callbacksOp): id="spaceHolder") - def AddGlobalHeatmap(self, g, selectedLayer, data, heatMapX, heatMapY): + def AddGlobalHeatmap(self, g, selectedLayer, data): """ Add global heatmap for selected layer. Args: g (Global_Var): reference to access global variables selectedLayer (String): layer name data (dataframe): synapses weights of all neurons in the layer - heatMapX (int): X dimension for heatmaps - heatMapY (int): Y dimension for heatmaps Returns: html component that contains the global heatmaps @@ -553,10 +542,10 @@ class callbacks(callbacksOp): plot_bgcolor= "rgba(255, 255, 255,0)", xaxis={'title': 'Step'} )} - except Exception as e: - print("synapseFreqDrawGraph: "+str(e)) + except Exception: + print("synapseFreqDrawGraph: "+ traceback.format_exc()) - def heatMap(self, g, index, data, heatmaps, isOn, heatMapX, heatMapY): + def heatMap(self, g, index, data, heatmaps, isOn): """ Create heatmap for selected neuron synapses. Args: @@ -565,14 +554,11 @@ class callbacks(callbacksOp): data (list): data to be added to the graph heatmaps (list): list of heatmaps created isOn (bool): whether this graph is active or not - heatMapX (int): X dimension for heatmaps - heatMapY (int): Y dimension for heatmaps Returns: heatmap content (data and layout) """ try: - heatMapWithIndexs = [] layout = go.Layout( margin={'l': 0, 'r': 0, 't': 0, 'b': 25}, @@ -584,22 +570,24 @@ class callbacks(callbacksOp): plot_bgcolor= "rgba(255, 255, 255,0)") if isOn: if not data.empty: + heatMapX = data["x"].max() + 1 + heatMapY = data["y"].max() + 1 + + # update heatmap in heatmaps + if (str(index) not in heatmaps) or (type(heatmaps[str(index)]) == type(None)): + heatmaps[str(index)] = [np.zeros((heatMapX,heatMapY)),heatMapX,heatMapY] + depth = data["C"].max() data = data.sort_values(["T"]) data = data.groupby(["C","x","y"], as_index=False).agg({"To":"last","T":"max","L":"last","V":"last"}) - # update heatmap in heatmaps - if str(index) not in heatmaps: - heatmaps[str(index)] = np.zeros( - (heatMapX, heatMapY)) for X,Y,V,C in zip(data["x"],data["y"],data["V"],data["C"]): try: # TODO: multi-D - heatmaps[str(index)][X][Y] = V + heatmaps[str(index)][0][X][Y] = V heatMapWithIndexs.append([X, Y, C, V]) - except Exception as e: - print("heatMap1: "+str(e)) - + except Exception: + print("heatMap1: "+ traceback.format_exc()) return {'data': [ go.Heatmap( z=g.createHeatMap(heatMapX, heatMapY, pd.DataFrame(heatMapWithIndexs), depth), @@ -609,7 +597,7 @@ class callbacks(callbacksOp): 'layout': layout} else: if str(index) not in heatmaps: - heatmaps[str(index)] = np.empty((heatMapX, heatMapY)) + heatmaps[str(index)] = None return {'data': [ go.Heatmap( @@ -623,12 +611,12 @@ class callbacks(callbacksOp): go.Heatmap( zmin=0, zmax=1, - z=heatmaps[str(index)] if str( + z=heatmaps[str(index)][0] if str( index) in heatmaps else [], colorscale="jet")], 'layout': layout} - except Exception as e: - print("heatMap2: "+str(e)) + except Exception: + print("heatMap2: "+ traceback.format_exc()) # ------------------------------------------------------------ # MongoDB operations @@ -695,5 +683,5 @@ class callbacks(callbacksOp): # ---------------------------- return globalSynapseWeights - except Exception as e: - print("Data process loading: "+str(e)) \ No newline at end of file + except Exception: + print("Data process loading: "+ traceback.format_exc()) \ No newline at end of file diff --git a/src/Modules/Synapse/layout.py b/src/Modules/Synapse/layout.py index 7d253987e418c3c90278cbb1a930d928e3384426..d73a80f1a61a7370131d41fb13a20ee7d5d66023 100755 --- a/src/Modules/Synapse/layout.py +++ b/src/Modules/Synapse/layout.py @@ -3,6 +3,7 @@ from collections import deque from dash import dcc, html +import traceback import dash_bootstrap_components as dbc from .callbacks import callbacks from src.templates.layoutOp import layoutOp @@ -65,16 +66,10 @@ class layout(layoutOp): style={'width': '150px', "marginLeft": "10px", "textAlign": "start"}), dbc.Button("+", id="AddComponentSynapse", n_clicks=0, style={ "fontWeight": "500", "marginLeft": "20px", "height": "36px", - "backgroundColor":"rgb(68, 71, 99)","borderColor":"rgb(68, 71, 99)"}), - html.Div([ - dbc.Input(type="number",id="HeatMapX",value=self.g.NeuronsSize["x"]+1, min=0, step=1, - style={"width":"80px","marginLeft":"10px","textAlign":"center"}), - html.P("X",style={"padding":"5px"}), - dbc.Input(type="number",id="HeatMapY",value=self.g.NeuronsSize["y"]+1, min=0, step=1, - style={"width":"80px","textAlign":"center"})], className="d-flex",style={"marginLeft":"3px"}) + "backgroundColor":"rgb(68, 71, 99)","borderColor":"rgb(68, 71, 99)"}) ,html.Div(id='clear-Synapse',children="False", style={'display': 'none'}) ,html.Div(id='display-Synapse',children="False", style={'display': 'none'}) - ], className="d-flex"), + ], className="d-flex", style={"paddingBottom": "10px"}), dbc.Card( dbc.CardBody([dbc.Card([dbc.CardHeader( dbc.Button( "Layer HeatMap", color="none", id="group-GlobalHeatMapAreaSynapse-toggle", @@ -93,5 +88,5 @@ class layout(layoutOp): callbacks(self,self.app,self.g) # Return the Layer return layer - except Exception as e: - print("SynapseLayer: " + str(e)) \ No newline at end of file + except Exception: + print("SynapseLayer: " + traceback.format_exc()) \ No newline at end of file diff --git a/src/Modules/Synapse/spark.py b/src/Modules/Synapse/spark.py index aef9ded093a26020097bf2a774c2d856bac4a514..70e9a8fc1e26fd5af8c26d3831327e7deda84113 100755 --- a/src/Modules/Synapse/spark.py +++ b/src/Modules/Synapse/spark.py @@ -64,7 +64,6 @@ class spark(sparkOp): print("done", self.MODULE_NAME) - except Exception as e: - print("Error:" + str(e)) - traceback.print_exc() + except Exception: + print("Error:" + traceback.format_exc()) pass \ No newline at end of file