PointWithDescription

class PointWithDescription(*args)

Collection of real values with a description for each component.

Available constructors:

PointWithDescription(size=0, value=0.0)

PointWithDescription(sequence)

Parameters:

size : int, size \geq 0

Size of the vector.

value : float

Value set to the size elements.

sequence : sequence of pair (string, float)

Components of the vector.

Examples

>>> import openturns as ot

Use the first constructor:

>>> print(ot.PointWithDescription(2))
[ : 0,  : 0]
>>> vector = ot.PointWithDescription(2, 3.0)
>>> print(vector)
[ : 3,  : 3]
>>> vector.setDescription(['c1', 'c2'])
>>> print(vector)
[c1 : 3, c2 : 3]

Use the second constructor:

>>> vector = ot.PointWithDescription([('C1', 2.0), ('C2', 3.0), ('C3', 4.5)])
>>> print(vector)
[C1 : 2, C2 : 3, C3 : 4.5]
>>> print(vector.getDescription())
[C1,C2,C3]

Use some functionalities:

>>> vector[1] = 7.1
>>> print(vector)
[C1 : 2, C2 : 7.1, C3 : 4.5]
>>> vector.add(6.2)
>>> print(vector)
[C1 : 2, C2 : 7.1, C3 : 4.5,  : 6.2]

Methods

add(*args) Append a component (in-place).
at(*args) Access to an element of the collection.
clean(threshold)
clear() Reset the collection to zero dimension.
getClassName() Accessor to the object’s name.
getDescription() Accessor to the componentwise description.
getDimension() Accessor to the vector’s dimension.
getId() Accessor to the object’s id.
getName() Accessor to the object’s name.
getShadowedId() Accessor to the object’s shadowed id.
getSize() Accessor to the vector’s dimension (or size).
getVisibility() Accessor to the object’s visibility state.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
isEmpty() Tell if the collection is empty.
norm() Compute the Euclidean (L^2) norm.
norm1() Compute the L^1 norm.
normInf() Compute the L^{\inf} norm.
normSquare() Compute the squared Euclidean norm.
normalize() Compute the normalized vector with respect to its Euclidean norm.
normalizeSquare() Compute the normalized vector with respect to its squared Euclidean norm.
resize(newSize) Change the size of the collection.
setDescription(description) Accessor to the componentwise description.
setName(name) Accessor to the object’s name.
setShadowedId(id) Accessor to the object’s shadowed id.
setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)

x.__init__(…) initializes x; see help(type(x)) for signature

add(*args)

Append a component (in-place).

Parameters:

value : type depends on the type of the collection.

The component to append.

Examples

>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.add(1.)
>>> print(x)
[0,0,1]
at(*args)

Access to an element of the collection.

Parameters:

index : positive int

Position of the element to access.

Returns:

element : type depends on the type of the collection

Element of the collection at the position index.

clear()

Reset the collection to zero dimension.

Examples

>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.clear()
>>> x
class=Point name=Unnamed dimension=0 values=[]
getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getDescription()

Accessor to the componentwise description.

Returns:

description : Description

Description of the components.

See also

setDescription

getDimension()

Accessor to the vector’s dimension.

Returns:

n : int

The number of components in the vector.

getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getSize()

Accessor to the vector’s dimension (or size).

Returns:

n : int

The number of components in the vector.

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

isEmpty()

Tell if the collection is empty.

Returns:

isEmpty : bool

True if there is no element in the collection.

Examples

>>> import openturns as ot
>>> x = ot.Point(2)
>>> x.isEmpty()
False
>>> x.clear()
>>> x.isEmpty()
True
norm()

Compute the Euclidean (L^2) norm.

The Euclidean (L^2) norm of a vector is defined as:

\norm{\vect{x}} = \norm{\vect{x}}_2
                = \sqrt{\sum_{i=1}^n x_i^2}

Returns:

norm : float

The vector’s Euclidean norm.

Examples

>>> import openturns as ot
>>> x = ot.Point([1.0, 2.0, 3.0])
>>> x.norm()
3.741657...
norm1()

Compute the L^1 norm.

The L^1 norm of a vector is defined as:

\norm{\vect{x}}_1 = \sum_{i=1}^n |x_i|

Returns:

norm : float

The vector’s L^1 norm.

Examples

>>> import openturns as ot
>>> x = ot.Point([1.0, 2.0, 3.0])
>>> x.norm1()
6.0
normInf()

Compute the L^{\inf} norm.

The L^{\inf} norm of a vector is defined as:

\norm{\vect{x}}_{\inf} = \max_{i=1}^n |x_i|

Returns:

norm : float

The vector’s L^{\inf} norm.

Examples

>>> import openturns as ot
>>> x = ot.Point([1.0, 2.0, 3.0])
>>> x.normInf()
3.0
normSquare()

Compute the squared Euclidean norm.

Returns:

norm : float

The vector’s squared Euclidean norm.

See also

norm

Examples

>>> import openturns as ot
>>> x = ot.Point([1.0, 2.0, 3.0])
>>> x.normSquare()
14.0
normalize()

Compute the normalized vector with respect to its Euclidean norm.

Returns:

normalized_vector : Point

The normalized vector with respect to its Euclidean norm.

Raises:

RuntimeError : If the Euclidean norm is zero.

See also

norm

Examples

>>> import openturns as ot
>>> x = ot.Point([1.0, 2.0, 3.0])
>>> print(x.normalize())
[0.267261,0.534522,0.801784]
normalizeSquare()

Compute the normalized vector with respect to its squared Euclidean norm.

Returns:

normalized_vector : normalized_vector

The normalized vector with respect to its squared Euclidean norm.

Raises:

RuntimeError : If the squared Euclidean norm is zero.

See also

normSquare

Examples

>>> import openturns as ot
>>> x = ot.Point([1.0, 2.0, 3.0])
>>> print(x.normalizeSquare())
[0.0714286,0.285714,0.642857]
resize(newSize)

Change the size of the collection.

Parameters:

newSize : positive int

New size of the collection.

Notes

If the new size is smaller than the older one, the last elements are thrown away, else the new elements are set to the default value of the element type.

Examples

>>> import openturns as ot
>>> x = ot.Point(2, 4)
>>> print(x)
[4,4]
>>> x.resize(1)
>>> print(x)
[4]
>>> x.resize(4)
>>> print(x)
[4,0,0,0]
setDescription(description)

Accessor to the componentwise description.

Parameters:

description : sequence of str

Description of the components.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.