Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
eigenpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
eigenpy
Commits
fdf2a999
Verified
Commit
fdf2a999
authored
1 year ago
by
Justin Carpentier
Browse files
Options
Downloads
Patches
Plain Diff
core: add helpers in Register
parent
94e47a4f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/eigenpy/register.hpp
+19
-0
19 additions, 0 deletions
include/eigenpy/register.hpp
src/register.cpp
+11
-0
11 additions, 0 deletions
src/register.cpp
with
30 additions
and
0 deletions
include/eigenpy/register.hpp
+
19
−
0
View file @
fdf2a999
...
...
@@ -20,6 +20,25 @@ namespace eigenpy {
struct
EIGENPY_DLLAPI
Register
{
static
PyArray_Descr
*
getPyArrayDescr
(
PyTypeObject
*
py_type_ptr
);
static
PyArray_Descr
*
getPyArrayDescrFromTypeNum
(
const
int
type_num
);
template
<
typename
Scalar
>
static
PyArray_Descr
*
getPyArrayDescrFromScalarType
()
{
if
(
!
isNumpyNativeType
<
Scalar
>
())
{
const
std
::
type_info
&
info
=
typeid
(
Scalar
);
if
(
instance
().
type_to_py_type_bindings
.
find
(
&
info
)
!=
instance
().
type_to_py_type_bindings
.
end
())
{
PyTypeObject
*
py_type
=
instance
().
type_to_py_type_bindings
[
&
info
];
return
instance
().
py_array_descr_bindings
[
py_type
];
}
else
return
nullptr
;
}
else
{
PyArray_Descr
*
new_descr
=
call_PyArray_DescrFromType
(
NumpyEquivalentType
<
Scalar
>::
type_code
);
return
new_descr
;
}
}
template
<
typename
Scalar
>
static
bool
isRegistered
()
{
return
isRegistered
(
Register
::
getPyType
<
Scalar
>
());
...
...
This diff is collapsed.
Click to expand it.
src/register.cpp
+
11
−
0
View file @
fdf2a999
...
...
@@ -14,6 +14,17 @@ PyArray_Descr* Register::getPyArrayDescr(PyTypeObject* py_type_ptr) {
return
NULL
;
}
PyArray_Descr
*
Register
::
getPyArrayDescrFromTypeNum
(
const
int
type_num
)
{
if
(
type_num
>=
NPY_USERDEF
)
{
for
(
const
auto
&
elt
:
instance
().
py_array_code_bindings
)
{
if
(
elt
.
second
==
type_num
)
return
instance
().
py_array_descr_bindings
[
elt
.
first
];
}
return
nullptr
;
}
else
return
PyArray_DescrFromType
(
type_num
);
}
bool
Register
::
isRegistered
(
PyTypeObject
*
py_type_ptr
)
{
if
(
getPyArrayDescr
(
py_type_ptr
)
!=
NULL
)
return
true
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment