src-d / modelforge

Python library to share machine learning models easily and reliably.
Apache License 2.0
18 stars 13 forks source link

Fix split_strings #89

Closed zurk closed 5 years ago

zurk commented 5 years ago

For some reason len function for numpy array gives weird error sometimes:

    if len(lengths) == 0 and len(strings) == 0:
TypeError: 'int' object is not callable

lengths.shape[0] works smoothly.

vmarkovtsev commented 5 years ago

@zurk I need a test extension which actually checks this, because your previous test passed.

zurk commented 5 years ago

That's why It is weird and usually, it is ok to get the length of numpy array.

import numpy
len(numpy.array([]))
Out[3]: 0
len(numpy.array([1,2,3]))
Out[4]: 3
len(numpy.array(["1","2","34"]))
Out[5]: 3

and TypeError: 'int' object is not callable makes no sence.

I will try to google the error I had and see what I can do.

zurk commented 5 years ago

it is an asdf issue. if you save and load numpy.ndarray it has int in its __len__ magic method. So I cannot add tests because it is a bug in asdf. Going to report the issue.

zurk commented 5 years ago

@vmarkovtsev here https://github.com/spacetelescope/asdf/issues/671 let's merge the PR, I cannot add a test as you asked, because actually, it should work.

vmarkovtsev commented 5 years ago

Go ahead and add the ASDF test - exactly how you wrote in the issue. It is a feature, not a bug.