-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perhaps add something about not supporting numpy int/float to the docs? #18
Comments
Good suggestion, I'll add that in. Regarding parallelism, it depends on how you try to go about things. You can't pickle |
I've now been tripped up by this multiple times, so I'll resound the request. However, I'm also curious why you can't work with numpy floats. I'd prefer to use the float16 to trade off precision for less memory. Thanks a lot for putting this code online! |
@davek44: I certainly could work with numpy input, it's just a matter of having another dependency. |
@endrebak @davek44 If either of you have a chance, give the |
Most people use conda, so installation order should very seldom be a Super btw. Will report back when I get around to it. On Mon, Oct 31, 2016 at 8:57 AM, Devon Ryan notifications@github.com
|
Yup, I'll modify the bioconda recipe accordingly if this works out OK. |
The |
How to test dpryans new PR: git clone -b numpy git@github.com:dpryan79/pyBigWig.git
cd pyBigWig
python setup.py install # I guess this should overwrite the already installed pyBigWig? Code you can copy into ipython afterwards: iimport pyBigWig
import pandas as pd
header = [("chr1", 500)]
bw = pyBigWig.open("test.bw", "w")
bw.addHeader(header)
c = ["chr1"] * 3
s = pd.Series([1, 5, 7])
e = s + 1
v = pd.Series([5, 0, -5])
bw.addEntries(c, list(s), ends=list(e), values=list(v)) # error happens here
bw.close() For me, running the above code lead to the following error:
Edit: come to think of it, this would have segfaulted in the previous version, AFAICR so good job. Might be an error on my part, somewhere. |
You can also just I've only tested directly inputting a numpy array (note that there's a nosetest that uses this), so I'd have to look and see what pandas is actually giving things. As an aside, this is the downside to writing python extensions in C. They're much faster, but also much less flexible. |
@endrebak Values need to be floats in bigWig files. That's why you're getting the error. |
For pandas, it looks like you can use the
As an aside, there was a bug preventing this from working with 64bit floats (what pandas uses) that I just fixed. |
With the latest PR (Fix the minimum floating point value check) it worked. Thanks! Ps. I am trying to recreate some of S4Vectors' functionality in Python. Do you have a good reference for reading about Python/numpy/C interop? If no, then please do not go looking for my sake (obviously :) ). |
Great! I'd like to sit on this a little while and play around with it before I make the next release, since the large increase in code size inevitably created a but or two. I don't have any good reference for python/numpy/C interop. This was my first C/Python hybrid and was quite a learning curve to make (in comparison, I started and completed py2bit/lib2bit in 2 days, so feel free to "borrow" the boilerplate initialization/finalization stuff from my code). I personally found the python C API documentation to be...not the most helpful thing in the world (especially in regards to reference counting). If you're interested in python/C/numpy interop then think early on about python 2/3 differences and the variety of different numeric types that can get passed in by numpy. The latter is relatively easy to handle but the former I at least personally still find to be confusing. |
I converted a pandas df to lists of
numpy.int64
(starts, ends) andnumpy.float64
(values) withlist(df.Starts)
etc. This gave strange segfaults. Perhaps you should warn about this in the docs that you need to convert these to proper Python values first withint(numpy_int)
andfloat(numpy_float)
? I had no idea what I was doing wrong...Thanks for the library by the way.
Ps. should it work in parallel? Some c-libs like
bx-python
do not.The text was updated successfully, but these errors were encountered: