Miscellaneous
The kyupy package itself contains a miscellaneous utility functions.
In addition, it defines a numba and a cuda objects that point to the actual packages
if they are available and otherwise point to mocks.
- kyupy.popcount(a)
Returns the number of 1-bits in a given packed numpy array of type
uint8.
- kyupy.readtext(file)
Reads and returns the text in a given file. Transparently decompresses *.gz files.
- kyupy.hr_sci(value)
Formats a value in a human-readible scientific notation.
- kyupy.hr_bytes(nbytes)
Formats a given number of bytes for human readability.
- kyupy.eng(number)
Formats a given number using engineering notation.
- kyupy.hr_time(seconds)
Formats a given time interval for human readability.
- kyupy.batchrange(nitems, maxsize)
A simple generator that produces offsets and sizes for batch-loops.
- class kyupy.Log
A very simple logger that formats the messages with the number of seconds since program start.
- logfile
When set to a file handle, log messages are written to it instead to standard output.
- info(message)
Log an informational message.
- warn(message)
Log a warning message.
- error(message)
Log an error message.
- range(*args)
A generator that operates just like the
range()built-in, and also occasionally logs the progress and compute time estimates.
- kyupy.log = <kyupy.Log object>
The standard logger instance.
- kyupy.numba = <kyupy.MockNumba object>
If Numba is available on the system, it is the actual
numbapackage. Otherwise, it simply defines annjitdecorator that does nothing.
- kyupy.cuda = <kyupy.MockCuda object>
If Numba is installed and Cuda GPUs are available, it is the actual
numba.cudapackage. Otherwise, it is an object that defines basic methods and decorators so that cuda-code can still run in the Python interpreter.