Skip to content

Commit 3b2c417

Browse files
authored
Clean up int/float logic (#71)
* clean up logic * bump version
1 parent f275bce commit 3b2c417

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

VERSION.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
11.3.0
2-
- Convert floats back to integers from Terra tables
1+
11.3.1
2+
- Clean up float/int logic to be more concise

ops_utils/tdr_utils/tdr_schema_utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,8 @@ def _determine_if_float_or_int(self, interpreted_numbers: list[Union[int, float]
164164
# If all values are int, return int type
165165
if all(isinstance(row_value, int) for row_value in non_nan_numbers):
166166
return self.PYTHON_TDR_DATA_TYPE_MAPPING[int]
167-
# If all values are float, return float type
168-
elif all(isinstance(row_value, float) for row_value in non_nan_numbers):
169-
return self.PYTHON_TDR_DATA_TYPE_MAPPING[float]
170-
# If ANY are float, return float type
171-
else:
172-
return self.PYTHON_TDR_DATA_TYPE_MAPPING[float]
167+
# If ANY or ALL values are float, return float type
168+
return self.PYTHON_TDR_DATA_TYPE_MAPPING[float]
173169

174170
def _python_type_to_tdr_type_conversion(self, values_for_header: list[Any]) -> str:
175171
"""
@@ -221,7 +217,6 @@ def _python_type_to_tdr_type_conversion(self, values_for_header: list[Any]) -> s
221217

222218
# If none of the above special cases apply, use the first of the non-null values to determine the
223219
# TDR data type
224-
225220
first_value = non_none_values[0]
226221
if isinstance(first_value, list):
227222
return self.PYTHON_TDR_DATA_TYPE_MAPPING[type(first_value[0])]

0 commit comments

Comments
 (0)