import: Columns are now rewritten in OBI_FLOAT if a value is > INT32_MAX

This commit is contained in:
MercierC
2021-03-29 09:00:52 +13:00
parent 6d445fe3ad
commit 3e93cfff7b
4 changed files with 10 additions and 5 deletions

View File

@ -371,8 +371,8 @@ def run(config):
# Fill value
dcols[tag][0][i] = value
except IndexError :
except (IndexError, OverflowError):
value_type = type(value)
old_column = dcols[tag][0]
old_nb_elements_per_line = old_column.nb_elements_per_line
@ -419,7 +419,7 @@ def run(config):
dcols[tag][0][i] = value
except Exception as e:
print("\nCould not import sequence id:", entry.id, "(error raised:", e, ")")
print("\nCould not import sequence:", entry, "(error raised:", e, ")")
if 'skiperror' in config['obi'] and not config['obi']['skiperror']:
raise e
else:

View File

@ -53,6 +53,8 @@ cdef extern from "obitypes.h" nogil:
extern const_char_p OBIQual_char_NA
extern uint8_t* OBIQual_int_NA
extern void* OBITuple_NA
extern obiint_t OBI_INT_MAX
const_char_p name_data_type(int data_type)

View File

@ -9,7 +9,8 @@ from obitools3.dms.capi.obitypes cimport is_a_DNA_seq, \
OBI_QUAL, \
OBI_SEQ, \
OBI_STR, \
index_t
index_t, \
OBI_INT_MAX
from obitools3.dms.capi.obierrno cimport OBI_LINE_IDX_ERROR, \
OBI_ELT_IDX_ERROR, \
@ -258,7 +259,7 @@ cdef obitype_t update_obitype(obitype_t obitype, object new_value) :
new_type = type(new_value)
if obitype == OBI_INT :
if new_type == float :
if new_type == float or new_value > OBI_INT_MAX :
return OBI_FLOAT
# TODO BOOL vers INT/FLOAT
elif new_type == str or new_type == bytes :

View File

@ -29,6 +29,8 @@
#define OBIQual_int_NA (NULL) /**< NA value for the type OBI_QUAL if the quality is in integer format */
#define OBITuple_NA (NULL) /**< NA value for tuples of any type */
#define OBI_INT_MAX (INT32_MAX) /**< Maximum value for the type OBI_INT */
/**
* @brief enum for the boolean OBIType.