Browse Source

small fixes for dataeditor and StockWeekly, added pandas to dependencies

master
phryk 10 months ago
parent
commit
3e9ce4bdca
3 changed files with 24 additions and 26 deletions
  1. +7
    -7
      example.py
  2. +15
    -18
      poobrains/svg/plot.py
  3. +2
    -1
      setup.py

+ 7
- 7
example.py View File

@@ -161,7 +161,6 @@ class NASAApproaches(poobrains.svg.plot.Dataset):
#rawdata = [rawdata]

#self.data = pandas.DataFrame(data=rawdata, index=[spkid])
app.debugger.set_trace()
#self.data = pandas.DataFrame([pandas.Series(rawdata, index=rawindex)])
self.data = pandas.DataFrame(pandas.Series(rawdata))

@@ -191,21 +190,23 @@ class StockWeekly(poobrains.svg.plot.Dataset):
date = datetime.datetime(y, m, d)

x = date.timestamp()
y = float(datapoint['1. open']) + float(datapoint['4. close']) / 2
error_lower = y - float(datapoint['3. low'])
error_upper = y - float(datapoint['2. high'])
#x = date
#y = (float(datapoint['1. open']) + float(datapoint['4. close'])) / 2
y = float(datapoint['4. close'])
#error_lower = y - float(datapoint['3. low'])
#error_upper = y - float(datapoint['2. high'])

#self.add_datapoint(x, y, error_lower=error_lower, error_upper=error_upper)
rawdata[x] = y

self.data = pandas.DataFrame(data=rawdata)
self.data = pandas.DataFrame(pandas.Series(data=rawdata))



class ConstrainedRandom(poobrains.svg.plot.Dataset):

def fill(self, magnitude: int = 2, length: int = 16) -> None:
#app.debugger.set_trace()
magnitude, length = int(magnitude), int(length)

ranges = []
@@ -240,7 +241,6 @@ class Sine(poobrains.svg.plot.Dataset):

def fill(self, length=10):

import pudb; pudb.set_trace()
inc = (2 * math.pi) / (length - 1)
#inc = 1.0 / (length - 1)



+ 15
- 18
poobrains/svg/plot.py View File

@@ -95,7 +95,7 @@ class Dataset(poobrains.auth.Protected):


@name.setter
def set_name(self, value):
def name(self, value):
self._name = value


@@ -634,7 +634,9 @@ class EditorNewSessionFieldset(poobrains.form.Fieldset):
'plot_kind': 'scatter',
'action': None,
'action_data': None,
'data': None
'title': None,
'description': None,
'data': None,
}

return redirect(DataEditor.url(handle=handle, mode='full'))
@@ -708,8 +710,10 @@ class EditorLoadFieldset(poobrains.form.Fieldset):
dataset = StoredDataset.load(dataset_name)
dataset.permissions['read'].check(g.user)
instance.dataset = dataset
session['editor-sessions'][instance.handle_string]['data'] = instance.dataset.data.to_dict()
session['editor-sessions'][instance.handle_string]['action'] = None
session['editor-sessions'][instance.handle_string]['title'] = instance.dataset.title
session['editor-sessions'][instance.handle_string]['description'] = instance.dataset.description
session['editor-sessions'][instance.handle_string]['data'] = instance.dataset.data.to_dict()
except StoredDataset.DoesNotExist:
flash('Unknown stored dataset: %s' % dataset_name, 'error')

@@ -738,8 +742,10 @@ class EditorLoadFieldset(poobrains.form.Fieldset):

dataset.permissions['read'].check(g.user)
instance.dataset = dataset
session['editor-sessions'][instance.handle_string]['data'] = instance.dataset.data.to_dict()
session['editor-sessions'][instance.handle_string]['action'] = None
session['editor-sessions'][instance.handle_string]['title'] = instance.dataset.title
session['editor-sessions'][instance.handle_string]['description'] = instance.dataset.description
session['editor-sessions'][instance.handle_string]['data'] = instance.dataset.data.to_dict()
del(self.fields['dynamic'])
self.fields['dataset'].readonly = False

@@ -787,7 +793,10 @@ class DataEditor(poobrains.auth.ProtectedForm):
editor_session = session['editor-sessions'][self.handle_string]

self.dataset = Dataset()
self.dataset.name = self.handle_string
self.dataset.plot_kind = editor_session['plot_kind'] or 'scatter'
self.dataset.title = editor_session['title']
self.dataset.description = editor_session['description']
self.dataset.data = pandas.DataFrame.from_dict(editor_session['data'])

if len(self.dataset.data):
@@ -805,20 +814,6 @@ class DataEditor(poobrains.auth.ProtectedForm):
self.save_dataset = poobrains.form.Button(type='submit', label='Save dataset')


#@poobrains.helpers.themed
#def view(self, mode='full', **kwargs):

#if not self.handle_string:
# return redirect(type(self)(handle=new_editor_handle()).url('full'))

#if self.handle_string and self.handle_string in session:
# #self.dataset = session[self.handle_string]
# self.dataset = Dataset()
# self.dataset.data = pandas.DataFrame.from_dict(session['editor-sessions'][self.handle_string])

#return poobrains.helpers.ThemedPassthrough(super(DataEditor, self).view(mode=mode, **kwargs))


def process(self, submit):

if submit.startswith('new.'):
@@ -826,6 +821,8 @@ class DataEditor(poobrains.auth.ProtectedForm):

elif submit.startswith('load.'):
self.fields['load'].process(submit, self)
if len(self.dataset.data):
self.plot_kind = PlotKindFieldset(self.handle_string)
#session[self.handle_string] = self.data

elif submit.startswith('plot_kind.'):


+ 2
- 1
setup.py View File

@@ -16,7 +16,8 @@ setup(
'pillow', # for image manipulation and generation (primarily to generate captchas)
'markdown',
'pyproj', # map projection
'pretty-bad-protocol' # formerly 'gnupg'
'pretty-bad-protocol', # formerly 'gnupg'
'pandas'
],

extras_require={


Loading…
Cancel
Save