beingzy / learning_dist_metrics

Algorithm of Learning Distance Metrics
9 stars 1 forks source link

Tests fail #2

Open tombosc opened 9 years ago

tombosc commented 9 years ago

Hello,

When I try to run the tests, they fail.

$ python test_ldm.py
py
E
======================================================================
ERROR: test_fit (__main__.TestClassLDM)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_ldm.py", line 24, in test_fit
    self.ldm.fit(X, S, D)
  File "/home/tbosc/twitter_argumentation/learning_dist_metrics/ldm.py", line 70, in fit
    self._fit(X, S, D)
  File "/home/tbosc/twitter_argumentation/learning_dist_metrics/ldm.py", line 145, in _fit
    fitted = minimize(objective_func, init, method="L-BFGS-B", bounds = bnds)
  File "/usr/lib64/python2.7/site-packages/scipy/optimize/_minimize.py", line 356, in minimize
    callback=callback, **options)
  File "/usr/lib64/python2.7/site-packages/scipy/optimize/lbfgsb.py", line 312, in _minimize_lbfgsb
    f, g = func_and_grad(x)
  File "/usr/lib64/python2.7/site-packages/scipy/optimize/lbfgsb.py", line 257, in func_and_grad
    f = fun(x, *args)
  File "/home/tbosc/twitter_argumentation/learning_dist_metrics/ldm.py", line 129, in objective_func
    a = squared_sum_grouped_dist(S, X, w) * 1.0
  File "/home/tbosc/twitter_argumentation/learning_dist_metrics/dist_metrics.py", line 56, in squared_sum_grouped_dist
    dist = all_pairwise_dist(pair_list, data, w)
  File "/home/tbosc/twitter_argumentation/learning_dist_metrics/dist_metrics.py", line 45, in all_pairwise_dist
    dist.append(pairwise_dist_wrapper(i, data, w))
  File "/home/tbosc/twitter_argumentation/learning_dist_metrics/dist_metrics.py", line 35, in pairwise_dist_wrapper
    a = data[pair[0], :]
IndexError: index 3 is out of bounds for axis 0 with size 0

---------------Ran 1 test in 0.014s

FAILED (errors=1)

and

$ python test_dist_metrics.py
.EE
======================================================================
ERROR: test_unweighted_grouped_distance (__main__.test_learing_metric)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_dist_metrics.py", line 45, in test_unweighted_grouped_distance
    test_res = grouped_average_distance(test_data, self.data1_pairs, weights)
NameError: global name 'grouped_average_distance' is not defined

======================================================================
ERROR: test_weighted_distance (__main__.test_learing_metric)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_dist_metrics.py", line 39, in test_weighted_distance
    test_res = weigthed_euclidean(self.x1, self.x2, test_weights)
NameError: global name 'weigthed_euclidean' is not defined

----------------------------------------------------------------------
Ran 3 tests in 0.001s

FAILED (errors=2)

Thanks!

beingzy commented 9 years ago

two bugs had been mentioned in the ticket. 2nd issue: python test_dist_metrics.py had been fixed by removing the test function(s) for deprived dist function(s) And, "test_dist_metrics.py" had been updated by adding test functions for updated functions (from dist_metrics).