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
953660b3
Commit
953660b3
authored
2 years ago
by
Wilson Jallet
Browse files
Options
Downloads
Patches
Plain Diff
Run pre-commit on copyable, pickle-vector, std-aligned-vector
remove references to aligned
parent
7ec0e310
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/eigenpy/copyable.hpp
+22
-24
22 additions, 24 deletions
include/eigenpy/copyable.hpp
include/eigenpy/pickle-vector.hpp
+35
-38
35 additions, 38 deletions
include/eigenpy/pickle-vector.hpp
include/eigenpy/std-aligned-vector.hpp
+66
-65
66 additions, 65 deletions
include/eigenpy/std-aligned-vector.hpp
with
123 additions
and
127 deletions
include/eigenpy/copyable.hpp
+
22
−
24
View file @
953660b3
...
...
@@ -7,28 +7,26 @@
#include
<boost/python.hpp>
namespace
pinocchio
{
namespace
python
{
namespace
bp
=
boost
::
python
;
///
/// \brief Add the Python method copy to allow a copy of this by calling the copy constructor.
///
template
<
class
C
>
struct
CopyableVisitor
:
public
bp
::
def_visitor
<
CopyableVisitor
<
C
>
>
{
template
<
class
PyClass
>
void
visit
(
PyClass
&
cl
)
const
{
cl
.
def
(
"copy"
,
&
copy
,
bp
::
arg
(
"self"
),
"Returns a copy of *this."
);
}
private
:
static
C
copy
(
const
C
&
self
)
{
return
C
(
self
);
}
};
}
// namespace python
}
// namespace pinocchio
namespace
pinocchio
{
namespace
python
{
#endif // ifndef __pinocchio_python_utils_copyable_hpp__
namespace
bp
=
boost
::
python
;
///
/// \brief Add the Python method copy to allow a copy of this by calling the
/// copy constructor.
///
template
<
class
C
>
struct
CopyableVisitor
:
public
bp
::
def_visitor
<
CopyableVisitor
<
C
>
>
{
template
<
class
PyClass
>
void
visit
(
PyClass
&
cl
)
const
{
cl
.
def
(
"copy"
,
&
copy
,
bp
::
arg
(
"self"
),
"Returns a copy of *this."
);
}
private
:
static
C
copy
(
const
C
&
self
)
{
return
C
(
self
);
}
};
}
// namespace python
}
// namespace pinocchio
#endif // ifndef __pinocchio_python_utils_copyable_hpp__
This diff is collapsed.
Click to expand it.
include/eigenpy/pickle-vector.hpp
+
35
−
38
View file @
953660b3
...
...
@@ -6,46 +6,43 @@
#define __pinocchio_python_utils_pickle_vector_hpp__
#include
<boost/python.hpp>
#include
<boost/python/tuple.hpp>
#include
<boost/python/stl_iterator.hpp>
#include
<boost/python/tuple.hpp>
namespace
pinocchio
{
namespace
python
{
///
/// \brief Create a pickle interface for the std::vector and aligned vector
///
/// \tparam VecType Vector Type to pickle
///
template
<
typename
VecType
>
struct
PickleVector
:
boost
::
python
::
pickle_suite
{
static
boost
::
python
::
tuple
getinitargs
(
const
VecType
&
)
{
return
boost
::
python
::
make_tuple
();
}
static
boost
::
python
::
tuple
getstate
(
boost
::
python
::
object
op
)
{
return
boost
::
python
::
make_tuple
(
boost
::
python
::
list
(
boost
::
python
::
extract
<
const
VecType
&>
(
op
)()));
}
static
void
setstate
(
boost
::
python
::
object
op
,
boost
::
python
::
tuple
tup
)
{
if
(
boost
::
python
::
len
(
tup
)
>
0
)
{
VecType
&
o
=
boost
::
python
::
extract
<
VecType
&>
(
op
)();
boost
::
python
::
stl_input_iterator
<
typename
VecType
::
value_type
>
begin
(
tup
[
0
]),
end
;
while
(
begin
!=
end
)
{
o
.
push_back
(
*
begin
);
++
begin
;
}
}
namespace
pinocchio
{
namespace
python
{
///
/// \brief Create a pickle interface for the std::vector
///
/// \tparam VecType Vector Type to pickle
///
template
<
typename
VecType
>
struct
PickleVector
:
boost
::
python
::
pickle_suite
{
static
boost
::
python
::
tuple
getinitargs
(
const
VecType
&
)
{
return
boost
::
python
::
make_tuple
();
}
static
boost
::
python
::
tuple
getstate
(
boost
::
python
::
object
op
)
{
return
boost
::
python
::
make_tuple
(
boost
::
python
::
list
(
boost
::
python
::
extract
<
const
VecType
&>
(
op
)()));
}
static
void
setstate
(
boost
::
python
::
object
op
,
boost
::
python
::
tuple
tup
)
{
if
(
boost
::
python
::
len
(
tup
)
>
0
)
{
VecType
&
o
=
boost
::
python
::
extract
<
VecType
&>
(
op
)();
boost
::
python
::
stl_input_iterator
<
typename
VecType
::
value_type
>
begin
(
tup
[
0
]),
end
;
while
(
begin
!=
end
)
{
o
.
push_back
(
*
begin
);
++
begin
;
}
static
bool
getstate_manages_dict
()
{
return
true
;
}
};
}
}
}
#endif // ifndef __pinocchio_python_utils_pickle_vector_hpp__
static
bool
getstate_manages_dict
()
{
return
true
;
}
};
}
// namespace python
}
// namespace pinocchio
#endif // ifndef __pinocchio_python_utils_pickle_vector_hpp__
This diff is collapsed.
Click to expand it.
include/eigenpy/std-aligned-vector.hpp
+
66
−
65
View file @
953660b3
...
...
@@ -8,77 +8,78 @@
#include
<boost/python.hpp>
#include
<string>
#include
"pinocchio/container/aligned-vector.hpp"
#include
"pinocchio/bindings/python/utils/pickle-vector.hpp"
#include
"pinocchio/bindings/python/utils/std-vector.hpp"
#include
"pinocchio/container/aligned-vector.hpp"
namespace
pinocchio
{
namespace
python
{
///
/// \brief Expose an container::aligned_vector from a type given as template
/// argument.
///
/// \tparam T Type to expose as container::aligned_vector<T>.
/// \tparam EnableFromPythonListConverter Enables the conversion from a Python
/// list to a container::aligned_vector<T>.
///
/// \sa StdAlignedVectorPythonVisitor
///
template
<
class
T
,
bool
NoProxy
=
false
,
bool
EnableFromPythonListConverter
=
true
>
struct
StdAlignedVectorPythonVisitor
:
public
::
boost
::
python
::
vector_indexing_suite
<
typename
container
::
aligned_vector
<
T
>
,
NoProxy
,
internal
::
contains_vector_derived_policies
<
typename
container
::
aligned_vector
<
T
>
,
NoProxy
>
>
,
public
StdContainerFromPythonList
<
container
::
aligned_vector
<
T
>
>
{
typedef
container
::
aligned_vector
<
T
>
vector_type
;
typedef
StdContainerFromPythonList
<
vector_type
,
NoProxy
>
FromPythonListConverter
;
typedef
T
value_type
;
namespace
pinocchio
{
namespace
python
{
///
/// \brief Expose an container::aligned_vector from a type given as template argument.
///
/// \tparam T Type to expose as container::aligned_vector<T>.
/// \tparam EnableFromPythonListConverter Enables the conversion from a Python list to a container::aligned_vector<T>.
///
/// \sa StdAlignedVectorPythonVisitor
///
template
<
class
T
,
bool
NoProxy
=
false
,
bool
EnableFromPythonListConverter
=
true
>
struct
StdAlignedVectorPythonVisitor
:
public
::
boost
::
python
::
vector_indexing_suite
<
typename
container
::
aligned_vector
<
T
>
,
NoProxy
,
internal
::
contains_vector_derived_policies
<
typename
container
::
aligned_vector
<
T
>
,
NoProxy
>
>
,
public
StdContainerFromPythonList
<
container
::
aligned_vector
<
T
>
>
{
typedef
container
::
aligned_vector
<
T
>
vector_type
;
typedef
StdContainerFromPythonList
<
vector_type
,
NoProxy
>
FromPythonListConverter
;
typedef
T
value_type
;
static
void
expose
(
const
std
::
string
&
class_name
,
const
std
::
string
&
doc_string
=
""
)
{
expose
(
class_name
,
doc_string
,
EmptyPythonVisitor
());
}
template
<
typename
VisitorDerived
>
static
void
expose
(
const
std
::
string
&
class_name
,
const
boost
::
python
::
def_visitor
<
VisitorDerived
>
&
visitor
)
{
expose
(
class_name
,
""
,
visitor
);
}
template
<
typename
VisitorDerived
>
static
void
expose
(
const
std
::
string
&
class_name
,
const
std
::
string
&
doc_string
,
const
boost
::
python
::
def_visitor
<
VisitorDerived
>
&
visitor
)
{
namespace
bp
=
boost
::
python
;
if
(
!
register_symbolic_link_to_registered_type
<
vector_type
>
())
{
bp
::
class_
<
vector_type
>
cl
(
class_name
.
c_str
(),
doc_string
.
c_str
());
cl
.
def
(
StdAlignedVectorPythonVisitor
())
.
def
(
bp
::
init
<
size_t
,
const
value_type
&>
(
bp
::
args
(
"self"
,
"size"
,
"value"
),
"Constructor from a given size and a given value."
))
.
def
(
bp
::
init
<
const
vector_type
&>
(
bp
::
args
(
"self"
,
"other"
),
"Copy constructor"
))
.
def
(
"tolist"
,
&
FromPythonListConverter
::
tolist
,
bp
::
arg
(
"self"
),
static
void
expose
(
const
std
::
string
&
class_name
,
const
std
::
string
&
doc_string
=
""
)
{
expose
(
class_name
,
doc_string
,
EmptyPythonVisitor
());
}
template
<
typename
VisitorDerived
>
static
void
expose
(
const
std
::
string
&
class_name
,
const
boost
::
python
::
def_visitor
<
VisitorDerived
>
&
visitor
)
{
expose
(
class_name
,
""
,
visitor
);
}
template
<
typename
VisitorDerived
>
static
void
expose
(
const
std
::
string
&
class_name
,
const
std
::
string
&
doc_string
,
const
boost
::
python
::
def_visitor
<
VisitorDerived
>
&
visitor
)
{
namespace
bp
=
boost
::
python
;
if
(
!
register_symbolic_link_to_registered_type
<
vector_type
>
())
{
bp
::
class_
<
vector_type
>
cl
(
class_name
.
c_str
(),
doc_string
.
c_str
());
cl
.
def
(
StdAlignedVectorPythonVisitor
())
.
def
(
bp
::
init
<
size_t
,
const
value_type
&>
(
bp
::
args
(
"self"
,
"size"
,
"value"
),
"Constructor from a given size and a given value."
))
.
def
(
bp
::
init
<
const
vector_type
&>
(
bp
::
args
(
"self"
,
"other"
),
"Copy constructor"
))
.
def
(
"tolist"
,
&
FromPythonListConverter
::
tolist
,
bp
::
arg
(
"self"
),
"Returns the aligned_vector as a Python list."
)
.
def
(
visitor
)
#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
.
def_pickle
(
PickleVector
<
vector_type
>
())
#endif
.
def
(
CopyableVisitor
<
vector_type
>
())
;
// Register conversion
if
(
EnableFromPythonListConverter
)
FromPythonListConverter
::
register_converter
();
}
}
};
}
// namespace python
}
// namespace pinocchio
.
def
(
CopyableVisitor
<
vector_type
>
());
// Register conversion
if
(
EnableFromPythonListConverter
)
FromPythonListConverter
::
register_converter
();
}
}
};
}
// namespace python
}
// namespace pinocchio
#endif // ifndef __pinocchio_python_utils_std_aligned_vector_hpp__
#endif
// ifndef __pinocchio_python_utils_std_aligned_vector_hpp__
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