Skip to content

[Bug] DatasetMetadata's optional argument class_distribution breaks when a list is passed #441

@tapyu

Description

@tapyu

Version

2.0.0 (Default)

System Information

OS: (Linux Distro, Mac, Windows)

❯ fastfetch --logo none
tapyu@thinkpad
--------------
OS: Ubuntu 24.04.3 LTS (Noble Numbat) x86_64
Host: 20QRCTO1WW (ThinkPad P73)
Kernel: Linux 6.14.0-36-generic
Uptime: 18 hours, 39 mins
Packages: 2642 (dpkg), 20 (snap)
Shell: zsh 5.9
Display (AUO109B): 3840x2160 @ 2x in 17", 60 Hz [Built-in]
DE: GNOME 46.0
WM: Mutter (X11)
WM Theme: Yaru-dark
Theme: Yaru-dark [GTK2/3/4]
Icons: Yaru-dark [GTK2/3/4]
Font: Cantarell (11pt) [GTK2/3/4]
Cursor: DMZ-White (24px)
Terminal: code 1.106.3
CPU: Intel(R) Core(TM) i7-9750H (12) @ 4.50 GHz
GPU 1: NVIDIA Quadro P620 [Discrete]
GPU 2: Intel UHD Graphics 630 @ 1.15 GHz [Integrated]
Memory: 10.95 GiB / 23.12 GiB (47%)
Swap: 0 B / 8.00 GiB (0%)
Disk (/): 201.78 GiB / 232.64 GiB (87%) - ext4
Local IP (wlp82s0): 192.168.0.8/24
Battery (5B10W13903): 100% [AC Connected]
Locale: en_US.UTF-8

Environment: (Docker, venv, conda, etc)

❯ uv pip list
Package                   Version     Editable project location
------------------------- ----------- ----------------------------
aiohappyeyeballs          2.6.1
aiohttp                   3.13.0
aiohttp-retry             2.9.1
aiosignal                 1.4.0
amqp                      5.3.1
annotated-types           0.7.0
antlr4-python3-runtime    4.9.3
anywidget                 0.9.18
appdirs                   1.4.4
astroid                   4.0.1
asttokens                 3.0.0
asyncssh                  2.21.1
atpublic                  6.0.2
attrs                     25.4.0
audioread                 3.0.1
billiard                  4.2.2
celery                    5.5.3
certifi                   2025.10.5
cffi                      2.0.0
charset-normalizer        3.4.4
click                     8.3.0
click-didyoumean          0.3.1
click-plugins             1.1.1.2
click-repl                0.3.0
code-anatel-axis4         0.1.0       /home/tapyu/git/anatel-axis4
colorama                  0.4.6
comm                      0.2.3
configobj                 5.0.9
contourpy                 1.3.3
coverage                  7.11.0
cryptography              46.0.3
cycler                    0.12.1
decorator                 5.2.1
dictdiffer                0.9.0
dill                      0.4.0
diskcache                 5.6.3
distro                    1.9.0
dpath                     2.2.0
dulwich                   0.24.5
dvc                       3.63.0
dvc-data                  3.16.12
dvc-http                  2.32.0
dvc-objects               5.1.2
dvc-render                1.0.2
dvc-studio-client         0.22.0
dvc-task                  0.40.2
entrypoints               0.4
executing                 2.2.1
filelock                  3.20.0
flatten-dict              0.4.2
flufl-lock                8.2.0
fonttools                 4.60.1
frozenlist                1.8.0
fsspec                    2025.9.0
funcy                     2.0
gitdb                     4.0.12
gitpython                 3.1.45
grandalf                  0.8
gto                       1.9.0
h5py                      3.15.0
hf-xet                    1.1.10
huggingface-hub           0.35.3
hydra-core                1.3.2
idna                      3.11
iniconfig                 2.1.0
ipython                   9.6.0
ipython-pygments-lexers   1.1.1
ipywidgets                8.1.7
isort                     7.0.0
iterative-telemetry       0.0.10
jedi                      0.19.2
jinja2                    3.1.6
joblib                    1.5.2
jsonschema                4.25.1
jsonschema-specifications 2025.9.1
jupyter-bbox-widget       0.6.0
jupyterlab-widgets        3.0.15
kiwisolver                1.4.9
kombu                     5.5.4
lazy-loader               0.4
librosa                   0.11.0
lightning-utilities       0.15.2
llvmlite                  0.45.1
loguru                    0.7.3
markdown-it-py            4.0.0
markupsafe                3.0.3
matplotlib                3.10.7
matplotlib-inline         0.1.7
mccabe                    0.7.0
mdurl                     0.1.2
mpmath                    1.3.0
msgpack                   1.1.2
multidict                 6.7.0
networkx                  3.5
numba                     0.62.1
numcodecs                 0.13.1
numpy                     1.26.4
nvidia-cublas-cu12        12.8.4.1
nvidia-cuda-cupti-cu12    12.8.90
nvidia-cuda-nvrtc-cu12    12.8.93
nvidia-cuda-runtime-cu12  12.8.90
nvidia-cudnn-cu12         9.10.2.21
nvidia-cufft-cu12         11.3.3.83
nvidia-cufile-cu12        1.13.1.3
nvidia-curand-cu12        10.3.9.90
nvidia-cusolver-cu12      11.7.3.90
nvidia-cusparse-cu12      12.5.8.93
nvidia-cusparselt-cu12    0.7.1
nvidia-nccl-cu12          2.27.5
nvidia-nvjitlink-cu12     12.8.93
nvidia-nvshmem-cu12       3.3.20
nvidia-nvtx-cu12          12.8.90
omegaconf                 2.3.0
opencv-python             4.8.0.74
orjson                    3.11.3
packaging                 25.0
pandas                    2.3.3
parso                     0.8.5
pathspec                  0.12.1
pexpect                   4.9.0
pillow                    12.0.0
platformdirs              4.5.0
pluggy                    1.6.0
pooch                     1.8.2
prompt-toolkit            3.0.52
propcache                 0.4.1
psutil                    7.1.0
psygnal                   0.15.0
ptyprocess                0.7.0
pure-eval                 0.2.3
py-cpuinfo                9.0.0
pycparser                 2.23
pydantic                  2.12.3
pydantic-core             2.41.4
pydantic-settings         2.11.0
pydot                     4.0.1
pygit2                    1.18.2
pygments                  2.19.2
pygtrie                   2.5.0
pylint                    4.0.1
pyparsing                 3.2.5
pytest                    8.4.2
pytest-cov                7.0.0
python-dateutil           2.9.0.post0
python-dotenv             1.1.1
pytorch-lightning         2.5.5
pytz                      2025.2
pywavelets                1.9.0
pyyaml                    6.0.3
referencing               0.37.0
requests                  2.32.5
rich                      14.2.0
rpds-py                   0.27.1
ruamel-yaml               0.18.15
ruamel-yaml-clib          0.2.14
safetensors               0.6.2
scikit-learn              1.7.2
scipy                     1.16.2
scmrepo                   3.5.2
seaborn                   0.13.2
semver                    3.0.4
setuptools                80.9.0
shellingham               1.5.4
shortuuid                 1.0.13
shtab                     1.7.2
sigmf                     1.2.10
six                       1.17.0
smmap                     5.0.2
soundfile                 0.13.1
soxr                      1.0.0
sqltrie                   0.11.2
stack-data                0.6.3
sympy                     1.14.0
tabulate                  0.9.0
threadpoolctl             3.6.0
timm                      1.0.20
tomlkit                   0.13.3
torch                     2.9.0
torchaudio                2.9.0
torchinfo                 1.8.0
torchmetrics              1.8.2
torchsig                  2.0.0
torchvision               0.24.0
tqdm                      4.67.1
traitlets                 5.14.3
triton                    3.5.0
typer                     0.19.2
typing-extensions         4.15.0
typing-inspection         0.4.2
tzdata                    2025.2
ultralytics               8.3.57
ultralytics-thop          2.0.17
urllib3                   2.5.0
vine                      5.1.0
voluptuous                0.15.2
wcwidth                   0.2.14
widgetsnbextension        4.0.14
yarl                      1.22.0
zc-lockfile               4.0

Description

When instantiating an object dataset_metadata from the class DatasetMetadata, it class_distribution is a np.ndarray instead of a list, dataset_metadata.to_dict() leads to

dataset_metadata.to_dict()
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/tapyu/git/anatel-axis4/.venv/lib/python3.12/site-packages/torchsig/datasets/dataset_metadata.py", line 366, in to_dict
    'class_distribution': "uniform" if self.class_distribution is None else self.class_distribution.tolist(),
                                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'tolist'

One should fix the documentation and the source code.

How to Reproduce the Bug

dataset_metadata = DatasetMetadata(
        num_iq_samples_dataset=cfg.data.n.samp.per_ex,
        ...
        class_distribution=[0.4, 0.6],
    )
dataset_metadata.to_dict()

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions