WallGo.fields

Classes for Fields and FieldPoint objects that hold information about the background fields.

Classes

FieldPoint(arr)

FieldPoint is a subclass of numpy's ndarray, representing a point in a field with certain constraints.

Fields(*fieldSpacePoints)

Simple class for holding collections of background fields in a common format.

class FieldPoint(arr)[source]

FieldPoint is a subclass of numpy’s ndarray, representing a point in a field with certain constraints.

Parameters:

arr (ndarray)

Return type:

FieldPoint

getField(i)[source]

Retrieve the field value at the specified index.

Parameters:

i (int) – The index of the field to retrieve.

Returns:

fieldValue – The value of the field at the specified index.

Return type:

float

numFields()[source]

Calculate the number of background fields.

This method returns the number of background fields contained within the object.

Returns:

nFields – The number of background fields.

Return type:

int

setField(i, value)[source]

Sets the value of the field at the specified index.

Parameters:
  • i (int) – The index at which to set the value.

  • value (float) – The value to set at the specified index.

Returns:

fieldPoint – The updated FieldPoint object.

Return type:

FieldPoint

class Fields(*fieldSpacePoints)[source]

Simple class for holding collections of background fields in a common format.

If the theory has N background fields, then a field-space point is defined by a list of length N. This array describes a collection of field-space points, so that the shape is (numPoints, numFields). Each row represents one field-space point. This is always a 2D array, even if we just have one field-space point.

Parameters:

fieldSpacePoints (Tuple[FieldPoint])

Return type:

Fields

static castFromNumpy(arr)[source]

Cast a NumPy array to a Fields object.

Parameters:

arr (np.ndarray) – The input NumPy array. It can be either 1D or 2D.

Returns:

fields – A Fields object created from the input NumPy array.

Return type:

Fields

Raises:

AssertionError : – If the input array has more than 2 dimensions.

getField(i)[source]

Get field at index i. I.e. if the theory has \(N\) background fields \(f_j\) with \(j\in 0, 1, \dots, N-1\), this will give all values of the field \(f_{i}\) as a 1D array.

Parameters:

i (int)

Return type:

ndarray

getFieldPoint(i)[source]

Get a field space point. It would be a 1D array, but we cast to a FieldPoint object for consistency. NB: no validation so will error if the index is out of bounds

Parameters:

i (int)

Return type:

FieldPoint

getFieldPreserveShape(i)[source]

Retrieve a field while preserving the original shape of the Fields object.

This method returns an array of the same shape as the original Fields object, but with all elements set to zero except for those corresponding to the specified field index.

Parameters:

i (int) – The index of the field to retrieve.

Returns:

arr – An array of the same shape as the original Fields object, with only the values of the specified field index preserved.

Return type:

np.ndarray

numFields()[source]

Returns how many background fields we contain

Return type:

int

numPoints()[source]

Returns how many field-space points we contain

Return type:

int

resizeFields(newNumPoints, newNumFields)[source]

Returns a resized array (uses np.resize internally)

Parameters:
  • newNumPoints (int)

  • newNumFields (int)

Return type:

Fields

setField(i, fieldArray)[source]

Set new values to the field at the specified index.

Parameters:
  • i (int) – The index at which to set the new field values.

  • fieldArray (np.ndarray) – The array containing the new field values.

Returns:

  • fields (Fields) – The updated Fields object with the new values set at

  • the specified index.

Return type:

Fields

takeSlice(idxStart, idxEnd, axis)[source]

Extracts a slice from the array along the specified axis.

Parameters:
  • idxStart (int) – The starting index of the slice (inclusive).

  • idxEnd (int) – The ending index of the slice (inclusive).

  • axis (int) – The axis along which to take the slice.

Returns:

arr – A sliced portion of the array as a numpy ndarray.

Return type:

np.ndarray

Notes

  • The method does not perform range checking on the indices.

  • The output is cast to a Fields object.