pystencils.types.create_type

Contents

pystencils.types.create_type#

pystencils.types.create_type(type_spec)#

Create a pystencils type object from a variety of specifications.

This function converts several possible representations of data types to an instance of PsType. The type_spec argument can be any of the following:

  • Strings (str): will be parsed as common C types, throwing an exception if that fails. Custom types must be created explicitly using PsCustomType.

  • Python builtin data types (instances of type): Attempts to interpret Python numeric types like so:
    • int becomes a signed 64-bit integer

    • float becomes a double-precision IEEE-754 float

    • No others are supported at the moment

  • Supported Numpy scalar data types (see https://numpy.org/doc/stable/reference/arrays.scalars.html) are converted to pystencils scalar data types

  • Instances of numpy.dtype: Attempt to interpret scalar types like above, and structured types as structs.

  • Instances of PsType will be returned as they are

Parameters:

type_spec (str | type | dtype | PsType) – The data type, in one of the above formats

Return type:

PsType