Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
21
Issues
21
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
a8f03248
Commit
a8f03248
authored
Feb 18, 2016
by
Celine Mercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Major update : views
parent
cfaf0690
Changes
46
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
3176 additions
and
1039 deletions
+3176
-1039
python/obitools3/obidms/_obidms.cfiles
python/obitools3/obidms/_obidms.cfiles
+5
-1
python/obitools3/obidms/_obidms.pxd
python/obitools3/obidms/_obidms.pxd
+59
-31
python/obitools3/obidms/_obidms.pyx
python/obitools3/obidms/_obidms.pyx
+443
-301
python/obitools3/obidms/_obidmscolumn_bool.cfiles
python/obitools3/obidms/_obidmscolumn_bool.cfiles
+2
-0
python/obitools3/obidms/_obidmscolumn_bool.pxd
python/obitools3/obidms/_obidmscolumn_bool.pxd
+4
-15
python/obitools3/obidms/_obidmscolumn_bool.pyx
python/obitools3/obidms/_obidmscolumn_bool.pyx
+26
-52
python/obitools3/obidms/_obidmscolumn_char.cfiles
python/obitools3/obidms/_obidmscolumn_char.cfiles
+2
-0
python/obitools3/obidms/_obidmscolumn_char.pxd
python/obitools3/obidms/_obidmscolumn_char.pxd
+4
-15
python/obitools3/obidms/_obidmscolumn_char.pyx
python/obitools3/obidms/_obidmscolumn_char.pyx
+27
-52
python/obitools3/obidms/_obidmscolumn_float.cfiles
python/obitools3/obidms/_obidmscolumn_float.cfiles
+2
-0
python/obitools3/obidms/_obidmscolumn_float.pxd
python/obitools3/obidms/_obidmscolumn_float.pxd
+4
-15
python/obitools3/obidms/_obidmscolumn_float.pyx
python/obitools3/obidms/_obidmscolumn_float.pyx
+28
-54
python/obitools3/obidms/_obidmscolumn_int.cfiles
python/obitools3/obidms/_obidmscolumn_int.cfiles
+2
-0
python/obitools3/obidms/_obidmscolumn_int.pxd
python/obitools3/obidms/_obidmscolumn_int.pxd
+4
-15
python/obitools3/obidms/_obidmscolumn_int.pyx
python/obitools3/obidms/_obidmscolumn_int.pyx
+28
-53
python/obitools3/obidms/_obidmscolumn_seq.cfiles
python/obitools3/obidms/_obidmscolumn_seq.cfiles
+2
-0
python/obitools3/obidms/_obidmscolumn_seq.pxd
python/obitools3/obidms/_obidmscolumn_seq.pxd
+3
-14
python/obitools3/obidms/_obidmscolumn_seq.pyx
python/obitools3/obidms/_obidmscolumn_seq.pyx
+35
-55
python/obitools3/obidms/_obidmscolumn_str.cfiles
python/obitools3/obidms/_obidmscolumn_str.cfiles
+2
-0
python/obitools3/obidms/_obidmscolumn_str.pxd
python/obitools3/obidms/_obidmscolumn_str.pxd
+3
-14
python/obitools3/obidms/_obidmscolumn_str.pyx
python/obitools3/obidms/_obidmscolumn_str.pyx
+35
-55
python/obitools3/obidms/capi/obidmscolumn.pxd
python/obitools3/obidms/capi/obidmscolumn.pxd
+161
-31
python/obitools3/obidms/capi/obitypes.pxd
python/obitools3/obidms/capi/obitypes.pxd
+11
-6
python/obitools3/obidms/capi/obiview.pxd
python/obitools3/obidms/capi/obiview.pxd
+68
-0
src/obidms.c
src/obidms.c
+2
-2
src/obidms.h
src/obidms.h
+1
-1
src/obidmscolumn.c
src/obidmscolumn.c
+53
-114
src/obidmscolumn.h
src/obidmscolumn.h
+6
-17
src/obidmscolumn_bool.c
src/obidmscolumn_bool.c
+78
-18
src/obidmscolumn_bool.h
src/obidmscolumn_bool.h
+77
-2
src/obidmscolumn_char.c
src/obidmscolumn_char.c
+78
-18
src/obidmscolumn_char.h
src/obidmscolumn_char.h
+77
-2
src/obidmscolumn_float.c
src/obidmscolumn_float.c
+77
-18
src/obidmscolumn_float.h
src/obidmscolumn_float.h
+77
-2
src/obidmscolumn_idx.c
src/obidmscolumn_idx.c
+72
-0
src/obidmscolumn_idx.h
src/obidmscolumn_idx.h
+30
-0
src/obidmscolumn_int.c
src/obidmscolumn_int.c
+79
-18
src/obidmscolumn_int.h
src/obidmscolumn_int.h
+75
-0
src/obidmscolumn_seq.c
src/obidmscolumn_seq.c
+84
-23
src/obidmscolumn_seq.h
src/obidmscolumn_seq.h
+77
-0
src/obidmscolumn_str.c
src/obidmscolumn_str.c
+83
-23
src/obidmscolumn_str.h
src/obidmscolumn_str.h
+77
-0
src/obierrno.h
src/obierrno.h
+2
-0
src/obitypes.h
src/obitypes.h
+4
-2
src/obiview.c
src/obiview.c
+949
-0
src/obiview.h
src/obiview.h
+158
-0
No files found.
python/obitools3/obidms/_obidms.cfiles
View file @
a8f03248
../../../src/obidms.h
../../../src/obidms.c
../../../src/obiview.h
../../../src/obiview.c
../../../src/obidmscolumn.h
../../../src/obidmscolumn.c
../../../src/obidmscolumndir.h
...
...
@@ -15,4 +17,6 @@
../../../src/obiavl.h
../../../src/obiavl.c
../../../src/encode.h
../../../src/encode.c
\ No newline at end of file
../../../src/encode.c
../../../src/obidmscolumn_idx.h
../../../src/obidmscolumn_idx.c
python/obitools3/obidms/_obidms.pxd
View file @
a8f03248
...
...
@@ -2,52 +2,80 @@
from
.capi.obidms
cimport
OBIDMS_p
from
.capi.obidmscolumn
cimport
OBIDMS_column_p
from
.capi.obiview
cimport
Obiview_p
from
.capi.obitypes
cimport
obiversion_t
,
OBIType_t
,
index_t
cdef
class
OBIDMS_column
cdef
class
OBIDMS
:
cdef
OBIDMS_p
pointer
cdef
str
dms_name
cpdef
dict
list
(
self
)
cpdef
close
(
self
)
cpdef
OBIDMS_column
open_column
(
self
,
str
column_name
,
bint
create
=*
,
bint
clone
=*
,
bint
clone_data
=*
,
bint
referring
=*
,
obiversion_t
version_number
=*
,
str
type
=*
,
index_t
nb_lines
=*
,
index_t
nb_elements_per_line
=*
,
list
elements_names
=*
,
str
avl_name
=*
,
str
comments
=*
)
cdef
class
OBIDMS_column
:
cdef
OBIDMS_column_p
pointer
cdef
OBIDMS_column_p
*
pointer
cdef
OBIDMS
dms
cdef
Obiview_p
view
cdef
str
data_type
cdef
str
dms_name
cdef
str
column_name
cdef
index_t
nb_elements_per_line
cdef
list
elements_names
cpdef
OBIDMS_column_p
referred_column_pointer
# cpdef object get_item(self, index_t line_nb, str element_name) TODO can't declare because not the same in all subclasses
# cpdef set_item(self, index_t line_nb, str element_name, object value) TODO can't declare because object value
cpdef
grep_line
(
self
,
index_t
line_nb
)
cpdef
update_pointer
(
self
)
cpdef
list
get_elements_names
(
self
)
cpdef
str
get_data_type
(
self
)
cpdef
index_t
get_nb_lines_used
(
self
)
cpdef
str
get_creation_date
(
self
)
cpdef
str
get_comments
(
self
)
cpdef
close
(
self
)
@
staticmethod
cdef
object
get_subclass_type
(
OBIDMS_column_p
column_p
)
cdef
class
OBIDMS_column_multi_elts
(
OBIDMS_column
):
cpdef
set_line
(
self
,
index_t
line_nb
,
dict
values
)
cdef
class
OBIDMS_column_line
:
cdef
OBIDMS_column
column
cdef
index_t
index
cdef
class
OBIView
:
cdef
Obiview_p
pointer
cdef
str
name
cdef
dict
columns
cdef
dict
columns_pp
# TODO this dict might be unnecessary
cdef
OBIDMS
dms
cpdef
delete_column
(
self
,
str
column_name
)
cpdef
add_column
(
self
,
str
column_name
,
obiversion_t
version_number
=*
,
str
type
=*
,
index_t
nb_lines
=*
,
index_t
nb_elements_per_line
=*
,
list
elements_names
=*
,
str
avl_name
=*
,
str
comments
=*
,
bint
create
=*
)
cpdef
select_line
(
self
,
index_t
line_nb
)
cpdef
select_lines
(
self
,
list
line_selection
)
cpdef
save_and_close
(
self
)
cdef
class
OBIView_line
:
cdef
index_t
index
cdef
OBIView
view
cdef
class
OBIDMS
:
cdef
OBIDMS_p
pointer
cdef
str
dms_name
cpdef
close
(
self
)
cpdef
OBIView
open_view
(
self
,
str
view_name
)
cpdef
OBIView
new_view
(
self
,
str
view_name
,
object
view_to_clone
=*
,
list
line_selection
=*
)
python/obitools3/obidms/_obidms.pyx
View file @
a8f03248
This diff is collapsed.
Click to expand it.
python/obitools3/obidms/_obidmscolumn_bool.cfiles
View file @
a8f03248
../../../src/obidmscolumn_bool.c
../../../src/obidmscolumn_bool.h
../../../src/obiview.h
../../../src/obiview.c
../../../src/obidmscolumn.h
../../../src/obidmscolumn.c
../../../src/obidmscolumndir.h
...
...
python/obitools3/obidms/_obidmscolumn_bool.pxd
View file @
a8f03248
#cython: language_level=3
from
.capi.obitypes
cimport
obibool_t
,
index_t
from
._obidms
cimport
OBIDMS_column
from
.capi.obitypes
cimport
index_t
from
._obidms
cimport
OBIDMS_column
,
OBIDMS_column_multi_elts
cdef
class
OBIDMS_column_bool
(
OBIDMS_column
):
cpdef
object
get_line
(
self
,
index_t
line_nb
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
)
cpdef
close
(
self
)
cdef
class
OBIDMS_column_bool_writable
(
OBIDMS_column_bool
):
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
)
cpdef
close
(
self
)
cdef
class
OBIDMS_column_bool_multi_elts
(
OBIDMS_column_bool
):
cdef
class
OBIDMS_column_multi_elts_bool
(
OBIDMS_column_multi_elts
):
cpdef
object
get_item
(
self
,
index_t
line_nb
,
str
element_name
)
cpdef
object
get_line
(
self
,
index_t
line_nb
)
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
obibool_t
value
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
)
cdef
class
OBIDMS_column_bool_multi_elts_writable
(
OBIDMS_column_bool_multi_elts
):
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
obibool_t
value
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
)
cpdef
close
(
self
)
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
object
value
)
python/obitools3/obidms/_obidmscolumn_bool.pyx
View file @
a8f03248
#cython: language_level=3
from
.capi.obidmscolumn
cimport
obi_close_column
,
\
obi_truncate_and_close_column
,
\
obi_column_get_obibool_with_elt_name
,
\
obi_column_get_obibool_with_elt_idx
,
\
obi_column_set_obibool_with_elt_name
,
\
obi_column_set_obibool_with_elt_idx
from
.capi.obidmscolumn
cimport
obi_truncate_and_close_column
,
\
obi_column_get_obibool_with_elt_name_in_view
,
\
obi_column_get_obibool_with_elt_idx_in_view
,
\
obi_column_set_obibool_with_elt_name_in_view
,
\
obi_column_set_obibool_with_elt_idx_in_view
from
.capi.obierrno
cimport
obi_errno
from
.capi.obitypes
cimport
OBIBool_NA
from
.capi.obitypes
cimport
OBIBool_NA
,
obibool_t
from
obitools3.utils
cimport
str2bytes
...
...
@@ -19,7 +18,7 @@ cdef class OBIDMS_column_bool(OBIDMS_column):
cpdef
object
get_line
(
self
,
index_t
line_nb
):
cdef
obibool_t
value
cdef
object
result
value
=
obi_column_get_obibool_with_elt_idx
(
self
.
pointer
,
line_nb
,
0
)
value
=
obi_column_get_obibool_with_elt_idx
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
0
)
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
)
if
value
==
OBIBool_NA
:
...
...
@@ -27,32 +26,20 @@ cdef class OBIDMS_column_bool(OBIDMS_column):
else
:
result
=
PyBool_FromLong
(
value
)
return
result
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
):
raise
Exception
(
"Column is read-only"
)
cpdef
close
(
self
):
if
obi_close_column
(
self
.
pointer
)
<
0
:
raise
Exception
(
"Problem closing a column"
)
cdef
class
OBIDMS_column_bool_writable
(
OBIDMS_column_bool
):
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
):
if
obi_column_set_obibool_with_elt_idx
(
self
.
pointer
,
line_nb
,
0
,
<
obibool_t
>
value
)
<
0
:
if
value
is
None
:
value
=
OBIBool_NA
if
obi_column_set_obibool_with_elt_idx_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
<
obibool_t
>
value
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
cpdef
close
(
self
):
if
obi_truncate_and_close_column
(
self
.
pointer
)
<
0
:
raise
Exception
(
"Problem closing a column"
)
cdef
class
OBIDMS_column_
bool_multi_elts
(
OBIDMS_column_bool
):
cdef
class
OBIDMS_column_
multi_elts_bool
(
OBIDMS_column_multi_elts
):
cpdef
object
get_item
(
self
,
index_t
line_nb
,
str
element_name
):
cdef
obibool_t
value
cdef
object
result
value
=
obi_column_get_obibool_with_elt_name
(
self
.
pointer
,
line_nb
,
str2bytes
(
element_name
))
value
=
obi_column_get_obibool_with_elt_name
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
str2bytes
(
element_name
))
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
,
element_name
)
if
value
==
OBIBool_NA
:
...
...
@@ -63,42 +50,29 @@ cdef class OBIDMS_column_bool_multi_elts(OBIDMS_column_bool):
cpdef
object
get_line
(
self
,
index_t
line_nb
)
:
cdef
obibool_t
value
cdef
object
result
cdef
object
value_in_result
cdef
dict
result
cdef
index_t
i
cdef
bint
all_NA
result
=
{}
all_NA
=
True
for
i
in
range
(
self
.
nb_elements_per_line
)
:
value
=
obi_column_get_obibool_with_elt_idx
(
self
.
pointer
,
line_nb
,
i
)
value
=
obi_column_get_obibool_with_elt_idx
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
i
)
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
)
result
[
self
.
elements_names
[
i
]]
=
PyBool_FromLong
(
value
)
if
all_NA
and
(
value
!=
OBIBool_NA
)
:
raise
IndexError
(
line_nb
)
if
value
==
OBIBool_NA
:
value_in_result
=
None
else
:
value_in_result
=
PyBool_FromLong
(
value
)
result
[
self
.
elements_names
[
i
]]
=
value_in_result
if
all_NA
and
(
value_in_result
is
not
None
)
:
all_NA
=
False
if
all_NA
:
result
=
None
return
result
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
obibool_t
value
):
raise
Exception
(
"Column is read-only"
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
):
raise
Exception
(
"Column is read-only"
)
cdef
class
OBIDMS_column_bool_multi_elts_writable
(
OBIDMS_column_bool_multi_elts
):
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
obibool_t
value
):
if
obi_column_set_obibool_with_elt_name
(
self
.
pointer
,
line_nb
,
str2bytes
(
element_name
),
value
)
<
0
:
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
object
value
):
if
value
is
None
:
value
=
OBIBool_NA
if
obi_column_set_obibool_with_elt_name_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
],
line_nb
,
str2bytes
(
element_name
),
<
obibool_t
>
value
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
):
cdef
obibool_t
value
for
element_name
in
values
:
value
=
<
obibool_t
>
values
[
element_name
]
self
.
set_item
(
line_nb
,
element_name
,
value
)
cpdef
close
(
self
):
if
obi_truncate_and_close_column
(
self
.
pointer
)
<
0
:
raise
Exception
(
"Problem closing a column"
)
python/obitools3/obidms/_obidmscolumn_char.cfiles
View file @
a8f03248
../../../src/obidmscolumn_char.c
../../../src/obidmscolumn_char.h
../../../src/obiview.h
../../../src/obiview.c
../../../src/obidmscolumn.h
../../../src/obidmscolumn.c
../../../src/obidmscolumndir.h
...
...
python/obitools3/obidms/_obidmscolumn_char.pxd
View file @
a8f03248
#cython: language_level=3
from
.capi.obitypes
cimport
obichar_t
,
index_t
from
._obidms
cimport
OBIDMS_column
from
.capi.obitypes
cimport
index_t
from
._obidms
cimport
OBIDMS_column
,
OBIDMS_column_multi_elts
cdef
class
OBIDMS_column_char
(
OBIDMS_column
):
cpdef
object
get_line
(
self
,
index_t
line_nb
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
)
cpdef
close
(
self
)
cdef
class
OBIDMS_column_char_writable
(
OBIDMS_column_char
):
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
)
cpdef
close
(
self
)
cdef
class
OBIDMS_column_char_multi_elts
(
OBIDMS_column_char
):
cdef
class
OBIDMS_column_multi_elts_char
(
OBIDMS_column_multi_elts
):
cpdef
object
get_item
(
self
,
index_t
line_nb
,
str
element_name
)
cpdef
object
get_line
(
self
,
index_t
line_nb
)
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
str
value
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
)
cdef
class
OBIDMS_column_char_multi_elts_writable
(
OBIDMS_column_char_multi_elts
):
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
str
value
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
)
cpdef
close
(
self
)
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
object
value
)
python/obitools3/obidms/_obidmscolumn_char.pyx
View file @
a8f03248
#cython: language_level=3
from
.capi.obidmscolumn
cimport
obi_close_column
,
\
obi_truncate_and_close_column
,
\
obi_column_get_obichar_with_elt_name
,
\
obi_column_get_obichar_with_elt_idx
,
\
obi_column_set_obichar_with_elt_name
,
\
obi_column_set_obichar_with_elt_idx
from
.capi.obidmscolumn
cimport
obi_truncate_and_close_column
,
\
obi_column_get_obichar_with_elt_name_in_view
,
\
obi_column_get_obichar_with_elt_idx_in_view
,
\
obi_column_set_obichar_with_elt_name_in_view
,
\
obi_column_set_obichar_with_elt_idx_in_view
from
.capi.obierrno
cimport
obi_errno
from
.capi.obitypes
cimport
OBIChar_NA
from
.capi.obitypes
cimport
OBIChar_NA
,
obichar_t
from
obitools3.utils
cimport
str2bytes
,
bytes2str
...
...
@@ -17,7 +16,7 @@ cdef class OBIDMS_column_char(OBIDMS_column):
cpdef
object
get_line
(
self
,
index_t
line_nb
):
cdef
obichar_t
value
cdef
object
result
value
=
obi_column_get_obichar_with_elt_idx
(
self
.
pointer
,
line_nb
,
0
)
value
=
obi_column_get_obichar_with_elt_idx
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
0
)
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
)
if
value
==
OBIChar_NA
:
...
...
@@ -27,30 +26,18 @@ cdef class OBIDMS_column_char(OBIDMS_column):
return
result
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
):
raise
Exception
(
"Column is read-only"
)
cpdef
close
(
self
):
if
obi_close_column
(
self
.
pointer
)
<
0
:
raise
Exception
(
"Problem closing a column"
)
cdef
class
OBIDMS_column_char_writable
(
OBIDMS_column_char
):
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
):
if
obi_column_set_obichar_with_elt_idx
(
self
.
pointer
,
line_nb
,
0
,
str2bytes
(
value
)[
0
])
<
0
:
if
value
is
None
:
value
=
OBIChar_NA
if
obi_column_set_obichar_with_elt_idx_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
str2bytes
(
value
)[
0
])
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
cpdef
close
(
self
):
if
obi_truncate_and_close_column
(
self
.
pointer
)
<
0
:
raise
Exception
(
"Problem closing a column"
)
cdef
class
OBIDMS_column_
char_multi_elts
(
OBIDMS_column_char
):
cdef
class
OBIDMS_column_
multi_elts_char
(
OBIDMS_column_multi_elts
):
cpdef
object
get_item
(
self
,
index_t
line_nb
,
str
element_name
):
cdef
obichar_t
value
cdef
object
result
value
=
obi_column_get_obichar_with_elt_name
(
self
.
pointer
,
line_nb
,
str2bytes
(
element_name
))
value
=
obi_column_get_obichar_with_elt_name
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
str2bytes
(
element_name
))
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
,
element_name
)
if
value
==
OBIChar_NA
:
...
...
@@ -58,45 +45,33 @@ cdef class OBIDMS_column_char_multi_elts(OBIDMS_column_char):
else
:
result
=
bytes2str
(
value
)
return
result
cpdef
object
get_line
(
self
,
index_t
line_nb
)
:
cdef
obichar_t
value
cdef
object
result
cdef
object
value_in_result
cdef
dict
result
cdef
index_t
i
cdef
bint
all_NA
result
=
{}
all_NA
=
True
for
i
in
range
(
self
.
nb_elements_per_line
)
:
value
=
obi_column_get_obichar_with_elt_idx
(
self
.
pointer
,
line_nb
,
i
)
value
=
obi_column_get_obichar_with_elt_idx
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
i
)
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
)
result
[
self
.
elements_names
[
i
]]
=
bytes2str
(
value
)
if
all_NA
and
(
value
!=
OBIChar_NA
)
:
raise
IndexError
(
line_nb
)
if
value
==
OBIChar_NA
:
value_in_result
=
None
else
:
value_in_result
=
bytes2str
(
value
)
result
[
self
.
elements_names
[
i
]]
=
value_in_result
if
all_NA
and
(
value_in_result
is
not
None
)
:
all_NA
=
False
if
all_NA
:
result
=
None
return
result
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
str
value
):
raise
Exception
(
"Column is read-only"
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
):
raise
Exception
(
"Column is read-only"
)
cdef
class
OBIDMS_column_char_multi_elts_writable
(
OBIDMS_column_char_multi_elts
):
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
str
value
):
if
obi_column_set_obichar_with_elt_name
(
self
.
pointer
,
line_nb
,
str2bytes
(
element_name
),
str2bytes
(
value
)[
0
])
<
0
:
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
object
value
):
if
value
is
None
:
value
=
OBIChar_NA
if
obi_column_set_obichar_with_elt_name_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
],
line_nb
,
str2bytes
(
element_name
),
str2bytes
(
value
)[
0
])
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
):
cdef
str
value
for
element_name
in
values
:
value
=
values
[
element_name
]
self
.
set_item
(
line_nb
,
element_name
,
value
)
cpdef
close
(
self
):
if
obi_truncate_and_close_column
(
self
.
pointer
)
<
0
:
raise
Exception
(
"Problem closing a column"
)
python/obitools3/obidms/_obidmscolumn_float.cfiles
View file @
a8f03248
../../../src/obidmscolumn_float.c
../../../src/obidmscolumn_float.h
../../../src/obiview.h
../../../src/obiview.c
../../../src/obidmscolumn.h
../../../src/obidmscolumn.c
../../../src/obidmscolumndir.h
...
...
python/obitools3/obidms/_obidmscolumn_float.pxd
View file @
a8f03248
#cython: language_level=3
from
.capi.obitypes
cimport
obifloat_t
,
index_t
from
._obidms
cimport
OBIDMS_column
from
.capi.obitypes
cimport
index_t
from
._obidms
cimport
OBIDMS_column
,
OBIDMS_column_multi_elts
cdef
class
OBIDMS_column_float
(
OBIDMS_column
):
cpdef
object
get_line
(
self
,
index_t
line_nb
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
)
cpdef
close
(
self
)
cdef
class
OBIDMS_column_float_writable
(
OBIDMS_column_float
):
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
)
cpdef
close
(
self
)
cdef
class
OBIDMS_column_float_multi_elts
(
OBIDMS_column_float
):
cdef
class
OBIDMS_column_multi_elts_float
(
OBIDMS_column_multi_elts
):
cpdef
object
get_item
(
self
,
index_t
line_nb
,
str
element_name
)
cpdef
object
get_line
(
self
,
index_t
line_nb
)
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
obifloat_t
value
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
)
cdef
class
OBIDMS_column_float_multi_elts_writable
(
OBIDMS_column_float_multi_elts
):
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
obifloat_t
value
)
cpdef
set_line
(
self
,
index_t
line_nb
,
object
values
)
cpdef
close
(
self
)
cpdef
set_item
(
self
,
index_t
line_nb
,
str
element_name
,
object
value
)
python/obitools3/obidms/_obidmscolumn_float.pyx
View file @
a8f03248
#cython: language_level=3
from
.capi.obidmscolumn
cimport
obi_close_column
,
\
obi_truncate_and_close_column
,
\
obi_column_get_obifloat_with_elt_name
,
\
obi_column_get_obifloat_with_elt_idx
,
\
obi_column_set_obifloat_with_elt_name
,
\
obi_column_set_obifloat_with_elt_idx
from
.capi.obidmscolumn
cimport
obi_truncate_and_close_column
,
\
obi_column_get_obifloat_with_elt_name_in_view
,
\
obi_column_get_obifloat_with_elt_idx_in_view
,
\
obi_column_set_obifloat_with_elt_name_in_view
,
\
obi_column_set_obifloat_with_elt_idx_in_view
from
.capi.obierrno
cimport
obi_errno
from
.capi.obitypes
cimport
OBIFloat_NA
from
.capi.obitypes
cimport
OBIFloat_NA
,
obifloat_t
from
obitools3.utils
cimport
str2bytes
...
...
@@ -17,7 +16,7 @@ cdef class OBIDMS_column_float(OBIDMS_column):
cpdef
object
get_line
(
self
,
index_t
line_nb
):
cdef
obifloat_t
value
cdef
object
result
value
=
obi_column_get_obifloat_with_elt_idx
(
self
.
pointer
,
line_nb
,
0
)
value
=
obi_column_get_obifloat_with_elt_idx
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
0
)
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
)
if
value
==
OBIFloat_NA
:
...
...
@@ -27,30 +26,18 @@ cdef class OBIDMS_column_float(OBIDMS_column):
return
result
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
):
raise
Exception
(
"Column is read-only"
)
cpdef
close
(
self
):
if
obi_close_column
(
self
.
pointer
)
<
0
:
raise
Exception
(
"Problem closing a column"
)
cdef
class
OBIDMS_column_float_writable
(
OBIDMS_column_float
):
cpdef
set_line
(
self
,
index_t
line_nb
,
object
value
):
if
obi_column_set_obifloat_with_elt_idx
(
self
.
pointer
,
line_nb
,
0
,
<
obifloat_t
>
value
)
<
0
:
if
value
is
None
:
value
=
OBIFloat_NA
if
obi_column_set_obifloat_with_elt_idx_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
],
line_nb
,
0
,
<
obifloat_t
>
value
)
<
0
:
raise
Exception
(
"Problem setting a value in a column"
)
cpdef
close
(
self
):
if
obi_truncate_and_close_column
(
self
.
pointer
)
<
0
:
raise
Exception
(
"Problem closing a column"
)
cdef
class
OBIDMS_column_float_multi_elts
(
OBIDMS_column_float
):
cdef
class
OBIDMS_column_multi_elts_float
(
OBIDMS_column_multi_elts
):
cpdef
object
get_item
(
self
,
index_t
line_nb
,
str
element_name
):
cdef
obifloat_t
value
cdef
object
result
value
=
obi_column_get_obifloat_with_elt_name
(
self
.
pointer
,
line_nb
,
str2bytes
(
element_name
))
value
=
obi_column_get_obifloat_with_elt_name
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
str2bytes
(
element_name
))
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
,
element_name
)
if
value
==
OBIFloat_NA
:
...
...
@@ -58,46 +45,33 @@ cdef class OBIDMS_column_float_multi_elts(OBIDMS_column_float):
else
:
result
=
<
double
>
value
return
result
cpdef
object
get_line
(
self
,
index_t
line_nb
)
:
cdef
obifloat_t
value
cdef
object
result
cdef
object
value_in_result
cdef
dict
result
cdef
index_t
i
cdef
bint
all_NA
result
=
{}
all_NA
=
True
for
i
in
range
(
self
.
nb_elements_per_line
)
:
value
=
obi_column_get_obifloat_with_elt_idx
(
self
.
pointer
,
line_nb
,
i
)
value
=
obi_column_get_obifloat_with_elt_idx
_in_view
(
self
.
view
,
(
self
.
pointer
)[
0
]
,
line_nb
,
i
)
if
obi_errno
>
0
:
raise
IndexError
(
line_nb
)
result
[
self
.
elements_names
[
i
]]
=
<
double
>
value
if
all_NA
and
(
value
!=
OBIFloat_NA
)
:
raise
IndexError
(
line_nb
)
if
value
==
OBIFloat_NA
: