Skip to content

Commit

Permalink
Allow truncation of extreme data values during float to int32 conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
tskisner committed Jan 2, 2025
1 parent 7d835d4 commit 6f59736
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion flacarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 14 additions & 8 deletions flacarray/libflacarray/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 6f59736

Please sign in to comment.