pymor.tools.io

Submodules

Package Contents

Classes

Deprecated

Decorator for marking functions as deprecated.

Functions

load_matrix

Load matrix from file.

save_matrix

Save matrix to file.

read_vtkfile

SafeTemporaryFileName

safe_temporary_filename

Cross~platform safe equivalent of re-opening a NamedTemporaryFile.

change_to_directory

Change current working directory to name for the scope of the context.

file_owned_by_current_user

Attributes

config

pymor.tools.io.load_matrix(path, key=None)[source]

Load matrix from file.

Parameters

path

Path to the file (str or pathlib.Path).

key

Key of the matrix (only for NPY, NPZ, and MATLAB files).

Returns

matrix

NumPy array of SciPy spmatrix.

Raises

IOError

If loading fails.

pymor.tools.io.save_matrix(path, matrix, key=None)[source]

Save matrix to file.

Parameters

path

Path to the file (str or pathlib.Path).

matrix

Matrix to save.

key

Key of the matrix (only for NPY, NPZ, and MATLAB files).

Raises

IOError

If saving fails.

pymor.tools.io.config[source]
class pymor.tools.io.Deprecated(alt='no alternative given')[source]

Decorator for marking functions as deprecated.

It will result in a warning being emitted when the function is used.

__call__(self, func)[source]
__get__(self, obj, ownerClass=None)[source]

Return a wrapper that binds self as a method of obj (!)

exception pymor.tools.io.IOLibsMissing(msg=None)[source]

Bases: ImportError

Import can’t find module, or can’t find name in module.

pymor.tools.io.read_vtkfile(*args, **kwargs)[source]
pymor.tools.io.SafeTemporaryFileName(name=None, parent_dir=None)[source]
pymor.tools.io.safe_temporary_filename(name=None, parent_dir=None)[source]

Cross~platform safe equivalent of re-opening a NamedTemporaryFile.

Creates an automatically cleaned up temporary directory with a single file therein.

Parameters

name

Filename component, defaults to ‘temp_file’.

dir

The parent dir of the new temporary directory. Defaults to tempfile.gettempdir().

pymor.tools.io.change_to_directory(name)[source]

Change current working directory to name for the scope of the context.

pymor.tools.io.file_owned_by_current_user(filename)[source]