psi4.core.Vector¶
-
class
psi4.core.Vector¶ Bases:
objectdocstring
Attributes Summary
nameThe name of the Vector. npView without only one irrep nphView with irreps. shapeShape of the Psi4 data object Methods Summary
array_interface((self: psi4.core.Vector) -> list)dim((self: psi4.core.Vector, arg0: int) -> int)docstring from_array(arr[, name, dim1, dim2])Converts a numpy array or list of numpy arrays into a Psi4 Matrix (irreped if list). from_serial(json_data)Converts serialized data to the correct Psi4 data type get(*args, **kwargs)Overloaded function. nirrep((self: psi4.core.Vector) -> int)docstring np_read(filename[, prefix])np_write([filename, prefix])print_out((self: psi4.core.Vector) -> None)docstring scale((self: psi4.core.Vector, ...)docstring set(*args, **kwargs)Overloaded function. to_array(matrix[, copy, dense])Converts a Psi4 Matrix or Vector to a numpy array. to_serial(data)Converts an object with a .nph accessor to a serialized dictionary Attributes Documentation
-
name¶ The name of the Vector. Used in printing.
-
np¶ View without only one irrep
-
nph¶ View with irreps.
-
shape¶ Shape of the Psi4 data object
Methods Documentation
-
array_interface(self: psi4.core.Vector) → list¶
-
dim(self: psi4.core.Vector, arg0: int) → int¶ docstring
-
classmethod
from_array(arr, name='New Matrix', dim1=None, dim2=None)¶ Converts a numpy array or list of numpy arrays into a Psi4 Matrix (irreped if list).
Parameters: - arr (array or list of arrays) – Numpy array or list of arrays to use as the data for a new core.Matrix
- name (str) – Name to give the new core.Matrix
- dim1 (list, tuple, or core.Dimension (optional)) – If a single dense numpy array is given, a dimension can be supplied to apply irreps to this array. Note that this discards all extra information given in the matrix besides the diagonal blocks determined by the passed dimension.
- dim2 – Same as dim1 only if using a Psi4.Dimension object.
Returns: matrix – Returns the given Psi4 object
Return type: Notes
This is a generalized function to convert a NumPy array to a Psi4 object
Examples
1 2
>>> data = np.random.rand(20) >>> vector = array_to_matrix(data)
1 2 3 4
>>> irrep_data = [np.random.rand(2, 2), np.empty(shape=(0,3)), np.random.rand(4, 4)] >>> matrix = array_to_matrix(irrep_data) >>> print matrix.rowspi().to_tuple() (2, 0, 4)
-
classmethod
from_serial(json_data)¶ Converts serialized data to the correct Psi4 data type
-
get(*args, **kwargs)¶ Overloaded function.
- get(self: psi4.core.Vector, arg0: int) -> float
docstring
- get(self: psi4.core.Vector, arg0: int, arg1: int) -> float
docstring
-
nirrep(self: psi4.core.Vector) → int¶ docstring
-
classmethod
np_read(filename, prefix='')¶
-
np_write(filename=None, prefix='')¶
-
print_out(self: psi4.core.Vector) → None¶ docstring
-
scale(self: psi4.core.Vector, arg0: float) → None¶ docstring
-
set(*args, **kwargs)¶ Overloaded function.
- set(self: psi4.core.Vector, arg0: int, arg1: float) -> None
docstring
- set(self: psi4.core.Vector, arg0: int, arg1: int, arg2: float) -> None
docstring
-
to_array(matrix, copy=True, dense=False)¶ Converts a Psi4 Matrix or Vector to a numpy array. Either copies the data or simply consturcts a view.
Parameters: Returns: array – Returns either a list of np.array’s or the base array depending on options.
Return type: np.array or list of of np.array
Notes
This is a generalized function to convert a Psi4 object to a NumPy array
Examples
1 2 3 4 5
>>> data = psi4.Matrix(3, 3) >>> data._to_array() [[ 0. 0. 0.] [ 0. 0. 0.] [ 0. 0. 0.]]
-
to_serial(data)¶ Converts an object with a .nph accessor to a serialized dictionary
-
array_interface(self: psi4.core.Vector) → list
-
dim(self: psi4.core.Vector, arg0: int) → int docstring
-
classmethod
from_array(arr, name='New Matrix', dim1=None, dim2=None) Converts a numpy array or list of numpy arrays into a Psi4 Matrix (irreped if list).
Parameters: - arr (array or list of arrays) – Numpy array or list of arrays to use as the data for a new core.Matrix
- name (str) – Name to give the new core.Matrix
- dim1 (list, tuple, or core.Dimension (optional)) – If a single dense numpy array is given, a dimension can be supplied to apply irreps to this array. Note that this discards all extra information given in the matrix besides the diagonal blocks determined by the passed dimension.
- dim2 – Same as dim1 only if using a Psi4.Dimension object.
Returns: matrix – Returns the given Psi4 object
Return type: Notes
This is a generalized function to convert a NumPy array to a Psi4 object
Examples
1 2
>>> data = np.random.rand(20) >>> vector = array_to_matrix(data)
1 2 3 4
>>> irrep_data = [np.random.rand(2, 2), np.empty(shape=(0,3)), np.random.rand(4, 4)] >>> matrix = array_to_matrix(irrep_data) >>> print matrix.rowspi().to_tuple() (2, 0, 4)
-
classmethod
from_serial(json_data) Converts serialized data to the correct Psi4 data type
-
get(*args, **kwargs) Overloaded function.
- get(self: psi4.core.Vector, arg0: int) -> float
docstring
- get(self: psi4.core.Vector, arg0: int, arg1: int) -> float
docstring
-
name The name of the Vector. Used in printing.
-
nirrep(self: psi4.core.Vector) → int docstring
-
np View without only one irrep
-
classmethod
np_read(filename, prefix='')
-
np_write(filename=None, prefix='')
-
nph View with irreps.
-
print_out(self: psi4.core.Vector) → None docstring
-
scale(self: psi4.core.Vector, arg0: float) → None docstring
-
set(*args, **kwargs) Overloaded function.
- set(self: psi4.core.Vector, arg0: int, arg1: float) -> None
docstring
- set(self: psi4.core.Vector, arg0: int, arg1: int, arg2: float) -> None
docstring
-
shape Shape of the Psi4 data object
-
to_array(matrix, copy=True, dense=False) Converts a Psi4 Matrix or Vector to a numpy array. Either copies the data or simply consturcts a view.
Parameters: Returns: array – Returns either a list of np.array’s or the base array depending on options.
Return type: np.array or list of of np.array
Notes
This is a generalized function to convert a Psi4 object to a NumPy array
Examples
1 2 3 4 5
>>> data = psi4.Matrix(3, 3) >>> data._to_array() [[ 0. 0. 0.] [ 0. 0. 0.] [ 0. 0. 0.]]
-
to_serial(data) Converts an object with a .nph accessor to a serialized dictionary
-