Mistake in BinOp.conform? #11283

Closed
BrenBarn opened this Issue Oct 10, 2015 · 3 comments

Comments

Projects
None yet
2 participants

in BinOp.conform in pandas.computation,pytables there is this code:

    def conform(self, rhs):
        """ inplace conform rhs """
        if not com.is_list_like(rhs):
            rhs = [rhs]
        if hasattr(self.rhs, 'ravel'):
            rhs = rhs.ravel()
        return rhs

I think this is wrong. The first test checks rhs, but the second checks self.rhs. They should both check one or the other. I think both should check local rhs but I'm not really familiar with all the nuts and bolts here so I'm not sure.

This causes failures when doing HDF5 queries making use of a local variable whose value is a single Numpy value (e.g., a float64). Because even a single numpy value has ravel, but it is not list-like, both if blocks execute, meaning that it sets rhs to a list and then tries to call ravel on it. This leads to a difficult-to-debug error because the exception is caught at a higher level and replaced with an "Invalid query syntax" error message.

Contributor

jreback commented Oct 10, 2015

if u can propose a fix gr8.

jreback added the IO HDF5 label Oct 11, 2015

I already did propose a fix in my bug report above. It is a less-than-one-line fix: change self.rhs to rhs.

Contributor

jreback commented Oct 11, 2015

ok pls submit a pr with tests pls

jreback added this to the 0.17.1 milestone Oct 12, 2015

jreback added the Bug label Oct 12, 2015

@BrenBarn BrenBarn pushed a commit to BrenBarn/pandas that referenced this issue Oct 13, 2015

BrenBarn Fix mistake in Pytables querying with numpy scalar value. Fixes #11283 314ed45

jreback closed this in #11291 Oct 13, 2015

@jreback jreback added a commit that referenced this issue Oct 13, 2015

@jreback jreback Merge pull request #11291 from BrenBarn/pytables-fix
Fix mistake in Pytables querying with numpy scalar value.  Fixes #11283
4a182d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment