-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Describe the Bug
I've followed the tutorial "How to analyse and represent soundscape perception" and I get an error:
File ".../test.py", line 86, in <module>
sspy.scatter(
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/soundscapy/__init__.py", line 53, in __getattr__
return import_optional(name)
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/soundscapy/_optionals.py", line 79, in import_optional
raise AttributeError(f"module 'soundscapy' has no attribute '{name}'")
AttributeError: module 'soundscapy' has no attribute 'scatter'
To Reproduce
# Import the necessary packages
import matplotlib.pyplot as plt # For creating plots
import numpy as np # For numerical operations
import pandas as pd # For data handling
import seaborn as sns # For enhanced visualizations
# Import soundscapy with the alias 'sspy'
import soundscapy as sspy
# Create a simple DataFrame with some example data
data = {
"LocationID": ["Park", "Park", "Street", "Street", "Cafe", "Cafe"],
"PAQ1": [4, 5, 2, 3, 4, 5], # Pleasant
"PAQ2": [3, 4, 4, 5, 3, 4], # Vibrant
"PAQ3": [2, 3, 5, 4, 3, 2], # Eventful
"PAQ4": [1, 2, 4, 5, 2, 1], # Chaotic
"PAQ5": [2, 1, 4, 5, 2, 1], # Annoying
"PAQ6": [3, 2, 2, 1, 3, 2], # Monotonous
"PAQ7": [4, 3, 1, 2, 3, 4], # Uneventful
"PAQ8": [5, 4, 2, 1, 4, 5], # Calm
}
# Create a DataFrame from the dictionary
example_df = pd.DataFrame(data)
# Get basic information about the DataFrame
print("\nDataFrame Info:")
example_df.info()
# Get summary statistics
print("\nSummary Statistics:")
print(example_df.describe())
# Select specific columns
print("\nJust the PAQ1 and PAQ2 columns:")
print(example_df[["PAQ1", "PAQ2"]])
# Filter rows based on a condition
print("\nOnly rows where LocationID is 'Park':")
park_data = example_df[example_df["LocationID"] == "Park"]
print(park_data)
# Calculate the mean of each PAQ by location
print("\nMean PAQ values by location:")
print(example_df.groupby("LocationID").mean())
# Load data from the International Soundscape Database (ISD)
isd_data = sspy.isd.load()
# Display basic information about the dataset
print(f"ISD Dataset shape: {isd_data.shape}")
print(f"Number of locations: {isd_data['LocationID'].nunique()}")
print(f"Number of records: {isd_data['RecordID'].nunique()}")
# Display the first few rows
print("\nFirst few rows of the ISD dataset:")
print(isd_data.head())
# Validate the ISD dataset
valid_data, excluded_data = sspy.databases.isd.validate(isd_data)
# Display validation results
print(f"Original dataset size: {len(isd_data)}")
print(f"Valid dataset size: {len(valid_data)}")
print(
f"Number of excluded data: {len(excluded_data) if excluded_data is not None else 0}"
)
# Calculate ISO coordinates
valid_data = sspy.surveys.add_iso_coords(valid_data, overwrite=True)
# Display the first few rows with ISO coordinates
print("Data with ISO coordinates:")
print(valid_data[["LocationID", "ISOPleasant", "ISOEventful"]].head())
# Select data for a specific location
location_id = "CamdenTown"
location_data = sspy.databases.isd.select_location_ids(valid_data, location_id)
print(f"Data for {location_id}:")
print(f"Number of records: {len(location_data)}")
print(f"Mean ISOPleasant: {location_data['ISOPleasant'].mean():.3f}")
print(f"Mean ISOEventful: {location_data['ISOEventful'].mean():.3f}")
# Create a scatter plot with a single line of code
sspy.scatter(
location_data,
title=f"Soundscape Perception at {location_id}",
diagonal_lines=True, # Add diagonal lines for the circumplex model
)
plt.show()Expected Behaviour
Output the scatter plot.
Actual Behaviour
File ".../test.py", line 86, in <module>
sspy.scatter(
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/soundscapy/__init__.py", line 53, in __getattr__
return import_optional(name)
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/soundscapy/_optionals.py", line 79, in import_optional
raise AttributeError(f"module 'soundscapy' has no attribute '{name}'")
AttributeError: module 'soundscapy' has no attribute 'scatter'
Version In Use
3.13
Additional Context
- Python version: 3.13
- Operating system: macOS