global_object
Modules:
| Name | Description |
|---|---|
global_object |
|
hugger |
|
logger |
|
map |
|
undo_redo |
|
Classes
Modules
global_object
Classes:
| Name | Description |
|---|---|
GlobalObject |
GlobalObject is the assimilated knowledge of |
Classes
GlobalObject()
GlobalObject is the assimilated knowledge of EasyScience.
Every class based on EasyScience gets brought into the
collective.
Methods:
| Name | Description |
|---|---|
instantiate_stack |
The undo/redo stack references the collective. |
generate_unique_name |
Generate a generic unique name for the object using the class |
Functions
instantiate_stack()
The undo/redo stack references the collective.
Hence it has to be imported after initialization.
generate_unique_name(name_prefix)
Generate a generic unique name for the object using the class
name and a global iterator. Names are in the format
name_prefix_0, name_prefix_1, name_prefix_2, etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name_prefix
|
str
|
The prefix to be used for the name. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Generated unique name. |
Functions
hugger
Modules:
| Name | Description |
|---|---|
hugger |
|
property |
|
Modules
hugger
property
Classes:
| Name | Description |
|---|---|
LoggedProperty |
Pump up python properties. |
Classes
LoggedProperty(*args, get_id=None, my_self=None, test_class=None, **kwargs)
Pump up python properties.
In this case we can see who has called this property and then do
something if a criteria is met. In this case if the caller is not a
member of the ObjBase class. Note that all high level
EasyScience objects should be built from ObjBase.
logger
Classes:
| Name | Description |
|---|---|
Logger |
Central logging controller for EasyScience. |
Classes
Logger(log_level=logging.WARNING)
Central logging controller for EasyScience.
Owns the package-root logger easyscience and provides a
convenience API to set its level. It never calls
logging.basicConfig nor attaches a handler, so the host
application keeps full control over where output goes.
log_level : int, default=logging.WARNING
Default level for the package-root logger. Overridden by the
EASYSCIENCE_LOG_LEVEL environment variable when set.
Methods:
| Name | Description |
|---|---|
debug |
Log a DEBUG-level message on the package-root logger. |
info |
Log an INFO-level message on the package-root logger. |
warning |
Log a WARNING-level message on the package-root logger. |
error |
Log an ERROR-level message on the package-root logger. |
critical |
Log a CRITICAL-level message on the package-root logger. |
exception |
Log an ERROR-level message with traceback on the package-root |
getLogger |
Create or retrieve a child logger under easyscience. |
at_level |
Context manager that temporarily sets the package-root logger to |
suspend |
Suppress all core log output (set level to CRITICAL+1). |
resume |
Restore the level captured by the most recent suspend call. |
Attributes:
| Name | Type | Description |
|---|---|---|
level |
int
|
Get the effective level of the package-root logger. |
Attributes
level
property
writable
Get the effective level of the package-root logger.
Returns:
| Type | Description |
|---|---|
int
|
Numeric logging level currently set on the |
Functions
debug(msg, *args, **kwargs)
Log a DEBUG-level message on the package-root logger.
info(msg, *args, **kwargs)
Log an INFO-level message on the package-root logger.
warning(msg, *args, **kwargs)
Log a WARNING-level message on the package-root logger.
error(msg, *args, **kwargs)
Log an ERROR-level message on the package-root logger.
critical(msg, *args, **kwargs)
Log a CRITICAL-level message on the package-root logger.
exception(msg, *args, **kwargs)
Log an ERROR-level message with traceback on the package-root logger.
getLogger(logger_name)
Create or retrieve a child logger under easyscience.
The returned logger is left at logging.NOTSET so it inherits
level and handler configuration from the package-root logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger_name
|
str
|
Logger name. Usually |
required |
Returns:
| Type | Description |
|---|---|
logging.Logger
|
A child logger whose name is |
at_level(level)
Context manager that temporarily sets the package-root logger to level, restoring the previous level on exit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int | str
|
Temporary level for the package-root logger — e.g.
|
required |
Yields:
| Type | Description |
|---|---|
None
|
Control is handed back to the |
Examples:
Setting the log-level only within the context:
with global_object.log.at_level(logging.ERROR):
fitter.fit(x, y, weights) # no core messages below ERROR
suspend()
Suppress all core log output (set level to CRITICAL+1).
resume()
Restore the level captured by the most recent suspend call.
map
Classes:
| Name | Description |
|---|---|
Map |
|
Classes
Map()
Methods:
| Name | Description |
|---|---|
vertices |
Returns the vertices of a map. |
edges |
Returns the edges of a map. |
is_known |
Check if a vertex is known in the map. |
find_isolated_vertices |
Returns a list of isolated vertices. |
find_path |
Find a path from start_vertex to end_vertex in map. |
find_all_paths |
Find all paths from start_vertex to end_vertex in map. |
reverse_route |
In this case we have an object and want to know the connections |
is_connected |
Determines if the map is connected. |
Functions
vertices()
Returns the vertices of a map.
Uses a retry loop to handle RuntimeError that can occur when the WeakValueDictionary is modified during iteration (e.g., by garbage collection).
edges()
Returns the edges of a map.
is_known(vertex)
Check if a vertex is known in the map.
All objects should have a 'unique_name' attribute.
__generate_edges()
A static method generating the edges of the map.
Edges are represented as sets with one (a loop back to the vertex) or two vertices
find_isolated_vertices()
Returns a list of isolated vertices.
find_path(start_vertex, end_vertex, path=[])
Find a path from start_vertex to end_vertex in map.
find_all_paths(start_vertex, end_vertex, path=[])
Find all paths from start_vertex to end_vertex in map.
reverse_route(end_vertex, start_vertex=None)
In this case we have an object and want to know the connections to get to another in reverse.
We might not know the start_object. In which case we follow the shortest path to a base vertex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
end_vertex
|
str
|
Final vertex in the path. |
required |
start_vertex
|
Optional[str]
|
Starting vertex. If omitted, the shortest reverse route is chosen automatically. |
None
|
Returns:
| Type | Description |
|---|---|
List
|
Reverse path from |
is_connected(vertices_encountered=None, start_vertex=None)
Determines if the map is connected.
undo_redo
Classes:
| Name | Description |
|---|---|
UndoCommand |
The Command interface pattern. |
NotarizedDict |
A simple dict drop in for EasyScience group classes. |
CommandHolder |
A holder for one or more commands which are added to the stack. |
UndoStack |
Implement a version of QUndoStack without the QT. |
PropertyStack |
Stack operator for when a property setter is wrapped. |
Functions:
| Name | Description |
|---|---|
property_stack |
Decorate a |
Classes
UndoCommand(obj)
The Command interface pattern.
Methods:
| Name | Description |
|---|---|
undo |
Undo implementation which should be overwritten. |
redo |
Redo implementation which should be overwritten. |
Functions
undo()
abstractmethod
Undo implementation which should be overwritten.
redo()
abstractmethod
Redo implementation which should be overwritten.
NotarizedDict(**kwargs)
A simple dict drop in for EasyScience group classes.
This is used as it wraps the get/set methods
CommandHolder(text=None)
A holder for one or more commands which are added to the stack.
UndoStack(max_history=None)
Implement a version of QUndoStack without the QT.
Methods:
| Name | Description |
|---|---|
push |
Add a command to the history stack. |
pop |
!! WARNING - TO BE USED WITH EXTREME CAUTION !! !! THIS IS |
clear |
Remove any commands on the stack and reset the state. |
undo |
Undo the last change to the stack. |
redo |
Redo the last |
beginMacro |
Start a bulk update i.e. multiple commands under one undo/redo |
endMacro |
End a bulk update i.e. multiple commands under one undo/redo |
canUndo |
Can the last command be undone? |
canRedo |
Can we redo a command? |
redoText |
Text associated with a redo item. |
undoText |
Text associated with a undo item. |
Functions
push(command)
Add a command to the history stack.
pop()
!! WARNING - TO BE USED WITH EXTREME CAUTION !! !! THIS IS PROBABLY NOT THE FN YOU'RE LOOKING FOR, IT CAN BREAK A LOT OF STUFF !! Sometimes you really don't want the last command. Remove it from the stack
Returns:
| Type | Description |
|---|---|
T_
|
None. |
clear()
Remove any commands on the stack and reset the state.
undo()
Undo the last change to the stack.
redo()
Redo the last undo command on the stack.
beginMacro(text)
Start a bulk update i.e. multiple commands under one undo/redo command.
endMacro()
End a bulk update i.e. multiple commands under one undo/redo command.
canUndo()
Can the last command be undone?
canRedo()
Can we redo a command?
redoText()
Text associated with a redo item.
undoText()
Text associated with a undo item.
PropertyStack(parent, func, old_value, new_value, text=None)
Stack operator for when a property setter is wrapped.
Functions
property_stack(arg, begin_macro=False)
Decorate a property setter with undo/redo functionality This
decorator can be used as:
@property_stack def func() ....
or
@property_stack("This is the undo/redo text) def func() ....
In the latter case the argument is a string which might be evaluated. The possible markups for this string are;
obj - The thing being operated on func - The function being
called name - The name of the function being called.
old_value - The pre-set value new_value - The post-set value
An example would be Function {name}: Set from {old_value} to
{new_value}