utils¶
Classes:
|
In the future, we will implement a coherent Parameter management system |
|
Sends signals to the main QT thread from spawned message threads |
Wrapper that calls an evoked event made by |
|
|
Thread whose .join() method returns the value from the function thx to https://stackoverflow.com/a/6894023 |
Functions:
|
Given a dictionary of a pilot_db, return the subjects that are in it. |
|
Try to load the file_db |
|
Coerce a discrete/string column of a pandas dataframe into numeric values |
|
Find all instances of a key in a dictionary, recursively. |
-
class
Param
(**kwargs)[source]¶ Bases:
object
In the future, we will implement a coherent Parameter management system
Warning
Not Implemented.
- Parameters
**kwargs
Attributes:
Methods:
__getitem__
(key)- Parameters
key
__setitem__
(key, value)- Parameters
key
__delitem__
(key)- Parameters
key
__contains__
(key)- Parameters
key
-
tag
= None¶
-
type
= None¶
-
types
= ['int', 'bool', 'list']¶
-
class
InvokeEvent
(fn, *args, **kwargs)[source]¶ Bases:
PySide2.QtCore.QEvent
Sends signals to the main QT thread from spawned message threads
See stackoverflow
Accepts a function, its args and kwargs and wraps them as a
QtCore.QEvent
Attributes:
-
EVENT_TYPE
= PySide2.QtCore.QEvent.Type(65533)¶
-
-
class
Invoker
[source]¶ Bases:
PySide2.QtCore.QObject
Wrapper that calls an evoked event made by
InvokeEvent
Methods:
event
(event)- Parameters
event
Attributes:
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object at 0x7f519d56e460>¶
-
class
ReturnThread
(group=None, target=None, name=None, args=(), kwargs={}, Verbose=None)[source]¶ Bases:
threading.Thread
Thread whose .join() method returns the value from the function thx to https://stackoverflow.com/a/6894023
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
Methods:
run
()Method representing the thread’s activity.
join
([timeout])Wait until the thread terminates.
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
join
(timeout=None)[source]¶ Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.
-
-
list_subjects
(pilot_db=None)[source]¶ Given a dictionary of a pilot_db, return the subjects that are in it.
- Parameters
pilot_db (dict) – a pilot_db. if None tried to load pilot_db with :method:`.load_pilotdb`
- Returns
a list of currently active subjects
- Return type
subjects (list)
-
load_pilotdb
(file_name=None, reverse=False)[source]¶ Try to load the file_db
- Parameters
reverse
file_name
Returns:
-
coerce_discrete
(df, col, mapping={'L': 0, 'R': 1})[source]¶ Coerce a discrete/string column of a pandas dataframe into numeric values
Default is to map ‘L’ to 0 and ‘R’ to 1 as in the case of Left/Right 2AFC tasks
- Parameters
df (
pandas.DataFrame
) – dataframe with the column to transformcol (str) – name of column
mapping (dict) – mapping of strings to numbers
- Returns
transformed dataframe
- Return type
df (
pandas.DataFrame
)