Skip to content

Commit 77580b1

Browse files
committed
chore: remove deprecated functions
1 parent 447f64c commit 77580b1

File tree

6 files changed

+41
-52
lines changed

6 files changed

+41
-52
lines changed

.github/dependabot.yml

-12
This file was deleted.

.github/workflows/documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
pages:
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-24.04
1010
environment:
1111
name: github-pages
1212
url: ${{ steps.deployment.outputs.page_url }}

src/mclsimpy/utils.py

+29-29
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434

3535
def complex_to_polar(complex_values):
36-
"""Complex value to polar coordinates.
36+
r"""Complex value to polar coordinates.
3737
3838
Parameters
3939
----------
@@ -239,7 +239,7 @@ def Rz(psi):
239239

240240

241241
def Rzyx(eta):
242-
"""Full roation matrix.
242+
r"""Full roation matrix.
243243
244244
.. math::
245245
R_{zyx} = R_z(\psi)R_y(\\theta)R_x(\phi)
@@ -262,7 +262,7 @@ def Rzyx(eta):
262262

263263

264264
def Tzyx(eta):
265-
"""Transformation matrix.
265+
r"""Transformation matrix.
266266
267267
Parameters
268268
----------
@@ -292,7 +292,7 @@ def Tzyx(eta):
292292

293293

294294
def J(eta):
295-
"""6 DOF rotation matrix.
295+
r"""6 DOF rotation matrix.
296296
297297
.. math::
298298
J(\eta) = \left[\\begin{array}{cc}R_{zyx}(\eta) & O_{3\\times 3} \\\ O_{3\\times 3} & T_{zyx}(\eta)\end{array} \\right]
@@ -316,7 +316,7 @@ def J(eta):
316316

317317

318318
def Smat(x):
319-
"""
319+
r"""
320320
Skew-symmetric cross-product operator matrix.
321321
322322
Parameters
@@ -331,7 +331,7 @@ def Smat(x):
331331

332332

333333
def three2sixDOF(v):
334-
"""3 to 6 DOF conversion.
334+
r"""3 to 6 DOF conversion.
335335
336336
Converts a vector a matrix from 3DOF
337337
to 6DOF.
@@ -368,7 +368,7 @@ def three2sixDOF(v):
368368

369369

370370
def six2threeDOF(v):
371-
"""6 to 3 DOF conversion.
371+
r"""6 to 3 DOF conversion.
372372
373373
Convert a 6DOF vecor or matrix to 3DOF.
374374
@@ -392,7 +392,7 @@ def six2threeDOF(v):
392392

393393

394394
def timeit(func):
395-
"""
395+
r"""
396396
Decorator for measuring execution time of function.
397397
398398
Print the execution time of a function. (Mainly for
@@ -433,7 +433,7 @@ def wrapper(*args, **kwargs):
433433

434434

435435
def rigid_body_transform(r, eta, in_ned=True):
436-
"""Calculate the relative motion of a point r different from the COG.
436+
r"""Calculate the relative motion of a point r different from the COG.
437437
438438
The calculation assumes small angles (s.t. cos(theta)=0 and sin(theta)=theta)
439439
and is computed as:
@@ -466,7 +466,7 @@ def rigid_body_transform(r, eta, in_ned=True):
466466

467467

468468
def power_spectral_density(timeseries, fs, freq_hz=False, nperseg=2**11):
469-
"""Compute the Power Spectral Density (PSD) of a timeseries.
469+
r"""Compute the Power Spectral Density (PSD) of a timeseries.
470470
471471
The PSD is calculated using scipy.signals.welch
472472
@@ -495,9 +495,9 @@ def power_spectral_density(timeseries, fs, freq_hz=False, nperseg=2**11):
495495

496496

497497
# --------- READ DATA UTILITY FUNCTIONS -------------------
498-
re_science = "\s{1,}-?\d\.?\d*[Ee][+\-]?\d+"
499-
re_int = "\s{1,}[0-9]{1,}"
500-
re_float = "\s{1,}[0-9]{1,}\.[0-9]{1,}"
498+
re_science = r"\s{1,}-?\d\.?\d*[Ee][+\-]?\d+"
499+
re_int = r"\s{1,}[0-9]{1,}"
500+
re_float = r"\s{1,}[0-9]{1,}\.[0-9]{1,}"
501501

502502

503503
def data2num(line):
@@ -513,7 +513,7 @@ def data2float(line):
513513

514514

515515
def read_tf(file_path, tf_type="motion"):
516-
"""Read VERES transfer function output.
516+
r"""Read VERES transfer function output.
517517
518518
The function reads data from veres input files.
519519
- Motion RAOs are found in '.re1'
@@ -637,7 +637,7 @@ def read_tf(file_path, tf_type="motion"):
637637

638638

639639
def read_hydrod(filepath):
640-
"""Read hydrodynamic coefficients from Veres output file.
640+
r"""Read hydrodynamic coefficients from Veres output file.
641641
642642
The function reads the hydrodynamic coefficients from a Veres output file.
643643
The coefficients are transformed from the CG to CO and from the Veres
@@ -775,7 +775,7 @@ def read_hydrod(filepath):
775775

776776

777777
def read_wave_drift(filepath):
778-
"""Read wave drift data from Veres output file.
778+
r"""Read wave drift data from Veres output file.
779779
780780
The function reads the wave drift data from a Veres output file. The data
781781
is transformed from the Veres axis system to the mclsimpy axis system. The
@@ -852,7 +852,7 @@ def read_wave_drift(filepath):
852852
def plot_raos(
853853
raos, freqs, plot_polar=True, rao_type="motion", wave_angle=0, figsize=(16, 8)
854854
):
855-
"""Plot the force or motion RAOs.
855+
r"""Plot the force or motion RAOs.
856856
857857
The RAOs should be complex.
858858
@@ -892,13 +892,13 @@ def plot_raos(
892892
np.angle(raos[i, 0, wave_angle, 0]),
893893
np.abs(raos[i, 0, wave_angle, 0]),
894894
"ro",
895-
label="$\omega_{min}$",
895+
label=r"$\omega_{min}$",
896896
)
897897
plt.plot(
898898
np.angle(raos[i, -1, wave_angle, 0]),
899899
np.abs(raos[i, -1, wave_angle, 0]),
900900
"go",
901-
label="$\omega_{max}$",
901+
label=r"$\omega_{max}$",
902902
)
903903
if (i < 3) and (rao_type == "motion"):
904904
plt.gca().set_rmax(1)
@@ -910,7 +910,7 @@ def plot_raos(
910910
for i in range(6):
911911
plt.sca(axs[i // 3, i % 3])
912912
plt.plot(freqs, np.abs(raos[i, :, wave_angle, 0]))
913-
plt.xlabel("$\omega \; [rad/s]$")
913+
plt.xlabel(r"$\omega \; [rad/s]$")
914914
if i < 3:
915915
plt.ylabel(r"$\frac{\eta}{\zeta_a} \; [\frac{m}{m}]$")
916916
else:
@@ -920,8 +920,8 @@ def plot_raos(
920920
for i in range(6):
921921
plt.sca(axs[i // 3, i % 3])
922922
plt.plot(freqs, np.angle(raos[i, :, wave_angle, 0]))
923-
plt.xlabel("$\omega \; [rad/s]$")
924-
plt.ylabel("$\phi \; [rad]$")
923+
plt.xlabel(r"$\omega \; [rad/s]$")
924+
plt.ylabel(r"$\phi \; [rad]$")
925925

926926
plt.show()
927927

@@ -995,7 +995,7 @@ def _complete_sector_coeffs(vessel_config: dict):
995995

996996

997997
def generate_config_file(input_files_paths: list = None, input_file_dir: str = None):
998-
"""Generate a .json configuration file for a vessel. The function can take
998+
r"""Generate a .json configuration file for a vessel. The function can take
999999
either a list of file locations, or the path to the directory containing the
10001000
result files.
10011001
@@ -1135,7 +1135,7 @@ def generate_config_file(input_files_paths: list = None, input_file_dir: str = N
11351135

11361136

11371137
def invfreqs(h, w, nb, na, weights=None, method=0, maxiter=40):
1138-
"""
1138+
r"""
11391139
Estimate the numerator and denominator coefficients of a transfer function from
11401140
frequency response data using complex function curve fitting with quasi-linear least squares.
11411141
@@ -1241,7 +1241,7 @@ def _invfreqs_alt(g, worN, nB, nA, wf=None, nk=0):
12411241

12421242

12431243
def _stabilize(a):
1244-
"""Stabilize the denominator polynomial by switching sign of real part for roots with real part > 1.
1244+
r"""Stabilize the denominator polynomial by switching sign of real part for roots with real part > 1.
12451245
12461246
Parameters
12471247
----------
@@ -1264,7 +1264,7 @@ def _stabilize(a):
12641264

12651265

12661266
def joint_identification(w, A, B, order, plot_estimate=False, method=0):
1267-
"""Joint identification of infinity added mass and radiation forces.
1267+
r"""Joint identification of infinity added mass and radiation forces.
12681268
12691269
Parameters
12701270
----------
@@ -1366,7 +1366,7 @@ def joint_identification(w, A, B, order, plot_estimate=False, method=0):
13661366

13671367

13681368
def system_identification(w, A, B, max_order=10, method=0, plot_estimate=False):
1369-
"""Identify the system matrices of a linear time-invariant system.
1369+
r"""Identify the system matrices of a linear time-invariant system.
13701370
13711371
Parameters
13721372
----------
@@ -1582,7 +1582,7 @@ def system_identification(w, A, B, max_order=10, method=0, plot_estimate=False):
15821582

15831583

15841584
def quat2eul(w, x, y, z):
1585-
"""
1585+
r"""
15861586
Returns the ZYX roll-pitch-yaw angles from a quaternion.
15871587
"""
15881588
q = np.array((w, x, y, z))
@@ -1607,7 +1607,7 @@ def quat2eul(w, x, y, z):
16071607

16081608

16091609
def quat2eul(w, x, y, z):
1610-
"""
1610+
r"""
16111611
Returns the ZYX roll-pitch-yaw angles from a quaternion.
16121612
"""
16131613
q = np.array((w, x, y, z))

src/mclsimpy/waves/wave_spectra.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import scipy as sp
1515
import numpy as np
16-
from abc import ABC, abstractclassmethod
16+
from abc import ABC, abstractmethod
1717

1818

1919
class BaseSpectrum(ABC):
@@ -44,7 +44,7 @@ def __call__(self, *args, freq_hz=None, **kwargs):
4444
def moment(self, n, *args, **kwargs):
4545
"""Calculate n-th spectral moment."""
4646
freq, spec = self.__call__(*args, **kwargs)
47-
return np.trapz(freq**n * spec, freq)
47+
return np.trapezoid(freq**n * spec, freq)
4848

4949
def realization(self, time, *args, **kwargs):
5050
"""Generate a wave realization from wave spectrum at a fixed position.
@@ -70,7 +70,7 @@ def realization(self, time, *args, **kwargs):
7070
eps = np.random.uniform(0, 2 * np.pi, size=len(amp))
7171
return np.sum(amp * np.cos(freq * time[:, None] + eps), axis=1)
7272

73-
@abstractclassmethod
73+
@abstractmethod
7474
def _spectrum(self, omega, *args, **kwargs):
7575
raise NotImplementedError
7676

src/mclsimpy/waves/wave_spreading.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Spreading functions for unidirectional and multidirectional wave fields
22
import numpy as np
3-
from abc import ABC, abstractclassmethod
4-
import scipy as sp
3+
from abc import ABC, abstractmethod
4+
import scipy
5+
import scipy.special
56

67
class BaseSpreading(ABC):
78

@@ -24,7 +25,7 @@ def __init__(self, angles, degrees=False):
2425
def __call__(self, *args, degrees=None, **kwargs):
2526
return self._spreading(*args, **kwargs)
2627

27-
@abstractclassmethod
28+
@abstractmethod
2829
def _spreading(self, *args, **kwargs):
2930
raise NotImplementedError
3031

@@ -56,9 +57,9 @@ def _spreading(self, theta0, s):
5657
in_pipi_half = np.abs(d_theta) < np.pi / 2
5758
f_theta = (
5859
2 ** (2 * s - 1)
59-
* np.math.factorial(s)
60-
* np.math.factorial(s - 1)
61-
/ (np.pi * np.math.factorial(2 * s - 1))
60+
* scipy.special.factorial(s)
61+
* scipy.math.factorial(s - 1)
62+
/ (np.pi * scipy.math.factorial(2 * s - 1))
6263
* np.cos(d_theta) ** (2 * s)
6364
)
6465
f_theta[~in_pipi_half] = 0

tests/test_wave_spectra.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_area_spreading_function(self):
7171
spreading_spectra = MultiDirectional(theta)
7272
angles, spreading = spreading_spectra()
7373

74-
integral = np.trapz(spreading, angles)
74+
integral = np.trapezoid(spreading, angles)
7575
print(integral)
7676
assert np.isclose(integral, 1, rtol=1e-2)
7777

0 commit comments

Comments
 (0)