_utils

Attributes

Strategy

Queue

SpatialSearch

ResponsibilityStyle

Exceptions

ReXError

Common base class for all non-exit exceptions.

ReXTomlError

Common base class for all non-exit exceptions.

ReXPathError

Common base class for all non-exit exceptions.

ReXScriptError

Common base class for all non-exit exceptions.

ReXDataError

Common base class for all non-exit exceptions.

ReXMapError

Common base class for all non-exit exceptions.

Classes

ReXPositions

Functions

update_mask_shape(batch_size, mask_shape)

try_rounding(n, rounding)

find_required_prediction(target, threshold, ...[, ...])

find_complete_prediction(target, target_confidence, ...)

match_resposnibility_style(s)

try_detach(t)

one_d_permute(tensor)

powerset(r[, reverse])

clause_area(clause, areas)

xlogx(ps)

_xlogx(p)

add_boundaries(img, segs[, colour])

get_device(gpu)

get_map_locations(map[, reverse])

set_boolean_mask_value(tensor, mode, order, coords[, val])

ff(obj, fmt)

Like format(obj, fmt), but returns the string 'None' if obj is None.

version()

Module Contents

_utils.Strategy
_utils.Queue
_utils.SpatialSearch
_utils.ResponsibilityStyle
_utils.update_mask_shape(batch_size, mask_shape)
Parameters:

batch_size (int)

Return type:

Tuple[int]

class _utils.ReXPositions(sufficient_position=None, contrastive_position=None, sufficiency_found=False, current_max_necessity=0.0)
sufficient_position = None
contrastive_position = None
sufficiency_found = False
current_max_necessity = 0.0
__repr__()
Return type:

str

is_empty()
_utils.try_rounding(n, rounding)
Parameters:

rounding (int | None)

Return type:

float

_utils.find_required_prediction(target, threshold, insertion_predictions, contrastive_completeness_threshold=0.0, deletion_predictions=None, rounding=None, sufficiency_found=False)
Parameters:
  • target (int)

  • threshold (float)

  • insertion_predictions (List[rex_xai.responsibility.prediction.Prediction])

  • contrastive_completeness_threshold (float)

  • deletion_predictions (List[rex_xai.responsibility.prediction.Prediction] | None)

_utils.find_complete_prediction(target, target_confidence, insertion_predictions, rounding=2)
Parameters:
  • target (int)

  • insertion_predictions (List[rex_xai.responsibility.prediction.Prediction])

_utils.match_resposnibility_style(s)
Parameters:

s (str)

Return type:

ResponsibilityStyle

_utils.try_detach(t)
Return type:

numpy.ndarray

_utils.one_d_permute(tensor)
_utils.powerset(r, reverse=True)
_utils.clause_area(clause, areas)
Parameters:

areas (Dict)

Return type:

int

exception _utils.ReXError

Bases: Exception

Common base class for all non-exit exceptions.

exception _utils.ReXTomlError(message)

Bases: ReXError

Common base class for all non-exit exceptions.

message
__str__()

Return str(self).

Return type:

str

exception _utils.ReXPathError(message)

Bases: ReXError

Common base class for all non-exit exceptions.

message
__str__()

Return str(self).

Return type:

str

exception _utils.ReXScriptError(message)

Bases: ReXError

Common base class for all non-exit exceptions.

message
__str__()

Return str(self).

Return type:

str

exception _utils.ReXDataError(message)

Bases: ReXError

Common base class for all non-exit exceptions.

message
__str__()

Return str(self).

Return type:

str

exception _utils.ReXMapError(message)

Bases: ReXError

Common base class for all non-exit exceptions.

message
__str__()

Return str(self).

Return type:

str

_utils.xlogx(ps)
_utils._xlogx(p)
_utils.add_boundaries(img, segs, colour=None)
Parameters:
  • img (Union[numpy.typing.NDArray, torch.Tensor])

  • segs (numpy.typing.NDArray)

Return type:

numpy.typing.NDArray

_utils.get_device(gpu)
Parameters:

gpu (bool)

_utils.get_map_locations(map, reverse=True)
_utils.set_boolean_mask_value(tensor, mode, order, coords, val=True)
Parameters:
  • coords (Union[rex_xai.mutants.box.Box, Tuple[numpy.typing.NDArray, numpy.typing.NDArray]])

  • val (bool)

_utils.ff(obj, fmt)

Like format(obj, fmt), but returns the string ‘None’ if obj is None. See the help for format() to see acceptable values for fmt.

_utils.version()