Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
61e3b0bd
Commit
61e3b0bd
authored
Aug 13, 2016
by
Ivan Smirnov
Browse files
Use builtin str type for recarray field names
parent
1cdd171f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
include/pybind11/numpy.h
include/pybind11/numpy.h
+4
-4
No files found.
include/pybind11/numpy.h
View file @
61e3b0bd
...
@@ -117,7 +117,7 @@ public:
...
@@ -117,7 +117,7 @@ public:
PYBIND11_OBJECT_DEFAULT
(
dtype
,
object
,
detail
::
npy_api
::
get
().
PyArrayDescr_Check_
);
PYBIND11_OBJECT_DEFAULT
(
dtype
,
object
,
detail
::
npy_api
::
get
().
PyArrayDescr_Check_
);
dtype
(
const
buffer_info
&
info
)
{
dtype
(
const
buffer_info
&
info
)
{
dtype
descr
(
_dtype_from_pep3118
()(
pybind11
::
str
(
info
.
format
)));
dtype
descr
(
_dtype_from_pep3118
()(
PYBIND11_STR_TYPE
(
info
.
format
)));
m_ptr
=
descr
.
strip_padding
().
release
().
ptr
();
m_ptr
=
descr
.
strip_padding
().
release
().
ptr
();
}
}
...
@@ -174,7 +174,7 @@ private:
...
@@ -174,7 +174,7 @@ private:
if
(
fields
.
ptr
()
==
Py_None
)
if
(
fields
.
ptr
()
==
Py_None
)
return
*
this
;
return
*
this
;
struct
field_descr
{
pybind11
::
str
name
;
object
format
;
int_
offset
;
};
struct
field_descr
{
PYBIND11_STR_TYPE
name
;
object
format
;
int_
offset
;
};
std
::
vector
<
field_descr
>
field_descriptors
;
std
::
vector
<
field_descr
>
field_descriptors
;
auto
items
=
fields
.
attr
(
"items"
).
cast
<
object
>
();
auto
items
=
fields
.
attr
(
"items"
).
cast
<
object
>
();
...
@@ -185,7 +185,7 @@ private:
...
@@ -185,7 +185,7 @@ private:
auto
offset
=
spec
[
1
].
cast
<
tuple
>
()[
1
].
cast
<
int_
>
();
auto
offset
=
spec
[
1
].
cast
<
tuple
>
()[
1
].
cast
<
int_
>
();
if
(
!
len
(
name
)
&&
format
.
kind
()
==
"V"
)
if
(
!
len
(
name
)
&&
format
.
kind
()
==
"V"
)
continue
;
continue
;
field_descriptors
.
push_back
({
name
,
format
.
strip_padding
(),
offset
});
field_descriptors
.
push_back
({
(
PYBIND11_STR_TYPE
)
name
,
format
.
strip_padding
(),
offset
});
}
}
std
::
sort
(
field_descriptors
.
begin
(),
field_descriptors
.
end
(),
std
::
sort
(
field_descriptors
.
begin
(),
field_descriptors
.
end
(),
...
@@ -405,7 +405,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
...
@@ -405,7 +405,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
for
(
auto
field
:
fields
)
{
for
(
auto
field
:
fields
)
{
if
(
!
field
.
descr
)
if
(
!
field
.
descr
)
pybind11_fail
(
"NumPy: unsupported field dtype"
);
pybind11_fail
(
"NumPy: unsupported field dtype"
);
names
.
append
(
str
(
field
.
name
));
names
.
append
(
PYBIND11_STR_TYPE
(
field
.
name
));
formats
.
append
(
field
.
descr
);
formats
.
append
(
field
.
descr
);
offsets
.
append
(
int_
(
field
.
offset
));
offsets
.
append
(
int_
(
field
.
offset
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment