Functions and files for OBIDMS columns with the type OBI_FLOAT
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from .capidmscolumn cimport *
|
from .capidmscolumn cimport *
|
||||||
from obitools3.obidms.obidmscolumn.obidmscolumn_int.capidmscolumn_int import OBIDMS_column_int
|
from obitools3.obidms.obidmscolumn.obidmscolumn_int.capidmscolumn_int import OBIDMS_column_int
|
||||||
|
from obitools3.obidms.obidmscolumn.obidmscolumn_float.capidmscolumn_float import OBIDMS_column_float
|
||||||
|
|
||||||
|
|
||||||
cdef class OBIDMS_column:
|
cdef class OBIDMS_column:
|
||||||
@ -83,7 +84,10 @@ cdef class OBIDMS_column:
|
|||||||
dms = obi_dms(dms_name_b)
|
dms = obi_dms(dms_name_b)
|
||||||
|
|
||||||
if type is None :
|
if type is None :
|
||||||
type = obi_column_get_data_type_from_name(dms, column_name_b)
|
if create :
|
||||||
|
print("A data type must be specified")
|
||||||
|
else :
|
||||||
|
type = obi_column_get_data_type_from_name(dms, column_name_b)
|
||||||
|
|
||||||
if type == 1 :
|
if type == 1 :
|
||||||
column = OBIDMS_column_int(dms_name, column_name,
|
column = OBIDMS_column_int(dms_name, column_name,
|
||||||
@ -91,6 +95,12 @@ cdef class OBIDMS_column:
|
|||||||
type, nb_elements,
|
type, nb_elements,
|
||||||
nb_elements_per_line, elements_names)
|
nb_elements_per_line, elements_names)
|
||||||
|
|
||||||
|
elif type == 2 :
|
||||||
|
column = OBIDMS_column_float(dms_name, column_name,
|
||||||
|
create, version_number,
|
||||||
|
type, nb_elements,
|
||||||
|
nb_elements_per_line, elements_names)
|
||||||
|
|
||||||
else :
|
else :
|
||||||
"Problem with the data type"
|
"Problem with the data type"
|
||||||
|
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
../../../../../src/obidmscolumn_float.c
|
||||||
|
../../../../../src/obidmscolumn_float.h
|
||||||
|
../../../../../src/obidmscolumn.h
|
||||||
|
../../../../../src/obidmscolumn.c
|
||||||
|
../../../../../src/obidmscolumndir.h
|
||||||
|
../../../../../src/obidmscolumndir.c
|
||||||
|
../../../../../src/obidms.h
|
||||||
|
../../../../../src/obidms.c
|
||||||
|
../../../../../src/obierrno.h
|
||||||
|
../../../../../src/obierrno.c
|
||||||
|
../../../../../src/obilittlebigman.h
|
||||||
|
../../../../../src/obilittlebigman.c
|
||||||
|
../../../../../src/obitypes.h
|
||||||
|
../../../../../src/obitypes.c
|
||||||
|
../../../../../src/private_at_functions.h
|
||||||
|
../../../../../src/private_at_functions.c
|
@ -0,0 +1,7 @@
|
|||||||
|
from obitools3.obidms.obidmscolumn.capidmscolumn cimport *
|
||||||
|
|
||||||
|
|
||||||
|
cdef extern from "obidmscolumn_float.h" nogil:
|
||||||
|
|
||||||
|
int obi_column_set_float(OBIDMS_column_p column, size_t line_nb, size_t element_idx, obifloat_t value)
|
||||||
|
obifloat_t obi_column_get_float(OBIDMS_column_p column, size_t line_nb, size_t element_idx)
|
@ -0,0 +1,30 @@
|
|||||||
|
#cython: language_level=3
|
||||||
|
|
||||||
|
from .capidmscolumn_float cimport *
|
||||||
|
|
||||||
|
|
||||||
|
cdef class OBIDMS_column_float(OBIDMS_column) :
|
||||||
|
|
||||||
|
def set_item(self, line_nb, element_name, value):
|
||||||
|
if element_name != "" :
|
||||||
|
element_idx = self.get_element_index_from_name(element_name)
|
||||||
|
else :
|
||||||
|
if obi_column_get_nb_elements_per_line(self.pointer) == 1 :
|
||||||
|
element_idx = 0
|
||||||
|
else :
|
||||||
|
print("An element name must be specified")
|
||||||
|
return -1
|
||||||
|
return obi_column_set_float(self.pointer, line_nb, element_idx, value)
|
||||||
|
|
||||||
|
def get_item(self, line_nb, element_name):
|
||||||
|
if element_name != "" :
|
||||||
|
element_idx = self.get_element_index_from_name(element_name)
|
||||||
|
else :
|
||||||
|
if obi_column_get_nb_elements_per_line(self.pointer) == 1 :
|
||||||
|
element_idx = 0
|
||||||
|
else :
|
||||||
|
print("An element name must be specified")
|
||||||
|
return -1
|
||||||
|
return obi_column_get_float(self.pointer, line_nb, element_idx)
|
||||||
|
|
||||||
|
|
40
src/obidmscolumn_float.c
Normal file
40
src/obidmscolumn_float.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* OBIDMS_column_float functions *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file obidsmcolumn_float.c
|
||||||
|
* @author Celine Mercier
|
||||||
|
* @date August 10th 2015
|
||||||
|
* @brief Functions handling OBIColumns containing data with the OBIType OBI_FLOAT.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "obidmscolumn.h"
|
||||||
|
#include "obitypes.h"
|
||||||
|
#include "obierrno.h"
|
||||||
|
#include "obidebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* D E F I N I T I O N O F T H E P U B L I C F U N C T I O N S
|
||||||
|
*
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
int obi_column_set_float(OBIDMS_column_p column, size_t line_nb, size_t element_idx, obifloat_t value)
|
||||||
|
{
|
||||||
|
// when/where check if can write?
|
||||||
|
*(((obifloat_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx) = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
obifloat_t obi_column_get_float(OBIDMS_column_p column, size_t line_nb, size_t element_idx)
|
||||||
|
{
|
||||||
|
return *(((obifloat_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx);
|
||||||
|
}
|
||||||
|
|
59
src/obidmscolumn_float.h
Normal file
59
src/obidmscolumn_float.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* OBIDMS_column_float header file *
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file obidsmcolumn_float.h
|
||||||
|
* @author Celine Mercier
|
||||||
|
* @date August 10th 2015
|
||||||
|
* @brief Header file for the functions handling OBIColumns containing data with the OBIType OBI_FLOAT.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "obidmscolumn.h"
|
||||||
|
#include "obitypes.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets a value in an OBIDMS column containing data with the type OBI_FLOAT.
|
||||||
|
*
|
||||||
|
* @param column a pointer as returned by obi_create_column()
|
||||||
|
* @warning Pointers returned by obi_open_column() don't allow writing.
|
||||||
|
*
|
||||||
|
* @param line_nb the number of the line where the value should be set
|
||||||
|
*
|
||||||
|
* @param element_idx the index of the element that should be set in the line
|
||||||
|
*
|
||||||
|
* @param value the value that should be set
|
||||||
|
*
|
||||||
|
* @return an integer value indicating the success of the operation.
|
||||||
|
*
|
||||||
|
* @retvalue 0 on success
|
||||||
|
* @retvalue -1 on failure and the `obi_errno` variable is set.
|
||||||
|
*
|
||||||
|
* @since August 2015
|
||||||
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||||
|
*/
|
||||||
|
int obi_column_set_float(OBIDMS_column_p column, size_t line_nb, size_t element_idx, obifloat_t value);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Recovers a value in an OBIDMS column containing data with the type OBI_FLOAT.
|
||||||
|
*
|
||||||
|
* @param column a pointer as returned by obi_create_column()
|
||||||
|
*
|
||||||
|
* @param line_nb the number of the line where the value should be recovered
|
||||||
|
*
|
||||||
|
* @param element_idx the index of the element that should be recovered in the line
|
||||||
|
*
|
||||||
|
* @return the recovered value
|
||||||
|
*
|
||||||
|
* @since August 2015
|
||||||
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||||
|
*/
|
||||||
|
obifloat_t obi_column_get_float(OBIDMS_column_p column, size_t line_nb, size_t element_idx);
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user