question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

By default, return float64, but provide options for reading different formats.

See original GitHub issue

I think it’s a good idea to return np.float32 by default (although I’m not 100% sure because the default type in NumPy is np.float64).

If the file has 64bit values, however, they shouldn’t be truncated by default.

So probably the default argument to read() should be format=None which should be changed appropriately within the function.

BTW, format may not be the best name choice for this parameter, maybe dtype would be rather what people would expect?

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bastibecommented, Aug 29, 2021

subtype is a property of soundfile.SoundFile and can have any value of soundfile._subtypes.

1reaction
bastibecommented, Mar 5, 2014

Interesting point. Come to think of it, I don’t see many reasons why we shouldn’t just switch everything over to np.float64 by default. In Numpy, pretty much everything is np.float64 by default.

The only argument against that would be that there is no microphone able to record more than 24 bits, let alone ears cabable of hearing more, which makes anything more than 32 bits kind of a waste. I can see 64 bit being useful for non-audio data though.

One could also make an argument that if the source data is, say, np.int16, read() should return exactly that. I don’t think there is much merit to this, though, since numpy integers violate too many pythonic assumptions about numbers (no infinite precision and overflow). How about providing something like read_native(), which would return the native data format of the file?

Read more comments on GitHub >

github_iconTop Results From Across the Web

By default, return float64, but provide options for reading ...
I think it's a good idea to return np.float32 by default (although I'm not 100% sure because the default type in NumPy is...
Read more >
Data Types and Formats – Data Analysis and Visualization in ...
Pandas and base Python use slightly different names for data types. ... pandas will default to float64, in case your missing value has...
Read more >
float64 with pandas to_csv - python - Stack Overflow
UPDATE: Answer was accurate at time of writing, and floating point precision is still not something you get by default with to_csv/read_csv ...
Read more >
IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
Lines with too many fields (e.g. a csv line with too many commas) will by default cause an exception to be raised, and...
Read more >
Overview of Pandas Data Types - Practical Business Python
This article will discuss the basic pandas data types (aka dtypes ), how they map to python and numpy data types and the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found