-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nathan Hui
committed
Nov 14, 2023
1 parent
708d8a5
commit f83569b
Showing
6 changed files
with
222 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"pyha_tests" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
'''Tests PyHa environment | ||
''' | ||
import json | ||
import os | ||
from pathlib import Path | ||
from tempfile import TemporaryDirectory | ||
from typing import Dict | ||
|
||
import pytest | ||
from nas_unzip.nas import nas_unzip | ||
|
||
from PyHa.IsoAutio import generate_automated_labels | ||
|
||
|
||
@pytest.fixture(name='creds') | ||
def create_creds() -> Dict[str, str]: | ||
"""Obtains the credentials | ||
Returns: | ||
Dict[str, str]: Username and password dictionary | ||
""" | ||
if Path('credentials.json').is_file(): | ||
with open('credentials.json', 'r', encoding='ascii') as handle: | ||
return json.load(handle) | ||
else: | ||
value = os.environ['NAS_CREDS'].splitlines() | ||
assert len(value) == 2 | ||
return { | ||
'username': value[0], | ||
'password': value[1] | ||
} | ||
|
||
|
||
def test_pyha(creds): | ||
"""Tests PyHa | ||
""" | ||
with TemporaryDirectory() as path: | ||
nas_unzip( | ||
network_path='smb://e4e-nas.ucsd.edu:6021/temp/github_actions/pyha/pyha_test.zip', | ||
output_path=Path(path), | ||
username=creds['username'], | ||
password=creds['password'] | ||
) | ||
isolation_parameters = { | ||
"model": "tweetynet", | ||
"tweety_output": True, | ||
"technique": "steinberg", | ||
"threshold_type": "median", | ||
"threshold_const": 2.0, | ||
"threshold_min": 0.0, | ||
"window_size": 2.0, | ||
"chunk_size": 5.0, | ||
"verbose": True | ||
} | ||
generate_automated_labels(path, isolation_parameters) | ||
isolation_parameters = { | ||
"model": "birdnet", | ||
"output_path": "outputs", | ||
"lat": 35.4244, | ||
"lon": -120.7463, | ||
"week": 18, | ||
"min_conf": 0.1, | ||
"filetype": "wav", | ||
"num_predictions": 1, | ||
"write_to_csv": False, | ||
} | ||
generate_automated_labels(path, isolation_parameters) | ||
isolation_parameters = { | ||
"model": "microfaune", | ||
"technique": "steinberg", | ||
"threshold_type": "median", | ||
"threshold_const": 2.0, | ||
"threshold_min": 0.0, | ||
"window_size": 2.0, | ||
"chunk_size": 5.0, | ||
"verbose": True | ||
} | ||
generate_automated_labels(path, isolation_parameters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters