databpy 0.11.0
  • Home
  • Attributes
  • API
  • Changelog
  1. Attribute
  2. attribute.guess_atype_from_array
  • Function reference
  • Attribute
    • named_attribute
    • store_named_attribute
    • remove_named_attribute
    • list_attributes
    • AttributeDomains
    • AttributeTypes
    • AttributeArray
    • Attribute
    • attribute.guess_atype_from_array
  • Collections
    • create_collection
    • move_to_collection
  • Objects
    • create_object
    • create_mesh_object
    • create_curves_object
    • create_pointcloud_object
    • create_bob
    • evaluate_object
    • GeometrySet
    • BlenderObject
    • BlenderObjectAttribute
    • BlenderObjectBase
  • Errors
    • DatabpyError
    • NamedAttributeError
    • AttributeNotFoundError
    • AttributeMismatchError
    • LinkedObjectError
  • Utilities
    • require
    • require_data
    • mesh_data
    • curves_data
    • pointcloud_data
    • volume_data
    • active_scene
    • active_object
    • centre
    • lerp
  • Nodes (deprecated)
    • nodes.new_tree
    • nodes.swap_tree
    • nodes.custom_string_iswitch
    • nodes.append_from_blend
    • nodes.new_socket
    • nodes.tree_interface
    • nodes.input_socket
    • nodes.output_socket
    • nodes.socket_value
    • nodes.set_socket_value
    • nodes.MaintainConnections
    • nodes.DuplicatePrevention

On this page

  • attribute.guess_atype_from_array
    • Parameters
    • Returns
    • Raises
    • Examples
  1. Attribute
  2. attribute.guess_atype_from_array

attribute.guess_atype_from_array

attribute.guess_atype_from_array(array)

Infer the attribute type for an array from its shape and dtype.

  • (n,) or (n, 1): bool to BOOLEAN, int8 to INT8, other integers to INT, floats to FLOAT, and strings to STRING. Unsigned integers map to INT, as their values may not fit INT8.
  • (n, 2): int16 to INT16_2D, other integers to INT32_2D, and floats to FLOAT2.
  • (n, 3): any numeric dtype to FLOAT_VECTOR.
  • (n, 4): uint8 to BYTE_COLOR, and other numeric dtypes to FLOAT4. Before Blender 5.2, which has no FLOAT4, they map to FLOAT_COLOR.
  • (n, 4, 4): any numeric dtype to FLOAT4X4.

FLOAT_COLOR and QUATERNION are never inferred, and must be passed as atype.

Parameters

Name Type Description Default
array np.ndarray Input numpy array to analyze. required

Returns

Name Type Description
AttributeTypes The inferred attribute type enum value.

Raises

Name Type Description
TypeError If input is not a numpy array.
ValueError If the array has no dimensions, or no attribute type matches its shape and dtype.

Examples

>>> print(guess_atype_from_array(np.array([1.0, 2.0, 3.0], dtype=np.float32)))
AttributeTypes.FLOAT
>>> print(guess_atype_from_array(np.array([[1, 2], [3, 4]], dtype=np.int32)))
AttributeTypes.INT32_2D
>>> print(guess_atype_from_array(np.array([[255, 0, 0, 255]], dtype=np.uint8)))
AttributeTypes.BYTE_COLOR
Attribute
create_collection