From 6f597360688edc979dde20c7bfb1bd1c5aef4a9c Mon Sep 17 00:00:00 2001 From: Theodore Kisner Date: Thu, 2 Jan 2025 00:26:30 -0800 Subject: [PATCH] Allow truncation of extreme data values during float to int32 conversion --- flacarray/__init__.py | 2 +- flacarray/libflacarray/utils.c | 22 ++++++++++++++-------- pyproject.toml | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/flacarray/__init__.py b/flacarray/__init__.py index a5ec41a..0dff32c 100644 --- a/flacarray/__init__.py +++ b/flacarray/__init__.py @@ -14,6 +14,6 @@ # Set the log level logging.basicConfig(level=log_level) -__version__ = "0.2.2" +__version__ = "0.2.3" from .array import FlacArray diff --git a/flacarray/libflacarray/utils.c b/flacarray/libflacarray/utils.c index fb79798..b94e041 100644 --- a/flacarray/libflacarray/utils.c +++ b/flacarray/libflacarray/utils.c @@ -239,10 +239,13 @@ int float32_to_int32( } else { // We are using a pre-defined quanta per stream. squanta = quanta[istream]; - if (squanta < min_quanta) { - // The requested quanta is too small - return ERROR_CONVERT_TYPE; - } + // Commented out, since there might be times when the + // user wants to truncate the peaks of the data. + //----------------------------------------------------- + // if (squanta < min_quanta) { + // // The requested quanta is too small + // return ERROR_CONVERT_TYPE; + // } } if (squanta == 0) { @@ -313,10 +316,13 @@ int float64_to_int32( } else { // We are using a pre-defined quanta per stream. squanta = quanta[istream]; - if (squanta < min_quanta) { - // The requested quanta is too small - return ERROR_CONVERT_TYPE; - } + // Commented out, since there might be times when the + // user wants to truncate the peaks of the data. + //----------------------------------------------------- + // if (squanta < min_quanta) { + // // The requested quanta is too small + // return ERROR_CONVERT_TYPE; + // } } if (squanta == 0) { diff --git a/pyproject.toml b/pyproject.toml index 2cb1154..f50d333 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = "mesonpy" [project] name = "flacarray" -version = "0.2.2" +version = "0.2.3" description = "FLAC Compression of Arrays" readme = "README.md" maintainers = [