Skip to content

Commit

Permalink
Merge pull request #2698 from shogun-toolbox/bugfix/python_modular_swig3
Browse files Browse the repository at this point in the history
fix segfaults when calling delete[] twice on SGMatrix-instances and fix minor issues with swig 3.X
  • Loading branch information
Björn Esser committed Apr 4, 2015
2 parents 8c7e9fc + 2b6c88d commit 203d5c3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
Expand Up @@ -17,8 +17,8 @@ def kernel_sparse_poly_modular (fm_train_real=traindat,fm_test_real=testdat,



kernel=PolyKernel(feats_train, feats_train, size_cache, degree,
inhomogene)
kernel=PolyKernel(feats_train, feats_train, size_cache,
inhomogene, degree)
km_train=kernel.get_kernel_matrix()

kernel.init(feats_train, feats_test)
Expand Down
@@ -1,5 +1,5 @@
#!/usr/bin/env python
parameter_list=[[10,7,0,0]]
parameter_list=[[10,7,0,False]]

def tests_check_commwordkernel_memleak_modular (num, order, gap, reverse):
import gc
Expand Down
20 changes: 7 additions & 13 deletions src/shogun/evaluation/CrossValidationMulticlassStorage.cpp
Expand Up @@ -33,31 +33,25 @@ CCrossValidationMulticlassStorage::CCrossValidationMulticlassStorage(bool comput

CCrossValidationMulticlassStorage::~CCrossValidationMulticlassStorage()
{
if (m_compute_ROC)
if (m_compute_ROC && m_fold_ROC_graphs)
{
for (int32_t i=0; i<m_num_folds*m_num_runs*m_num_classes; i++)
m_fold_ROC_graphs[i].~SGMatrix<float64_t>();

SG_FREE(m_fold_ROC_graphs);
}

if (m_compute_PRC)
if (m_compute_PRC && m_fold_PRC_graphs)
{
for (int32_t i=0; i<m_num_folds*m_num_runs*m_num_classes; i++)
m_fold_PRC_graphs[i].~SGMatrix<float64_t>();

SG_FREE(m_fold_PRC_graphs);
}

if (m_compute_conf_matrices)
if (m_compute_conf_matrices && m_conf_matrices)
{
for (int32_t i=0; i<m_num_folds*m_num_runs; i++)
m_conf_matrices[i].~SGMatrix<int32_t>();

SG_FREE(m_conf_matrices);
}

SG_UNREF(m_binary_evaluations);
if (m_binary_evaluations)
{
SG_UNREF(m_binary_evaluations);
}
};


Expand Down
8 changes: 5 additions & 3 deletions src/shogun/evaluation/MulticlassOVREvaluation.cpp
Expand Up @@ -28,13 +28,15 @@ CMulticlassOVREvaluation::CMulticlassOVREvaluation(CBinaryClassEvaluation* binar

CMulticlassOVREvaluation::~CMulticlassOVREvaluation()
{
SG_UNREF(m_binary_evaluation);
if (m_graph_results)
{
for (int32_t i=0; i<m_num_graph_results; i++)
m_graph_results[i].~SGMatrix<float64_t>();
SG_FREE(m_graph_results);
}

if (m_binary_evaluation)
{
SG_UNREF(m_binary_evaluation);
}
}

float64_t CMulticlassOVREvaluation::evaluate(CLabels* predicted, CLabels* ground_truth)
Expand Down

0 comments on commit 203d5c3

Please sign in to comment.