Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
takenori-y committed Dec 10, 2024
1 parent 71a8424 commit 877c464
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions diffsptk/misc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@ def next_power_of_two(n):

def default_dtype():
t = torch.get_default_dtype()
if t == torch.float: # pragma: no cover
if t == torch.float:
return np.float32
elif t == torch.double: # pragma: no cover
elif t == torch.double:
return np.float64
raise RuntimeError("Unknown default dtype: {t}.")


def default_complex_dtype():
t = torch.get_default_dtype()
if t == torch.float: # pragma: no cover
if t == torch.float:
return np.complex64
elif t == torch.double: # pragma: no cover
elif t == torch.double:
return np.complex128
raise RuntimeError("Unknown default dtype: {t}.")


def torch_default_complex_dtype():
t = torch.get_default_dtype()
if t == torch.float: # pragma: no cover
if t == torch.float:
return torch.complex64
elif t == torch.double: # pragma: no cover
elif t == torch.double:
return torch.complex128
raise RuntimeError("Unknown default dtype: {t}.")

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ exclude_lines = [
"verbose",
"warn_type",
"warnings",
"torch.float",
"torch.double",
]

[tool.coverage.run]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_igammatone.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_analysis_synthesis(device, exact, M=4, L=8192, desired_delay=4, verbose
igammatone = diffsptk.GammatoneFilterBankSynthesis(
sr, filter_order=M, exact=exact, desired_delay=desired_delay
).to(device)
y = igammatone(gammatone(x.unsqueeze(0)), compensate_delay=True)
y = igammatone(gammatone(x.unsqueeze(0)).squeeze(0), compensate_delay=True)
assert (x - y).abs().max() < 0.1

if verbose:
Expand Down

0 comments on commit 877c464

Please sign in to comment.