documenting
This commit is contained in:
parent
2e25a03d13
commit
f1f88610dd
|
@ -66,7 +66,20 @@ class DADF5():
|
||||||
|
|
||||||
|
|
||||||
def __manage_visible(self,datasets,what,action):
|
def __manage_visible(self,datasets,what,action):
|
||||||
"""Manages the visibility of the groups."""
|
"""
|
||||||
|
Manages the visibility of the groups.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
datasets : list of str or Boolean
|
||||||
|
name of datasets as list, supports ? and * wildcards.
|
||||||
|
True is equivalent to [*], False is equivalent to []
|
||||||
|
what : str
|
||||||
|
attribute to change (must be in self.visible)
|
||||||
|
action : str
|
||||||
|
select from 'set', 'add', and 'del'
|
||||||
|
|
||||||
|
"""
|
||||||
# allow True/False and string arguments
|
# allow True/False and string arguments
|
||||||
if datasets is True:
|
if datasets is True:
|
||||||
datasets = ['*']
|
datasets = ['*']
|
||||||
|
@ -94,19 +107,60 @@ class DADF5():
|
||||||
|
|
||||||
|
|
||||||
def set_by_time(self,start,end):
|
def set_by_time(self,start,end):
|
||||||
|
"""
|
||||||
|
Sets active time increments based on start and end time.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
start : float
|
||||||
|
start time (included)
|
||||||
|
end : float
|
||||||
|
end time (exclcuded)
|
||||||
|
|
||||||
|
"""
|
||||||
self.__manage_visible(self.__time_to_inc(start,end),'increments','set')
|
self.__manage_visible(self.__time_to_inc(start,end),'increments','set')
|
||||||
|
|
||||||
|
|
||||||
def add_by_time(self,start,end):
|
def add_by_time(self,start,end):
|
||||||
|
"""
|
||||||
|
Adds to active time increments based on start and end time.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
start : float
|
||||||
|
start time (included)
|
||||||
|
end : float
|
||||||
|
end time (exclcuded)
|
||||||
|
|
||||||
|
"""
|
||||||
self.__manage_visible(self.__time_to_inc(start,end),'increments','add')
|
self.__manage_visible(self.__time_to_inc(start,end),'increments','add')
|
||||||
|
|
||||||
|
|
||||||
def del_by_time(self,start,end):
|
def del_by_time(self,start,end):
|
||||||
|
"""
|
||||||
|
Delets from active time increments based on start and end time.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
start : float
|
||||||
|
start time (included)
|
||||||
|
end : float
|
||||||
|
end time (exclcuded)
|
||||||
|
|
||||||
|
"""
|
||||||
self.__manage_visible(self.__time_to_inc(start,end),'increments','del')
|
self.__manage_visible(self.__time_to_inc(start,end),'increments','del')
|
||||||
|
|
||||||
|
|
||||||
def iter_visible(self,what):
|
def iter_visible(self,what):
|
||||||
"""Iterates over visible items by setting each one visible."""
|
"""
|
||||||
|
Iterates over visible items by setting each one visible.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
what : str
|
||||||
|
attribute to change (must be in self.visible)
|
||||||
|
|
||||||
|
"""
|
||||||
datasets = self.visible[what]
|
datasets = self.visible[what]
|
||||||
last_datasets = datasets.copy()
|
last_datasets = datasets.copy()
|
||||||
for dataset in datasets:
|
for dataset in datasets:
|
||||||
|
@ -120,14 +174,50 @@ class DADF5():
|
||||||
|
|
||||||
|
|
||||||
def set_visible(self,what,datasets):
|
def set_visible(self,what,datasets):
|
||||||
|
"""
|
||||||
|
Sets active groups.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
datasets : list of str or Boolean
|
||||||
|
name of datasets as list, supports ? and * wildcards.
|
||||||
|
True is equivalent to [*], False is equivalent to []
|
||||||
|
what : str
|
||||||
|
attribute to change (must be in self.visible)
|
||||||
|
|
||||||
|
"""
|
||||||
self.__manage_visible(datasets,what,'set')
|
self.__manage_visible(datasets,what,'set')
|
||||||
|
|
||||||
|
|
||||||
def add_visible(self,what,datasets):
|
def add_visible(self,what,datasets):
|
||||||
|
"""
|
||||||
|
Adds to active groups.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
datasets : list of str or Boolean
|
||||||
|
name of datasets as list, supports ? and * wildcards.
|
||||||
|
True is equivalent to [*], False is equivalent to []
|
||||||
|
what : str
|
||||||
|
attribute to change (must be in self.visible)
|
||||||
|
|
||||||
|
"""
|
||||||
self.__manage_visible(datasets,what,'add')
|
self.__manage_visible(datasets,what,'add')
|
||||||
|
|
||||||
|
|
||||||
def del_visible(self,what,datasets):
|
def del_visible(self,what,datasets):
|
||||||
|
"""
|
||||||
|
Removes from active groupse.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
datasets : list of str or Boolean
|
||||||
|
name of datasets as list, supports ? and * wildcards.
|
||||||
|
True is equivalent to [*], False is equivalent to []
|
||||||
|
what : str
|
||||||
|
attribute to change (must be in self.visible)
|
||||||
|
|
||||||
|
"""
|
||||||
self.__manage_visible(datasets,what,'del')
|
self.__manage_visible(datasets,what,'del')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,14 @@ class return_message():
|
||||||
"""Object with formatted return message."""
|
"""Object with formatted return message."""
|
||||||
|
|
||||||
def __init__(self,message):
|
def __init__(self,message):
|
||||||
|
"""
|
||||||
|
Sets return message.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
message : str or list of str
|
||||||
|
message for output to screen
|
||||||
|
"""
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -468,10 +476,15 @@ def curve_fit_bound(f, xdata, ydata, p0=None, sigma=None, bounds=None, **kw):
|
||||||
|
|
||||||
return (popt, pcov, infodict, errmsg, ier) if return_full else (popt, pcov)
|
return (popt, pcov, infodict, errmsg, ier) if return_full else (popt, pcov)
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadPool:
|
||||||
|
"""Pool of threads consuming tasks from a queue."""
|
||||||
|
|
||||||
class Worker(Thread):
|
class Worker(Thread):
|
||||||
"""Thread executing tasks from a given tasks queue."""
|
"""Thread executing tasks from a given tasks queue."""
|
||||||
|
|
||||||
def __init__(self, tasks):
|
def __init__(self, tasks):
|
||||||
|
""" Worker for tasks."""
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
self.tasks = tasks
|
self.tasks = tasks
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
|
@ -490,13 +503,19 @@ class Worker(Thread):
|
||||||
self.tasks.task_done()
|
self.tasks.task_done()
|
||||||
|
|
||||||
|
|
||||||
class ThreadPool:
|
|
||||||
"""Pool of threads consuming tasks from a queue."""
|
|
||||||
|
|
||||||
def __init__(self, num_threads):
|
def __init__(self, num_threads):
|
||||||
|
"""
|
||||||
|
Thread pool.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
num_threads : int
|
||||||
|
number of threads
|
||||||
|
|
||||||
|
"""
|
||||||
self.tasks = Queue(num_threads)
|
self.tasks = Queue(num_threads)
|
||||||
for _ in range(num_threads):
|
for _ in range(num_threads):
|
||||||
Worker(self.tasks)
|
self.Worker(self.tasks)
|
||||||
|
|
||||||
def add_task(self, func, *args, **kargs):
|
def add_task(self, func, *args, **kargs):
|
||||||
"""Add a task to the queue."""
|
"""Add a task to the queue."""
|
||||||
|
|
Loading…
Reference in New Issue