12.11 The types module
The types module contains prototype objects for each of Pyxplot’s data types. Each may be called like a function to create a new object of the specified type:
types.boolean(...)
The types.boolean(...) prototype takes any of the following combinations of arguments:
none – returns false.
any object – returns false for zero, an empty string, a null object, or an empty data structure. Otherwise returns true.
types.color(...)
The types.color(...) prototype takes any of the following combinations of arguments:
types.date(...)
The types.date(...) prototype takes any of the following combinations of arguments:
types.dictionary(...)
The types.dictionary(...) prototype takes any of the following combinations of arguments:
types.exception(...)
The types.exception(...) prototype takes any of the following combinations of arguments:
types.fileHandle(...)
The types.fileHandle(...) prototype takes any of the following combinations of arguments:
types.function(...)
The types.function(...) prototype takes any of the following combinations of arguments:
types.instance(...)
The types.instance(...) prototype takes any of the following combinations of arguments:
types.list(...)
The types.list(...) prototype takes any of the following combinations of arguments:
none – returns an empty list.
a list – returns a deep copy of the supplied list.
a vector – returns a list representation of the supplied vector.
a list of arguments returns its arguments as a list.
types.matrix(...)
The types.matrix(...) prototype takes any of the following combinations of arguments:
none – returns a one-by-one zero matrix.
a pair of numbers – returns a zero matrix of the specified dimensions. The first number is the number of rows, and the second the number of columns.
a matrix – returns a copy of the supplied matrix.
one or more vectors, or a list of vectors – converts the supplied vector(s) into the columns of a new matrix object.
one or more lists, or a list of lists – converts the supplied list(s) into the rows of a new matrix object, providing all the elements are numerical and have matching units.
types.module(...)
The types.module(...) prototype takes any of the following combinations of arguments:
types.null(...)
The types.null(...) prototype takes any of the following combinations of arguments:
types.number(...)
The types.number(...) prototype takes any of the following combinations of arguments:
none – returns zero.
a number – returns that number.
a boolean – returns zero or one.
a string – converts the string to a number if it is in a valid format, or returns an error if not.
types.string(...)
The types.string(...) prototype takes any of the following combinations of arguments:
types.type(...)
The types.type(...) prototype takes any of the following combinations of arguments:
types.vector(...)
The types.vector(...) prototype takes any of the following combinations of arguments:
none – returns the vector [0].
a number – returns a zero vector with the specified number of dimensions.
a vector – returns a copy of the supplied vector.
a list – converts the supplied list to a vector, providing all of its elements are numerical and have consistent units.
a list of arguments returns its arguments as a vector, providing they are all numerical and have consistent units.