subjac.py#

Subjacobian classes.

Subjacobian classes are used to store the subjacobian information for a given variable pair. They are used to store the subjacobian in a variety of formats, including dense, sparse, and OpenMDAO’s internal COO format.

class openmdao.jacobians.subjac.COOSubjac(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Bases: SparseSubjac

Sparse subjacobian in COO format.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

__init__(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)

Initialize the subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. If not None, this is a subjac in the dr/do matrix of a SplitJacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

as_coo_info(full=False, randgen=None)[source]

Get the subjac as COO data.

Parameters:
fullbool

Whether to offset the row and column indices by the row and column slice start so the rows and columns will then represent the rows and columns of the full jacobian.

randgenRandomNumberGenerator or None

Random number generator.

Returns:
tuple

(data, rows, cols).

get_as_coo_data(randgen=None)

Get the subjac as data from a COO matrix.

Parameters:
randgenRandomNumberGenerator or None

Random number generator.

Returns:
ndarray

Subjac data.

get_coo_data_size()

Get the size the subjacobian would be if flattened.

Returns:
int

Size of the subjacobian in COO format.

static get_instance_metadata(pattern_meta, prev_inst_meta, shape, system, key)

Get the instance metadata for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

prev_inst_metadict

Previous instance metadata, if any.

shapetuple

Shape of the subjacobian.

systemSystem

The system containing the subjac.

keystr

The (of, wrt) key indicating which subjac is being updated.

Returns:
dict

Instance metadata.

get_rand_val(randgen)[source]

Get the value of the subjacobian.

Parameters:
randgenRandomNumberGenerator

Random number generator.

Returns:
coo_matrix

Subjacobian value.

static get_subjac_class(pattern_meta)

Get the subjacobian class for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

Returns:
Subjac

The subjacobian class.

get_val()

Get the value of the subjacobian.

Returns:
ndarray

Subjac data.

set_col(icol, column, uncovered_threshold=None)[source]

Set a column of the subjacobian.

Parameters:
icolint

Column index to set.

columnndarray

Column to set.

uncovered_thresholdfloat or None

Threshold for uncovered elements. Only used in _CheckingJacobian.

set_dtype(dtype)[source]

Set the dtype of the subjacobian.

Parameters:
dtypedtype

The type to set the subjacobian to.

set_val(val)

Set the value of the subjacobian.

Parameters:
valndarray

Value to set the subjacobian to.

todense()

Return the subjacobian as a dense array.

Returns:
ndarray

Subjacobian as a dense array.

class openmdao.jacobians.subjac.CSCSubjac(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Bases: SparseSubjac

Sparse subjacobian in CSC format.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

__init__(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)

Initialize the subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. If not None, this is a subjac in the dr/do matrix of a SplitJacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

as_coo_info(full=False, randgen=None)

Get the subjac as COO data.

Parameters:
fullbool

Whether to offset the row and column indices by the row and column slice start so the rows and columns will then represent the rows and columns of the full jacobian.

randgenRandomNumberGenerator or None

Random number generator.

Returns:
tuple

(data, rows, cols).

get_as_coo_data(randgen=None)

Get the subjac as data from a COO matrix.

Parameters:
randgenRandomNumberGenerator or None

Random number generator.

Returns:
ndarray

Subjac data.

get_coo_data_size()

Get the size the subjacobian would be if flattened.

Returns:
int

Size of the subjacobian in COO format.

static get_instance_metadata(pattern_meta, prev_inst_meta, shape, system, key)

Get the instance metadata for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

prev_inst_metadict

Previous instance metadata, if any.

shapetuple

Shape of the subjacobian.

systemSystem

The system containing the subjac.

keystr

The (of, wrt) key indicating which subjac is being updated.

Returns:
dict

Instance metadata.

get_rand_val(randgen)[source]

Get the value of the subjacobian.

Parameters:
randgenRandomNumberGenerator

Random number generator.

Returns:
csc_matrix

Subjacobian value.

static get_subjac_class(pattern_meta)

Get the subjacobian class for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

Returns:
Subjac

The subjacobian class.

get_val()

Get the value of the subjacobian.

Returns:
ndarray

Subjac data.

set_col(icol, column, uncovered_threshold=None)[source]

Set a column of the subjacobian.

Parameters:
icolint

Column index to set.

columnndarray

Column to set.

uncovered_thresholdfloat or None

Threshold for uncovered elements. Only used in _CheckingJacobian.

set_dtype(dtype)

Set the dtype of the subjacobian.

Parameters:
dtypedtype

The type to set the subjacobian to.

set_val(val)

Set the value of the subjacobian.

Parameters:
valndarray

Value to set the subjacobian to.

todense()

Return the subjacobian as a dense array.

Returns:
ndarray

Subjacobian as a dense array.

class openmdao.jacobians.subjac.CSRSubjac(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Bases: SparseSubjac

Sparse subjacobian in CSR format.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

__init__(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)

Initialize the subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. If not None, this is a subjac in the dr/do matrix of a SplitJacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

as_coo_info(full=False, randgen=None)

Get the subjac as COO data.

Parameters:
fullbool

Whether to offset the row and column indices by the row and column slice start so the rows and columns will then represent the rows and columns of the full jacobian.

randgenRandomNumberGenerator or None

Random number generator.

Returns:
tuple

(data, rows, cols).

get_as_coo_data(randgen=None)

Get the subjac as data from a COO matrix.

Parameters:
randgenRandomNumberGenerator or None

Random number generator.

Returns:
ndarray

Subjac data.

get_coo_data_size()

Get the size the subjacobian would be if flattened.

Returns:
int

Size of the subjacobian in COO format.

static get_instance_metadata(pattern_meta, prev_inst_meta, shape, system, key)

Get the instance metadata for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

prev_inst_metadict

Previous instance metadata, if any.

shapetuple

Shape of the subjacobian.

systemSystem

The system containing the subjac.

keystr

The (of, wrt) key indicating which subjac is being updated.

Returns:
dict

Instance metadata.

get_rand_val(randgen)[source]

Get the value of the subjacobian.

Parameters:
randgenRandomNumberGenerator

Random number generator.

Returns:
csr_matrix

Subjacobian value.

static get_subjac_class(pattern_meta)

Get the subjacobian class for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

Returns:
Subjac

The subjacobian class.

get_val()

Get the value of the subjacobian.

Returns:
ndarray

Subjac data.

set_col(icol, column, uncovered_threshold=None)[source]

Set a column of the subjacobian.

Parameters:
icolint

Column index to set.

columnndarray

Column to set.

uncovered_thresholdfloat or None

Threshold for uncovered elements. Only used in _CheckingJacobian.

set_dtype(dtype)

Set the dtype of the subjacobian.

Parameters:
dtypedtype

The type to set the subjacobian to.

set_val(val)

Set the value of the subjacobian.

Parameters:
valndarray

Value to set the subjacobian to.

todense()

Return the subjacobian as a dense array.

Returns:
ndarray

Subjacobian as a dense array.

class openmdao.jacobians.subjac.DenseSubjac(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Bases: Subjac

Dense subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

__init__(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)

Initialize the subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. If not None, this is a subjac in the dr/do matrix of a SplitJacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

as_coo_info(full=False, randgen=None)[source]

Get the subjac as COO data.

This is here for completeness, but it shouldn’t normally be called.

Parameters:
fullbool

Whether to offset the row and column indices by the row and column slice start so the rows and columns will then represent the rows and columns of the full jacobian.

randgenRandomNumberGenerator or None

Random number generator.

Returns:
tuple

(data, rows, cols).

get_as_coo_data(randgen=None)[source]

Get the subjac as data from a COO matrix.

Parameters:
randgenRandomNumberGenerator or None

Random number generator.

Returns:
ndarray

Subjac data.

get_coo_data_size()[source]

Get the size of the subjacobian in COO format.

Returns:
int

Size of the subjacobian in COO format.

static get_instance_metadata(pattern_meta, prev_inst_meta, shape, system, key)

Get the instance metadata for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

prev_inst_metadict

Previous instance metadata, if any.

shapetuple

Shape of the subjacobian.

systemSystem

The system containing the subjac.

keystr

The (of, wrt) key indicating which subjac is being updated.

Returns:
dict

Instance metadata.

get_rand_val(randgen)[source]

Get the value of the subjacobian.

If randgen is not None then we’re computing sparsity and we return a matrix of random values based on our ‘sparsity’ metadata.

Parameters:
randgenRandomNumberGenerator

Random number generator.

Returns:
ndarray

Subjacobian value.

static get_subjac_class(pattern_meta)

Get the subjacobian class for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

Returns:
Subjac

The subjacobian class.

get_val()

Get the value of the subjacobian.

Returns:
ndarray

Subjac data.

set_col(icol, column, uncovered_threshold=None)[source]

Set a column of the subjacobian.

Parameters:
icolint

Column index to set.

columnndarray

Column to set.

uncovered_thresholdfloat or None

Threshold for uncovered elements. Only used in _CheckingJacobian for sparse subjacs.

set_dtype(dtype)

Set the dtype of the subjacobian.

Parameters:
dtypedtype

The type to set the subjacobian to.

set_val(val)[source]

Set the value of the subjacobian.

Parameters:
valndarray

Value to set the subjacobian to.

todense()[source]

Return the subjacobian as a dense array.

Returns:
ndarray

Subjacobian as a dense array.

class openmdao.jacobians.subjac.DiagonalSubjac(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Bases: SparseSubjac

Diagonal subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

__init__(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)

Initialize the subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. If not None, this is a subjac in the dr/do matrix of a SplitJacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

as_coo_info(full=False, randgen=None)[source]

Get the subjac as COO data, rows, and cols.

Parameters:
fullbool

Whether to offset the row and column indices by the row and column slice start so the rows and columns will then represent the rows and columns of the full jacobian.

randgenRandomNumberGenerator or None

Random number generator.

Returns:
tuple

(data, rows, cols).

get_as_coo_data(randgen=None)[source]

Get the subjac as COO data.

Parameters:
randgenRandomNumberGenerator or None

Random number generator.

Returns:
ndarray

Subjacobian data.

get_coo_data_size()[source]

Get the size the subjacobian would be if flattened.

Returns:
int

Size of the subjacobian in COO format.

static get_instance_metadata(pattern_meta, prev_inst_meta, shape, system, key)

Get the instance metadata for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

prev_inst_metadict

Previous instance metadata, if any.

shapetuple

Shape of the subjacobian.

systemSystem

The system containing the subjac.

keystr

The (of, wrt) key indicating which subjac is being updated.

Returns:
dict

Instance metadata.

get_rand_val(randgen)[source]

Get the value of the subjacobian.

Parameters:
randgenRandomNumberGenerator

Random number generator.

Returns:
ndarray

Subjac data.

static get_subjac_class(pattern_meta)

Get the subjacobian class for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

Returns:
Subjac

The subjacobian class.

get_val()

Get the value of the subjacobian.

Returns:
ndarray

Subjac data.

set_col(icol, column, uncovered_threshold=None)[source]

Set a column of the subjacobian.

Parameters:
icolint

Column index to set.

columnndarray

Column to set.

uncovered_thresholdfloat or None

Threshold for uncovered elements. Only used in _CheckingJacobian.

set_dtype(dtype)[source]

Set the dtype of the subjacobian.

Parameters:
dtypedtype

The type to set the subjacobian to.

set_val(val)[source]

Set the value of the subjacobian.

Parameters:
valndarray

Value to set the subjacobian to.

todense()[source]

Return the subjacobian as a dense array.

Returns:
ndarray

Subjacobian as a dense array.

class openmdao.jacobians.subjac.OMCOOSubjac(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Bases: COOSubjac

Sparse subjacobian in OpenMDAO’s internal COO format.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

Attributes:
rowsndarray

Row indices of the subjacobian.

colsndarray

Column indices of the subjacobian.

__init__(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Initialize the subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

as_coo_info(full=False, randgen=None)[source]

Get the subjac as COO data.

Parameters:
fullbool

Whether to offset the row and column indices by the row and column slice start so the rows and columns will then represent the rows and columns of the full jacobian.

randgenRandomNumberGenerator or None

Random number generator.

Returns:
tuple

(data, rows, cols).

get_as_coo_data(randgen=None)

Get the subjac as data from a COO matrix.

Parameters:
randgenRandomNumberGenerator or None

Random number generator.

Returns:
ndarray

Subjac data.

get_coo_data_size()[source]

Get the size the subjacobian would be if flattened.

Returns:
int

Size of the subjacobian in COO format.

static get_instance_metadata(pattern_meta, prev_inst_meta, shape, system, key)

Get the instance metadata for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

prev_inst_metadict

Previous instance metadata, if any.

shapetuple

Shape of the subjacobian.

systemSystem

The system containing the subjac.

keystr

The (of, wrt) key indicating which subjac is being updated.

Returns:
dict

Instance metadata.

get_rand_val(randgen)[source]

Get the value of the subjacobian.

Parameters:
randgenRandomNumberGenerator

Random number generator.

Returns:
coo_matrix

Subjacobian value.

static get_subjac_class(pattern_meta)

Get the subjacobian class for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

Returns:
Subjac

The subjacobian class.

get_val()

Get the value of the subjacobian.

Returns:
ndarray

Subjac data.

set_col(icol, column, uncovered_threshold=None)[source]

Set a column of the subjacobian.

Parameters:
icolint

Column index to set.

columnndarray

Column to set.

uncovered_thresholdfloat or None

Threshold for uncovered elements. Only used in _CheckingJacobian.

set_dtype(dtype)

Set the dtype of the subjacobian.

Parameters:
dtypedtype

The type to set the subjacobian to.

set_val(val)[source]

Set the value of the subjacobian.

Parameters:
valndarray

Value to set the subjacobian to.

todense()[source]

Return the subjacobian as a dense array.

Returns:
ndarray

Subjacobian as a dense array.

class openmdao.jacobians.subjac.SparseSubjac(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Bases: Subjac

Sparse subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices. Note that this is the slice into either the input or output vector, not the absolute indices with respect to the full jacobian columns.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. None unless the jacobian is split into a square and non-square part where the square part has outputs as rows and columns, requiring a mapping of inputs to their source outputs via the src_indices array.

factorfloat or None

Unit conversion factor for the subjacobian if, as with src_indices, we have a square part of the jacobian requiring a mapping of inputs to their source outputs for the jacobian columns where the input and output have different units.

srcstr or None

Source name for the subjacobian.

__init__(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)

Initialize the subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. If not None, this is a subjac in the dr/do matrix of a SplitJacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

as_coo_info(full=False, randgen=None)[source]

Get the subjac as COO data.

Parameters:
fullbool

Whether to offset the row and column indices by the row and column slice start so the rows and columns will then represent the rows and columns of the full jacobian.

randgenRandomNumberGenerator or None

Random number generator.

Returns:
tuple

(data, rows, cols).

get_as_coo_data(randgen=None)[source]

Get the subjac as data from a COO matrix.

Parameters:
randgenRandomNumberGenerator or None

Random number generator.

Returns:
ndarray

Subjac data.

get_coo_data_size()[source]

Get the size the subjacobian would be if flattened.

Returns:
int

Size of the subjacobian in COO format.

static get_instance_metadata(pattern_meta, prev_inst_meta, shape, system, key)

Get the instance metadata for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

prev_inst_metadict

Previous instance metadata, if any.

shapetuple

Shape of the subjacobian.

systemSystem

The system containing the subjac.

keystr

The (of, wrt) key indicating which subjac is being updated.

Returns:
dict

Instance metadata.

static get_subjac_class(pattern_meta)

Get the subjacobian class for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

Returns:
Subjac

The subjacobian class.

get_val()

Get the value of the subjacobian.

Returns:
ndarray

Subjac data.

set_dtype(dtype)[source]

Set the dtype of the subjacobian.

Parameters:
dtypedtype

The type to set the subjacobian to.

set_val(val)[source]

Set the value of the subjacobian.

Parameters:
valndarray

Value to set the subjacobian to.

todense()[source]

Return the subjacobian as a dense array.

Returns:
ndarray

Subjacobian as a dense array.

class openmdao.jacobians.subjac.Subjac(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Bases: object

Base class for subjacobians.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices. Note that this is the slice into either the input or output vector, not the absolute indices with respect to the full jacobian columns.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. None unless the jacobian is split into a square and non-square part where the square part has outputs as rows and columns, requiring a mapping of inputs to their source outputs via the src_indices array.

factorfloat or None

Unit conversion factor for the subjacobian if, as with src_indices, we have a square part of the jacobian requiring a mapping of inputs to their source outputs for the jacobian columns where the input and output have different units.

srcstr or None

Source name for the subjacobian.

Attributes:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

densebool

Whether the subjacobian is dense.

nrowsint

Number of rows in the subjacobian.

ncolsint

Number of columns in the subjacobian.

parent_ncolsint

Number of columns this subjacobian occupies in the parent jacobian. If this subjac has src_indices then parent_ncols may differ from ncols.

_in_viewndarray or None

View of this subjac’s slice of the input vector.

_out_viewndarray or None

View of this subjac’s slice of the output vector.

_res_viewndarray or None

View of this subjac’s slice of the residual vector.

__init__(key, info, row_slice, col_slice, wrt_is_input, dtype, src_indices=None, factor=None, src=None)[source]

Initialize the subjacobian.

Parameters:
keytuple

The (of, wrt) key.

infodict

Metadata for the subjacobian.

row_sliceslice

Slice of the row indices.

col_sliceslice

Slice of the column indices.

wrt_is_inputbool

Whether the wrt variable is an input.

dtypedtype

The dtype of the subjacobian.

src_indicesarray or None

Source indices for the subjacobian. If not None, this is a subjac in the dr/do matrix of a SplitJacobian.

factorfloat or None

Unit conversion factor for the subjacobian.

srcstr or None

Source name for the subjacobian.

static get_instance_metadata(pattern_meta, prev_inst_meta, shape, system, key)[source]

Get the instance metadata for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

prev_inst_metadict

Previous instance metadata, if any.

shapetuple

Shape of the subjacobian.

systemSystem

The system containing the subjac.

keystr

The (of, wrt) key indicating which subjac is being updated.

Returns:
dict

Instance metadata.

static get_subjac_class(pattern_meta)[source]

Get the subjacobian class for the given pattern metadata.

Parameters:
pattern_metadict

Pattern metadata.

Returns:
Subjac

The subjacobian class.

get_val()[source]

Get the value of the subjacobian.

Returns:
ndarray

Subjac data.

set_dtype(dtype)[source]

Set the dtype of the subjacobian.

Parameters:
dtypedtype

The type to set the subjacobian to.