vispy.util.fetching module#

Data downloading and reading functions

class vispy.util.fetching.ProgressBar(max_value, initial_value=0, mesg='', max_chars=40, progress_character='.', spinner=False)#

Bases: object

Class for generating a command-line progressbar

Parameters:
max_valueint

Maximum value of process (e.g. number of samples to process, bytes to download, etc.).

initial_valueint

Initial value of process, useful when resuming process from a specific value, defaults to 0.

mesgstr

Message to include at end of progress bar.

max_charsint

Number of characters to use for progress bar (be sure to save some room for the message and % complete as well).

progress_characterchar

Character in the progress bar that indicates the portion completed.

spinnerbool

Show a spinner. Useful for long-running processes that may not increment the progress bar very often. This provides the user with feedback that the progress has not stalled.

spinner_symbols = ['|', '/', '-', '\\']#
template = '\r[{0}{1}] {2:.05f} {3} {4}   '#
update(cur_value, mesg=None)#

Update progressbar with current value of process

Parameters:
cur_valuenumber

Current value of process. Should be <= max_value (but this is not enforced). The percent of the progressbar will be computed as (cur_value / max_value) * 100

mesgstr

Message to display to the right of the progressbar. If None, the last message provided will be used. To clear the current message, pass a null string, ‘’.

update_with_increment_value(increment_value, mesg=None)#

Update progressbar with the value of the increment instead of the current value of process as in update()

Parameters:
increment_valueint

Value of the increment of process. The percent of the progressbar will be computed as (self.cur_value + increment_value / max_value) * 100

mesgstr

Message to display to the right of the progressbar. If None, the last message provided will be used. To clear the current message, pass a null string, ‘’.

vispy.util.fetching.load_data_file(fname, directory=None, force_download=False)#

Get a standard vispy demo data file

Parameters:
fnamestr

The filename on the remote demo-data repository to download, e.g. 'molecular_viewer/micelle.npy'. These correspond to paths on https://github.com/vispy/demo-data/.

directorystr | None

Directory to use to save the file. By default, the vispy configuration directory is used.

force_downloadbool | str

If True, the file will be downloaded even if a local copy exists (and this copy will be overwritten). Can also be a YYYY-MM-DD date to ensure a file is up-to-date (modified date of a file on disk, if present, is checked).

Returns:
fnamestr

The path to the file on the local system.

vispy.util.fetching.sizeof_fmt(num)#

Turn number of bytes into human-readable str