def scatter(self, col=None, x = None, y = None, name = None): assert type(col) != type(None) or type(y) != type(None) if type(x) == type(None): x = self.timestamps if type(y) == type(None): y = self.data[castlist(col)].values.flatten() return go.Scatter( x = x, y = y, name= name if name != None else None )
def wrapper_do_function(*args, **kwargs): try: parent = args[0] except: raise assert isinstance(parent, Cachable), 'Only Cachable datatypes are possible' kwargsToCheck = [l for l in list(func.__code__.co_varnames) if l != 'self'] interestingKwargs = {} if type(kwargsToCheck) != type(None): interestingKwargs = {kwarg: kwargs[kwarg] if kwarg in kwargs else None for kwarg in kwargsToCheck} else: interestingKwargs = kwargs parDict = inspectDict(parent) localAttribute = 'attr-loc-' if payAttentionTo != None: for attr in castlist(payAttentionTo): interestingKwargs['{}{}'.format(localAttribute, attr)] = '{}'.format(parDict[attr] if attr in parDict else 'None') ignored = list(ignore) if type(ignore) != type(None) else [] globalAttribute = 'attr-glo-' if parent.alwaysCheck != None: for attr in [att for att in castlist(parent.alwaysCheck) if att not in ignored]: if attr not in interestingKwargs and '{}{}'.format(localAttribute, attr) not in interestingKwargs: interestingKwargs['{}{}'.format(globalAttribute,attr)] = '{}'.format(parDict[attr] if attr in parDict else 'None') cachable = '{}__{}'.format(func.__name__, '__'.join(['{}_{}'.format(k, interestingKwargs[k]) for k in interestingKwargs])) if len(args) > 1: cachable += '__args__{}'.format('_'.join(str(arg) for arg in args[1:])) already, ret = parent.isHashedAlready(cachable) if already: return ret result = func(*args, **kwargs) parent.insertNewResult(cachable, result) if hasattr(parent, 'save') and callable(parent.save): if parent.verbose: log(f'Saving file after {cachable}') parent.save() return result
def outlierShapes(self, relCol, outCol): self.recalculateOutlierExplanations() blocks = self.outlierExplanations[outCol].outlierBlocks def shape(x0, y0, x1, y1): return go.Scatter( x = [x0, x1, x1, x0, x0], y = [y0, y0, y1, y1, y0], fill = 'toself', marker = dict(opacity = 0), line = dict(color = 'rgb(255,0,0)') ) tstmps = self.timestamps relData = self.data[castlist(relCol)].values xs = [ dict( x0=tstmps[bl[0]], y0=np.min(relData[slice(*bl)]), x1=tstmps[bl[1]-1], y1=np.max(relData[slice(*bl)]) ) for bl, bChar in blocks] return [shape(**x) for x in xs]
saveButton = html.Button('Save data', id=ids['saveButton']) precalculateButton = html.Button('Precalc', id=ids['precalculateButton']) precalculateLoader = dcc.Loading(id = ids['precalculateLoader']) precalculateDiv = html.Div([precalculateLoader, precalculateButton], id = ids['precalculateDiv'], style= precalculateDivStyle) deleteButtonDiv = html.Div(deleteButton, id=ids['deleteButtonDiv'], style=buttonDivStyle) saveButtonDiv = html.Div([saveButton, precalculateDiv], id=ids['saveButtonDiv'], style=buttonDivStyle) dataChoice = dcc.Dropdown(value = None, id=ids['dataChoice'], style = {**dropDownStyle, **minwidth400}) dataChoiceDiv = html.Div(dataChoice, id=ids['dataChoiceDiv'], style={**fullparentwidth, **flexcenter}) updateTriggerDivs = lambda x: [html.Div(id=f'update-trigger-{i + 1}', style=displaynone) for i in range(x)] updateTriggerOutput = lambda index: Output(f'update-trigger-{index}', 'children') updateTriggerInput = lambda indexes: [Input(f'update-trigger-{i}', 'children') for i in castlist(indexes)] colIdLabel = html.Label('Timeseries Id column') colIdDiv = html.Div([colIdLabel]) colSortLabel = html.Label('Timestamp column') colSortDiv = html.Div([colSortLabel]) colFrequencyLabel = html.Label('Frequency of data') colFrequencyDiv = html.Div([colFrequencyLabel], id = 'input-frequency-div', style = maxwidth200) colOutlierLabel = html.Label('Outlier column') colOutlierDiv = html.Div([colOutlierLabel]) colRelevantLabel = html.Label('Relevant columns to take a look at') colRelevantDiv = html.Div([colRelevantLabel]) colId = dcc.Dropdown(id='dd-column-id', style = dropDownStyle) colSort = dcc.Dropdown(id='dd-column-sort', style = dropDownStyle) colIsTimestamp = dcc.RadioItems(id='ri-is-timestamp',options=[dict(label='Is Timestamp in [s]', value='True'), dict(label='Not a Timestamp', value='False')])
def matrixprofile(self, col, motiflen): mp = matrixProfile.stomp(self.data[castlist(col)].values.flatten(), motiflen) return self.scatter(y = mp[0], name = 'matrixprofile (len {})'.format(motiflen))