otaf.exceptions package

Module contents

Custom exception classes for the OTAF project.

exception otaf.exceptions.ConflictingSurfaceDirectionsException(part_id1, surface_id1, part_id2, surface_id2)[source]

Bases: Exception

Exception raised for conflicting surface directions in cylinder interactions.

exception otaf.exceptions.CylindricalInterferenceGeometricException(part_id1, surface_id1, part_id2, surface_id2, radius1, radius2)[source]

Bases: Exception

Exception raised for geometric inconsistencies in cylindrical interactions.

exception otaf.exceptions.DuplicatePointError(point_name, surf_id, part_id, existing_point=None, origin=False, new_point_value=None, existing_point_value=None, exact_match=True)[source]

Bases: ValueError

Raised when a point name or its coordinates duplicate an existing point of the surface.

Parameters:
  • point_name (str) – Name of the new point.

  • surf_id (str) – ID of the surface.

  • part_id (str) – ID of the part.

  • existing_point (str, optional) – Name of the existing point with similar coordinates (exact_match=False).

  • origin (bool, optional) – Whether the point is the surface origin.

  • new_point_value (array_like, optional) – Coordinates of the new point, shown in the message.

  • existing_point_value (array_like, optional) – Coordinates of the existing point, shown in the message.

  • exact_match (bool, optional) – True when the name itself is duplicated, False when only the coordinates are.

exception otaf.exceptions.GeometricConditionError(condition_name)[source]

Bases: Exception

Raised when a geometric condition required by the modelling is not met.

Parameters:

condition_name (str) – Name of the condition.

exception otaf.exceptions.InconsistentContactConstraintsError(part_id1, surf_id1, constraints1, part_id2, surf_id2, constraints2)[source]

Bases: ValueError

Raised when the two surfaces of a contact carry different CONSTRAINTS_G.

The contact type is looked up from both entries, so they must be equal. A surface without the key counts as ["FLOATING"].

Parameters:
  • part_id1 (str) – First surface of the contact.

  • surf_id1 (str) – First surface of the contact.

  • constraints1 (list of str) – Its CONSTRAINTS_G (default included).

  • part_id2 (str) – Second surface of the contact.

  • surf_id2 (str) – Second surface of the contact.

  • constraints2 (list of str) – Its CONSTRAINTS_G (default included).

exception otaf.exceptions.InvalidAffineTransformException(matrix, message='Matrix is not a valid affine transformation matrix.')[source]

Bases: Exception

Exception raised when a matrix is not a valid affine transformation matrix.

matrix

The matrix that caused the exception.

Type:

np.ndarray

message

Explanation of the error.

Type:

str

exception otaf.exceptions.InvalidGlobalConstraintError(valid_constraints)[source]

Bases: ValueError

Raised when GLOBAL_CONSTRAINTS is not one of the available presets.

Parameters:

valid_constraints (iterable of str) – The accepted preset names.

exception otaf.exceptions.InvalidInteractionFormatError(interaction)[source]

Bases: ValueError

Raised when an INTERACTIONS entry does not match P<part><surface> (e.g. P2a).

Parameters:

interaction (str) – The offending interaction string.

exception otaf.exceptions.InvalidPartLabelError[source]

Bases: ValueError

Raised when a part label is not the string form of an integer.

exception otaf.exceptions.InvalidSurfaceDirectionError(surf_dir)[source]

Bases: ValueError

Raised when SURFACE_DIRECTION is not one of otaf.constants.SURFACE_DIRECTIONS.

Parameters:

surf_dir (str) – The offending direction.

exception otaf.exceptions.InvalidSurfaceLabelError[source]

Bases: ValueError

Raised when a surface label is not a lowercase alphabetical string.

exception otaf.exceptions.LabelPatternError[source]

Bases: ValueError

Raised when point labels do not match the expected pattern (capital letters followed by an integer).

exception otaf.exceptions.LabelPrefixError[source]

Bases: ValueError

Raised when the point labels of a surface do not share the same letter prefix.

exception otaf.exceptions.MissingKeyError(key, dictionary_name)[source]

Bases: KeyError

Raised when a required key is missing from an input dictionary.

Parameters:
  • key (str) – Name of the missing key.

  • dictionary_name (str) – Name of the dictionary that should contain it.

exception otaf.exceptions.MissingOriginPointError(part_id, surf_id)[source]

Bases: PointDictionaryError

Raised when the POINTS dictionary of a surface has no point for the surface origin.

Parameters:
  • part_id (str) – ID of the part.

  • surf_id (str) – ID of the surface.

exception otaf.exceptions.MissingSurfaceTypeKeyError(part_id, surf_id)[source]

Bases: KeyError

Raised when a surface has no TYPE key.

Parameters:
  • part_id (str) – ID of the part.

  • surf_id (str) – ID of the surface.

exception otaf.exceptions.NoAxialOverlapException(part_id1, surface_id1, part_id2, surface_id2)[source]

Bases: Exception

Exception raised when two interacting cylinders have no physical overlap along their axis.

exception otaf.exceptions.NoPlanarOverlapException(part_id1, surface_id1, part_id2, surface_id2)[source]

Bases: Exception

Exception raised when two interacting planes do not overlap once projected onto each other.

exception otaf.exceptions.NonConcentricCylindersException(part_id1, surface_id1, part_id2, surface_id2)[source]

Bases: Exception

Exception raised for cylinders that are not concentric.

exception otaf.exceptions.NonUniqueCoordinatesError(duplicates=None)[source]

Bases: ValueError

Raised when two points of a surface have the same coordinates.

Parameters:

duplicates (dict, optional) – Mapping from coordinates to the labels sharing them, shown in the message.

exception otaf.exceptions.NonUniqueLabelError(message)[source]

Bases: PointDictionaryError

Raised when point labels of a surface are not unique.

Parameters:

message (str) – Description of the problem.

exception otaf.exceptions.PartNotFoundError(part_id)[source]

Bases: ValueError

Raised when a part ID does not exist in the assembly data.

Parameters:

part_id (str) – The unknown part ID.

exception otaf.exceptions.PointDictionaryError(message)[source]

Bases: ValueError

Base class of the errors raised for an invalid POINTS dictionary.

Parameters:

message (str) – Description of the problem.

exception otaf.exceptions.PointsNotOnPlaneError(part_id, surf_id)[source]

Bases: Exception

Raised when the points given for a plane surface are not coplanar.

Parameters:
  • part_id (str) – ID of the part.

  • surf_id (str) – ID of the surface.

exception otaf.exceptions.SolverFailureWarning[source]

Bases: RuntimeWarning

Warns that the optimisation failed for some samples of a batch.

Their rows of the result are NaN; the scipy.optimize.milp status of every sample is available with return_status=True.

exception otaf.exceptions.SurfaceNotFoundError(surf_id, part_id)[source]

Bases: ValueError

Raised when a surface ID does not exist in a part.

Parameters:
  • surf_id (str) – The unknown surface ID.

  • part_id (str) – ID of the part searched.

exception otaf.exceptions.SystemDataValidationError(messages)[source]

Bases: ValueError

Raised when the assembly dictionary does not match the input schema.

Lists every problem found, each prefixed by its location in the dictionary (e.g. PARTS -> 1 -> a -> RADIUS).

Parameters:

messages (list of str) – One message per problem.

exception otaf.exceptions.UncoveredContactWarning[source]

Bases: UserWarning

Warns that a contact listed in INTERACTIONS is crossed by no compatibility loop.

Contact conditions are only written for the gaps that appear in the loops, so such a contact has no condition at all.

exception otaf.exceptions.UniqueLabelSuffixError[source]

Bases: ValueError

Raised when integer suffixes of point labels coincide once leading zeros are removed (A000 and A0).

exception otaf.exceptions.UnsupportedSurfaceTypeError(part_id, surf_id, surf_type)[source]

Bases: ValueError

Raised when a surface TYPE is not one of otaf.constants.SUPPORTED_SURFACE_TYPES.

"cone" and "sphere" are listed in otaf.constants.BASE_SURFACE_TYPES but have no deviation or gap model yet, so they are rejected too.

Parameters:
  • part_id (str) – ID of the part.

  • surf_id (str) – ID of the surface.

  • surf_type (str) – The unsupported type.

otaf.exceptions.timeout(seconds=10, error_message='Function call timed out')[source]

Limit the execution time of a function using a decorator.

Parameters:
  • seconds (int) – The number of seconds before the function is terminated with a timeout error.

  • error_message (str) – The message to include in the TimeoutError raised when the timeout occurs.