Skip to content

Commit

Permalink
Minor docstring fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbmorgan committed Nov 18, 2024
1 parent e1da226 commit 85d4a29
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 38 deletions.
4 changes: 2 additions & 2 deletions dfttoolkit/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,9 @@ def get_n_initial_ks_states(self, include_spin_polarised=True) -> int:
Parameters
----------
include_spin_polarised : bool, optional
include_spin_polarised : bool, default=True
Whether to include the spin-down states in the count if the calculation is
spin polarised (the default is True).
spin polarised.
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions dfttoolkit/utils/math_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ def get_autocorrelation_function_manual_lag(
----------
signal : 1D npt.NDArray
Siganl for which the autocorrelation function should be calculated.
max_lag : Union[None, int], optional
max_lag : Union[None, int]
Autocorrelation will be calculated for a range of 0 to max_lag,
where max_lag is the largest lag for the calculation of the
autocorrelation function. The default is None.
autocorrelation function
Returns
-------
Expand Down
32 changes: 14 additions & 18 deletions dfttoolkit/utils/vibrations_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def get_cross_correlation_function(
return cross_correlation


# TODO Fix docstrings and types
def get_cross_spectrum(
signal_0: npt.NDArray,
signal_1: npt.NDArray,
Expand Down Expand Up @@ -83,16 +84,16 @@ def get_cross_spectrum(
Second siganl for which the correlation function should be calculated.
time_step : float
DESCRIPTION.
bootstrapping_blocks : int, optional
DESCRIPTION. The default is 1.
bootstrapping_overlap : int, optional
DESCRIPTION. The default is 0.
zero_padding : int, optional
bootstrapping_blocks : int, default=1
DESCRIPTION
bootstrapping_overlap : int, default=0
DESCRIPTION
zero_padding : int, default=0
Pad the cross correlation function with zeros to increase the frequency
resolution of the FFT. This also avoids the effect of varying spectral
leakage. However, it artificially broadens the resulting cross spectrum
and introduces wiggles.
cutoff_at_last_maximum : bool, optional
cutoff_at_last_maximum : bool, default=False
Cut off the cross correlation function at the last maximum to hide
spectral leakage.
Expand All @@ -114,7 +115,8 @@ def get_cross_spectrum(
signal_length = len(signal_0)
block_size = int(
np.floor(
signal_length * (1 + bootstrapping_overlap)
signal_length
* (1 + bootstrapping_overlap)
/ (bootstrapping_blocks + bootstrapping_overlap)
)
)
Expand All @@ -123,8 +125,7 @@ def get_cross_spectrum(
cross_spectrum = []

for block in range(bootstrapping_blocks):
block_start = int(np.ceil(block * block_size /
(1 + bootstrapping_overlap)))
block_start = int(np.ceil(block * block_size / (1 + bootstrapping_overlap)))
if block_start < 0:
block_start = 0

Expand Down Expand Up @@ -204,8 +205,7 @@ def get_cross_spectrum_mem(
"""
# Calculate the autocorrelation of the time series
autocorr = np.correlate(signal_0, signal_1, mode="full") / len(signal_0)
autocorr = autocorr[len(autocorr) //
2: len(autocorr) // 2 + model_order + 1]
autocorr = autocorr[len(autocorr) // 2 : len(autocorr) // 2 + model_order + 1]

# Create a Toeplitz matrix from the autocorrelation function
# R = toeplitz(autocorr[:-1])
Expand Down Expand Up @@ -309,8 +309,7 @@ def get_line_widths(
res = [np.nan, np.nan, np.nan]

if use_lorentzian:
res = lorentzian_fit(frequencies, power_spectrum,
filter_maximum=filter_maximum)
res = lorentzian_fit(frequencies, power_spectrum, filter_maximum=filter_maximum)

if np.isnan(res[0]):
res = get_peak_parameters(frequencies, power_spectrum)
Expand Down Expand Up @@ -396,8 +395,7 @@ def _get_normal_mode_decomposition_numba(
# Loop over atoms and components
for i in range(number_of_cell_atoms):
for m in range(velocity_components):
projection_sum += velocities[n,
i, m] * eigenvectors[k, i, m]
projection_sum += velocities[n, i, m] * eigenvectors[k, i, m]

# Store the result in the projected velocities array
velocities_projected[n, k] = projection_sum
Expand All @@ -408,9 +406,7 @@ def _get_normal_mode_decomposition_numpy(
) -> None:

# Use einsum to perform the double summation over cell atoms and time steps
velocities_projected += np.einsum(
'tij,kij->tk', velocities, eigenvectors.conj()
)
velocities_projected += np.einsum("tij,kij->tk", velocities, eigenvectors.conj())

# number_of_cell_atoms = velocities.shape[1]
# number_of_frequencies = eigenvectors.shape[0]
Expand Down
26 changes: 12 additions & 14 deletions dfttoolkit/vibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def get_displacements(self, displacement: float = 0.0025) -> list:
Parameters
----------
displacement : float, optional
displacement : float, default=0.0025
Displacement for finte difference calculation of vibrations in
Angstrom. The default is 0.0025 Angstrom.
Angstrom.
Returns
-------
Expand Down Expand Up @@ -133,9 +133,8 @@ def get_hessian(
Parameters
----------
set_constrained_atoms_zero : bool, optional
set_constrained_atoms_zero : bool, default=False
Set elements in Hessian that code for constrained atoms to zero.
The default is False.
Returns
-------
Expand Down Expand Up @@ -185,8 +184,8 @@ def get_symmetrized_hessian(self, hessian=None):
Parameters
----------
hessian : TYPE, optional
DESCRIPTION. The default is None.
hessian : TYPE, default=None
DESCRIPTION
Returns
-------
Expand Down Expand Up @@ -227,13 +226,12 @@ def get_eigenvalues_and_eigenvectors(
----------
hessian : npt.NDArray[np.float64], optional
Hessian. The default is None.
only_real : bool, optional
only_real : bool, default=True
Returns only real valued eigenfrequencies + eigenmodes
(ATTENTION: if you want to also include instable modes, you have to
symmetrize the hessian as provided below). The default is True.
symmetrize_hessian : bool, optional
symmetrize the hessian as provided below).
symmetrize_hessian : bool, default=True
Symmetrise the hessian only for this function (no global change).
The default is True.
Returns
-------
Expand Down Expand Up @@ -500,10 +498,10 @@ def get_cross_correlation_function(
DESCRIPTION.
time_step : float
DESCRIPTION.
bootstrapping_blocks : int, optional
DESCRIPTION. The default is 1.
bootstrapping_overlap : int, optional
DESCRIOTION. The default is 0.
bootstrapping_blocks : int, default=1
DESCRIPTION
bootstrapping_overlap : int, default=0
DESCRIPTION
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def test_get_geometry(self):

if self._aims_fixture_no in [1, 2, 3, 5, 7, 9]:
assert len(geom) == 3
assert geom.get_is_periodic() == False
assert geom.get_is_periodic() is False
else:
assert len(geom) == 2
assert geom.get_is_periodic() == True
assert geom.get_is_periodic() is True

# TODO
# def test_get_parameters(self):
Expand Down

0 comments on commit 85d4a29

Please sign in to comment.