clip#

swordfish.function.clip()#

Clips X to specified range.

Parameters:
  • X (Constant) – A numeric or temporal scalar/vector/matrix/table, or a dictionary with numeric or temporal values.

  • Y (Constant) – A numeric or temporal scalar/vector/matrix/table indicating the lower bound for the clipping range.

  • Z (Constant) – A numeric or temporal scalar/vector/matrix/table indicating the upper bound for the clipping range.

Returns:

X’ of the same data type and form as X.

The following rules determine how X is clipped (If X is a dictionary, “element” indicates the dictionary value):

  • When Y and Z are scalars, the clipping range is [Y, Z]. Values outside this range are clipped to the nearest boundary.

    • Null Y or Z indicates no limit on the lower or upper bound.

    • If Y is greater than Z, all elements in X’areZ.

  • When Y and Z are vectors, matrices, or tables, each elementXi is clipped within the range [Yi, Zi]. Note: If any element in Y or Z is null, the corresponding element in X’ is also null.

  • When Y or Z is a scalar, and the other is a vector, matrix, or table, each element Xi is clipped within the range [Y,Zi] or [Yi,Z].

    • The scalar represents a fixed boundary for all elements in X, while vector/ matrix/table specify the boundary limits for Xi in the corresponding position.

    • If the scalar is null, no limit is set on the boundary. If any element in the vector, matrix or table is null, the corresponding element in X’ is also null.

    • If Y is greater than Z for a specific position, the corresponding element in X’ is set to Z.

If X is a matrix or table, the aforementioned calculations will be performed on each column.

Return type:

Constant