Skip to content

Commit

Permalink
fix mode method, and improvements on help and code
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelobianchi committed Dec 31, 2019
1 parent 9828ecd commit a43a692
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 5 additions & 6 deletions pqws.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def render_GET(self, request):
lis = [
li(a('query', '/query') + ': The Query method is the one that you should use to get data.'),
li(a('application.wadl', '/application.wadl') + ': The Query method is the one that you should use to get data.'),
li(a('web teste', '/web/test.html') + ': This is a web test/demonstration page for the system.'),
li(a('Test Web Page', '/web/test.html') + ': This is a web test page for the system.'),
]
msg += title('Available Resources are:', 2)
msg += ol(lis)
Expand All @@ -85,15 +85,14 @@ def __parseargs__(self, args):
def pquantity(v):
if v not in ['mean', 'median', 'mode', 'min', 'max']: raise ValueError("Invalid quantity value.")
return v
def pbool(v):
return (True if v in [ "true", "1", 1 ] else False)
def ploc(v): return ("--" if str(v) == "" else str(v))
def pbool(v): return True if v in [ "true", "1", 1 ] else False
def ploc(v) : return ("--" if str(v) == "" else str(v))
def pdow(v):
valid = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
v = v.split(",")
if len(v) == 0: raise ValueError("Days of week cannot be empty.")
if len(v) == 0: raise ValueError("Week days cannot be empty.")
for iv in v:
if iv not in valid: raise ValueError("Value is invalid")
if iv not in valid: raise ValueError("Value: {} is invalid".format(iv))
return v

validargs = [ 'net', 'sta', 'loc', 'cha', 'starttime',
Expand Down
11 changes: 7 additions & 4 deletions pypqlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def __periods__(self):
def mode(self, periods = False):
mode = []
for i in self.__periods__:
a = self.power[max(self.count[self.period == i])]
mode.append(a)
v = self.power[self.period == i][(self.count[self.period == i]).argmax()]
mode.append(v)
return (np.array(mode), self.__periods__) if periods else np.array(mode)

def median(self, periods = False):
Expand All @@ -149,10 +149,13 @@ def average(self, periods = False):
average.append(a)
return (np.array(average), self.__periods__) if periods else np.array(average)

def min(self, periods = False):
def min(self, periods = False, dirty = False):
minimun = []
for i in self.__periods__:
a = min(self.power[self.period == i])
if dirty:
a = min(self.power[self.period == i])
else:
a = min(self.power[(self.period == i)&(self.power>-200)])
minimun.append(a)
return (np.array(minimun), self.__periods__) if periods else np.array(minimun)

Expand Down

0 comments on commit a43a692

Please sign in to comment.