Skip to content

Commit

Permalink
Use pathlib for filename because pylint's suggestion is terrible
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcvey3 committed Sep 10, 2024
1 parent 160b40e commit 307b50c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mhkit/acoustics/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pandas as pd
import xarray as xr
from scipy.io import wavfile
from pathlib import Path


def read_hydrophone(
Expand All @@ -26,7 +27,7 @@ def read_hydrophone(
Parameters
----------
filename: string
filename: str or pathlib.Path
Input filename
peak_voltage: numeric
Peak voltage supplied to the analog to digital converter (ADC) in V.
Expand All @@ -44,7 +45,8 @@ def read_hydrophone(
out: numpy.array
Sound pressure [Pa] or Voltage [V] indexed by time[s]
"""
if not isinstance(filename, str):

if (not isinstance(filename, str)) and (not isinstance(filename.as_posix(), str)):
raise TypeError("Filename should be a string.")
if peak_voltage is None:
raise ValueError(
Expand Down Expand Up @@ -133,7 +135,7 @@ def read_hydrophone(
),
"valid_max": np.round(max_sat / 1e6, 6),
"fs": fs,
"filename": filename.replace("\\", "/").split("/")[-1],
"filename": Path(filename).stem,
},
)

Expand All @@ -152,7 +154,7 @@ def read_hydrophone(
"valid_min": -max_sat,
"valid_max": max_sat,
"fs": fs,
"filename": str(filename).replace("\\", "/").split("/")[-1],
"filename": Path(filename).stem,
},
)

Expand Down

0 comments on commit 307b50c

Please sign in to comment.