Start debugger on line where it is called, roughly equivalent to:
import pdb; pdb.set_trace()
First, this function tries to start an IPython-enabled debugger using the IPython API.
When this fails, the plain old pdb is used instead.
With IPython, one can say in what frame the debugger can stop.
Get an item from Container - a wrapper around Container.__getitem__() with defaults and custom error message.
Parameters: | ii : int or str
default : any, optional
msg_if_none : str, optional
|
---|
Factory class providing output (print) functions. All SfePy printing should be accomplished by this class.
Examples
>>> from sfepy.base.base import Output
>>> output = Output('sfepy:')
>>> output(1, 2, 3, 'hello')
sfepy: 1 2 3 hello
>>> output.prefix = 'my_cool_app:'
>>> output(1, 2, 3, 'hello')
my_cool_app: 1 2 3 hello
Set the output mode.
If quiet is True, no messages are printed to screen. If simultaneously filename is not None, the messages are logged into the specified file.
If quiet is False, more combinations are possible. If filename is None, output is to screen only, otherwise it is to the specified file. Moreover, if combined is True, both the ways are used.
Parameters: | filename : str or file object
quiet : bool
combined : bool
append : bool
|
---|
Try to cast val to Python float, and if this fails, to Python complex type.
Check if all names in names1 are in names2, otherwise raise IndexError with the provided message msg.
Configure the standard output() function using output_log_name and output_screen attributes of options.
Parameters: | options : Struct or dict
|
---|
Start debugger on line where it is called, roughly equivalent to:
import pdb; pdb.set_trace()
First, this function tries to start an IPython-enabled debugger using the IPython API.
When this fails, the plain old pdb is used instead.
With IPython, one can say in what frame the debugger can stop.
Convert a dictionary of nD arrays of the same shapes with non-negative integer keys to a single (n+1)D array.
Convert a dict instance to a Struct instance.
Replace substrings old with new in string values of dictionary str_dict. Both old and new can be lists of the same length - items in old are replaced by items in new with the same index.
Parameters: | str_dict : dict
old : str or list of str
new : str or list of str
recur : bool
|
---|---|
Returns: | new_dict : dict
|
Replace substrings old with new in items of tuple str_tuple. Non-string items are just copied to the new tuple.
Parameters: | str_tuple : tuple
old : str
new : str
recur : bool
|
---|---|
Returns: | new_tuple : tuple
|
Find subclasses of the given classes in the given context.
Examples
>>> solver_table = find_subclasses(vars().items(),
[LinearSolver, NonlinearSolver,
TimeSteppingSolver, EigenvalueSolver,
OptimizationSolver])
Get a calling function’s arguments.
Returns:
Import a file as a module. The module is explicitly reloaded to prevent undesirable interactions.
Invert a dictionary by making its values keys and vice versa.
Parameters: | d : dict
is_val_tuple : bool
unique : bool
|
---|---|
Returns: | di : dict
|
For each filename in filenames, load all subclasses of classes listed.
Time measurement utility.
Measures times of execution between subsequent calls using time.clock(). The time is printed if the msg argument is not None.
Examples
>>> times = []
>>> mark_time(times)
... do something
>>> mark_time(times, 'elapsed')
elapsed 0.1
... do something else
>>> mark_time(times, 'elapsed again')
elapsed again 0.05
>>> times
[0.10000000000000001, 0.050000000000000003]
Prints the line number and waits for a keypress.
If you press: “q” ............. it will call sys.exit() any other key ... it will continue execution of the program
This is useful for debugging.
Print Struct instances in a container, works recursively. Debugging utility function.
Utility function to remap state dict keys according to var_map.
Waits for a keypress.
If you press: “q” ............. it will call sys.exit() any other key ... it will continue execution of the program
This is useful for debugging. This function is called from pause().
Try import statements until one succeeds.
Parameters: | imports : list
fail_msg : str
|
---|---|
Returns: | locals : dict
|
Update dst dictionary recursively using items in src dictionary.
Parameters: | dst : dict
src : dict
tuples_too : bool
overwrite_by_none : bool
|
---|---|
Returns: | dst : dict
|