Skip to content

Commit

Permalink
Bump versio and black formatting (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
magdalenafuentes committed Feb 6, 2024
1 parent be38e9b commit 62fdaa6
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 55 deletions.
1 change: 1 addition & 0 deletions soundata/annotations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""soundata annotation data types
"""

import numpy as np

#: Time units
Expand Down
1 change: 1 addition & 0 deletions soundata/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Core soundata classes
"""

import json
import os
import random
Expand Down
15 changes: 10 additions & 5 deletions soundata/datasets/dcase_bioacoustic.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,16 @@ def _metadata(self):
"subdataset": os.path.normpath(v["csv"][0])
.split(clip_id)[0]
.split(os.path.sep)[-2],
"split": "train"
if "Training" in os.path.normpath(v["csv"][0]).split(clip_id)[0]
else "validation"
if "Validation" in os.path.normpath(v["csv"][0]).split(clip_id)[0]
else "evaluation",
"split": (
"train"
if "Training" in os.path.normpath(v["csv"][0]).split(clip_id)[0]
else (
"validation"
if "Validation"
in os.path.normpath(v["csv"][0]).split(clip_id)[0]
else "evaluation"
)
),
}
for clip_id, v in self._index["clips"].items()
}
Expand Down
1 change: 0 additions & 1 deletion soundata/datasets/freefield1010.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"""


import os
from typing import BinaryIO, Optional, TextIO, Tuple

Expand Down
44 changes: 26 additions & 18 deletions soundata/datasets/fsd50k.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,32 +439,40 @@ def load_ground_truth(data_path):
if len(line) == 3:
if "collection" not in data_path:
ground_truth_dict[line[0]] = {
"tags": list(line[1].split(","))
if "," in line[1]
else list([line[1]]),
"mids": list(line[2].split(","))
if "," in line[2]
else list([line[2]]),
"tags": (
list(line[1].split(","))
if "," in line[1]
else list([line[1]])
),
"mids": (
list(line[2].split(","))
if "," in line[2]
else list([line[2]])
),
"split": "test",
}
else:
ground_truth_dict[line[0]] = {
"tags": list(line[1].split(","))
if "," in line[1]
else list([line[1]]),
"mids": list(line[2].split(","))
if "," in line[2]
else list([line[2]]),
"tags": (
list(line[1].split(","))
if "," in line[1]
else list([line[1]])
),
"mids": (
list(line[2].split(","))
if "," in line[2]
else list([line[2]])
),
}
clip_ids.append(line[0])
if len(line) == 4:
ground_truth_dict[line[0]] = {
"tags": list(line[1].split(","))
if "," in line[1]
else list([line[1]]),
"mids": list(line[2].split(","))
if "," in line[2]
else list([line[2]]),
"tags": (
list(line[1].split(",")) if "," in line[1] else list([line[1]])
),
"mids": (
list(line[2].split(",")) if "," in line[2] else list([line[2]])
),
"split": "train" if line[3] == "train" else "validation",
}
clip_ids.append(line[0])
Expand Down
1 change: 1 addition & 0 deletions soundata/datasets/singapura.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
Creative Commons Attribution-ShareAlike 4.0 International.
"""

import os
from typing import Dict, List, Optional, TextIO, Union

Expand Down
27 changes: 17 additions & 10 deletions soundata/datasets/starss2022.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,13 @@ def _process_raw_events(raw_reader, dt):
# keep only one value if the event is static
azimuths_elevations = [
[
np.array([azimuth[0], elevation[0]])
if (azimuth == azimuth[0]).all() and (elevation == elevation[0]).all()
else np.concatenate(
[azimuth[:, np.newaxis], elevation[:, np.newaxis]], axis=1
(
np.array([azimuth[0], elevation[0]])
if (azimuth == azimuth[0]).all()
and (elevation == elevation[0]).all()
else np.concatenate(
[azimuth[:, np.newaxis], elevation[:, np.newaxis]], axis=1
)
)
for azimuth, elevation in zip(event_azimuths, event_elevations)
]
Expand All @@ -318,18 +321,22 @@ def _process_raw_events(raw_reader, dt):
# separate azimuths and elevations again
azimuths = [
[
azimuth_elevation[:, 0]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[0]])
(
azimuth_elevation[:, 0]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[0]])
)
for azimuth_elevation in event_azimuths_elevations
]
for event_azimuths_elevations in azimuths_elevations
]
elevations = [
[
azimuth_elevation[:, 1]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[1]])
(
azimuth_elevation[:, 1]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[1]])
)
for azimuth_elevation in event_azimuths_elevations
]
for event_azimuths_elevations in azimuths_elevations
Expand Down
27 changes: 17 additions & 10 deletions soundata/datasets/tau2020sse_nigens.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,13 @@ def _process_raw_events(raw_reader, dt):
# keep only one value if the event is static
azimuths_elevations = [
[
np.array([azimuth[0], elevation[0]])
if (azimuth == azimuth[0]).all() and (elevation == elevation[0]).all()
else np.concatenate(
[azimuth[:, np.newaxis], elevation[:, np.newaxis]], axis=1
(
np.array([azimuth[0], elevation[0]])
if (azimuth == azimuth[0]).all()
and (elevation == elevation[0]).all()
else np.concatenate(
[azimuth[:, np.newaxis], elevation[:, np.newaxis]], axis=1
)
)
for azimuth, elevation in zip(event_azimuths, event_elevations)
]
Expand All @@ -309,18 +312,22 @@ def _process_raw_events(raw_reader, dt):
# separate azimuths and elevations again
azimuths = [
[
azimuth_elevation[:, 0]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[0]])
(
azimuth_elevation[:, 0]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[0]])
)
for azimuth_elevation in event_azimuths_elevations
]
for event_azimuths_elevations in azimuths_elevations
]
elevations = [
[
azimuth_elevation[:, 1]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[1]])
(
azimuth_elevation[:, 1]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[1]])
)
for azimuth_elevation in event_azimuths_elevations
]
for event_azimuths_elevations in azimuths_elevations
Expand Down
27 changes: 17 additions & 10 deletions soundata/datasets/tau2021sse_nigens.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,13 @@ def _process_raw_events(raw_reader, dt):
# keep only one value if the event is static
azimuths_elevations = [
[
np.array([azimuth[0], elevation[0]])
if (azimuth == azimuth[0]).all() and (elevation == elevation[0]).all()
else np.concatenate(
[azimuth[:, np.newaxis], elevation[:, np.newaxis]], axis=1
(
np.array([azimuth[0], elevation[0]])
if (azimuth == azimuth[0]).all()
and (elevation == elevation[0]).all()
else np.concatenate(
[azimuth[:, np.newaxis], elevation[:, np.newaxis]], axis=1
)
)
for azimuth, elevation in zip(event_azimuths, event_elevations)
]
Expand All @@ -318,18 +321,22 @@ def _process_raw_events(raw_reader, dt):
# separate azimuths and elevations again
azimuths = [
[
azimuth_elevation[:, 0]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[0]])
(
azimuth_elevation[:, 0]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[0]])
)
for azimuth_elevation in event_azimuths_elevations
]
for event_azimuths_elevations in azimuths_elevations
]
elevations = [
[
azimuth_elevation[:, 1]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[1]])
(
azimuth_elevation[:, 1]
if len(azimuth_elevation.shape) == 2
else np.array([azimuth_elevation[1]])
)
for azimuth_elevation in event_azimuths_elevations
]
for event_azimuths_elevations in azimuths_elevations
Expand Down
1 change: 1 addition & 0 deletions soundata/jams_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Utilities for converting soundata Annotation classes to jams format.
"""

import logging
import os
from typing import Callable, List
Expand Down
2 changes: 1 addition & 1 deletion soundata/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"""Version info"""

short_version = "0.1"
version = "0.1.2"
version = "0.1.3"
1 change: 1 addition & 0 deletions tests/test_full_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This test takes a long time, but it makes sure that the datset can be locally downloaded,
validated successfully, and loaded.
"""

import os
import pytest
import tqdm
Expand Down

0 comments on commit 62fdaa6

Please sign in to comment.