Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.libsvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
bob
bob.learn.libsvm
Commits
c07029b3
Commit
c07029b3
authored
9 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issue
#8
. Segmentation fault when using the __repr__ method
parent
59e3341c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/libsvm/machine.cpp
+3
-3
3 additions, 3 deletions
bob/learn/libsvm/machine.cpp
bob/learn/libsvm/test_machine.py
+2
-0
2 additions, 0 deletions
bob/learn/libsvm/test_machine.py
with
5 additions
and
3 deletions
bob/learn/libsvm/machine.cpp
+
3
−
3
View file @
c07029b3
...
...
@@ -444,11 +444,11 @@ PyObject* PyBobLearnLibsvmMachine_Repr(PyBobLearnLibsvmMachineObject* self) {
* <bob.learn.libsvm.Machine float64@(3, 2)>
*/
auto
shape
=
make_safe
(
PyObject_GetAttrString
((
PyObject
*
)
self
,
"shape"
));
auto
shape_str
=
make_safe
(
PyObject_Str
(
shape
.
get
()
));
PyObject
*
shape
=
Py_BuildValue
(
"(nn)"
,
self
->
cxx
->
inputSize
(),
self
->
cxx
->
outputSize
(
));
PyObject
*
retval
=
PyUnicode_FromFormat
(
"<%s float64@%U>"
,
Py_TYPE
(
self
)
->
tp_name
,
shape_str
.
get
(
));
Py_TYPE
(
self
)
->
tp_name
,
PyObject_Unicode
(
shape
));
#if PYTHON_VERSION_HEX < 0x03000000
if
(
!
retval
)
return
0
;
...
...
This diff is collapsed.
Click to expand it.
bob/learn/libsvm/test_machine.py
+
2
−
0
View file @
c07029b3
...
...
@@ -79,6 +79,7 @@ def test_can_load():
assert
-
1
in
machine
.
labels
assert
+
1
in
machine
.
labels
assert
abs
(
machine
.
gamma
-
0.0769231
)
<
1e-6
assert
type
(
machine
.
__repr__
())
is
str
def
test_can_save
():
...
...
@@ -251,6 +252,7 @@ def test_correctness_iris():
pred_labels
,
pred_probs
=
machine
.
predict_class_and_probabilities
(
data
)
assert
numpy
.
array_equal
(
pred_labels
,
real_labels
)
assert
numpy
.
all
(
abs
(
numpy
.
vstack
(
pred_probs
)
-
numpy
.
vstack
(
real_probs
))
<
1e-6
)
@nose.tools.raises
(
RuntimeError
)
def
test_correctness_inputsize_exceeds
():
...
...
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