Skip to content

Preserve np.ndarray in field value casting #868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tombagby
Copy link

@tombagby tombagby commented May 8, 2025

The current _cast_value will always cast an np.ndarray to a python list. Instead, when the value is an array and the type to cast to is a numpy dtype, use astype and preserve the array.

The default in librosa is sr=22050, which forces resampling, it has to be set explicitly to None to preserve the original sample rate. I doubt this is intentional?

If resampling is desired, the field description should include an explicit target sample rate to enable.
@tombagby tombagby requested a review from a team as a code owner May 8, 2025 17:55
Copy link

github-actions bot commented May 8, 2025

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

[np.array([1, 2, 3]), DataType.FLOAT32, np.array([1.0, 2.0, 3.0])],
],
)
def test_cast_value_ndarray():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def test_cast_value_ndarray(conforms_to, value, data_type, expected):
  ...

Copy link
Contributor

@marcenacp marcenacp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

LGTM if you fix the red tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants