Skip to content

Commit

Permalink
Fix many pylint warnings, update copyright to 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed May 21, 2024
1 parent 11be4f9 commit fd36ba1
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion stockwell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Time-frequency analysis through Stockwell transform.
:copyright:
2021-2023 Claudio Satriano <satriano@ipgp.fr>
2021-2024 Claudio Satriano <satriano@ipgp.fr>
:license:
GNU General Public License v3.0 or later.
Expand Down
15 changes: 14 additions & 1 deletion stockwell/lib_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This file is part of the Stockwell project.
:copyright:
2023 Claudio Satriano <satriano@ipgp.fr>
2023-2024 Claudio Satriano <satriano@ipgp.fr>
:license:
GNU General Public License v3.0 or later.
Expand All @@ -18,6 +18,19 @@


def get_lib_path(lib):
"""
Return the path to the compiled library.
Parameters
----------
lib : str
The name of the library.
Returns
-------
str
The path to the compiled library.
"""
suffix = importlib.machinery.EXTENSION_SUFFIXES[0]
libname = lib + suffix
return os.path.join(os.path.dirname(__file__), 'lib', libname)
4 changes: 2 additions & 2 deletions stockwell/sine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
This file is part of the Stockwell project.
:copyright:
2023 Claudio Satriano <satriano@ipgp.fr>
2023-2024 Claudio Satriano <satriano@ipgp.fr>
:license:
GNU General Public License v3.0 or later.
(https://www.gnu.org/licenses/gpl-3.0.html)
"""
import numpy as np
from ctypes import CDLL, POINTER, c_int, c_double, c_void_p
import numpy as np
from .lib_path import get_lib_path

lib_sine = CDLL(get_lib_path('sine'))
Expand Down
4 changes: 2 additions & 2 deletions stockwell/st.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
This file is part of the Stockwell project.
:copyright:
2023 Claudio Satriano <satriano@ipgp.fr>
2023-2024 Claudio Satriano <satriano@ipgp.fr>
:license:
GNU General Public License v3.0 or later.
(https://www.gnu.org/licenses/gpl-3.0.html)
"""
import numpy as np
from ctypes import CDLL, POINTER, c_int, c_uint, c_double, c_void_p
import numpy as np
from .lib_path import get_lib_path

lib_st = CDLL(get_lib_path('st'))
Expand Down
23 changes: 21 additions & 2 deletions stockwell/tests/test_stockwell.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
# -*- coding: utf8 -*-
# SPDX-License-Identifier: GPL-3.0-or-later
"""
test_stockwell.py
This file is part of the Stockwell project.
:copyright:
2023-2024 Claudio Satriano <satriano@ipgp.fr>
:license:
GNU General Public License v3.0 or later.
(https://www.gnu.org/licenses/gpl-3.0.html)
"""
import os
import unittest
from stockwell.lib_path import get_lib_path
import numpy as np
from numpy.testing import assert_allclose
from stockwell.lib_path import get_lib_path

# Note: st and sine modules are lazily imported in the tests below to avoid
# early failure if the libraries are not found.
# pylint: disable=import-outside-toplevel


class TestStockwell(unittest.TestCase):
"""Test the Stockwell transform."""
def test_find_libs(self):
"""Test if the compiled libraries are found."""
for lib in 'st', 'sine':
lib_path = get_lib_path(lib)
# check if the library exists
Expand All @@ -19,6 +34,7 @@ def test_find_libs(self):
assert False

def test_st(self):
"""Test the Stockwell transform."""
from stockwell import st
array = np.array([0, 1])
stock_expected = np.array([
Expand All @@ -29,6 +45,7 @@ def test_st(self):
assert_allclose(stock, stock_expected)

def test_ist(self):
"""Test the inverse Stockwell transform."""
from stockwell import st
stock = np.array([
[0.5+0.j, 0.5+0.j],
Expand All @@ -39,6 +56,7 @@ def test_ist(self):
assert_allclose(array, array_expected)

def test_hilbert(self):
"""Test the Hilbert transform."""
from stockwell import st
array = np.arange(10)
hilbert_expected = np.array([
Expand All @@ -49,6 +67,7 @@ def test_hilbert(self):
assert_allclose(hilbert, hilbert_expected)

def test_sine_taper(self):
"""Test the sine taper."""
from stockwell import sine
taper_expected = np.array([
0.12013117, 0.23053002, 0.3222527, 0.38786839, 0.42206128,
Expand Down

0 comments on commit fd36ba1

Please sign in to comment.