Skip to content

Mistake in BinOp.conform? #11283

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

Closed
BrenBarn opened this issue Oct 10, 2015 · 3 comments · Fixed by #11291
Closed

Mistake in BinOp.conform? #11283

BrenBarn opened this issue Oct 10, 2015 · 3 comments · Fixed by #11291
Labels
Bug IO HDF5 read_hdf, HDFStore
Milestone

Comments

@BrenBarn
Copy link

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.

@jreback
Copy link
Contributor

jreback commented Oct 10, 2015

if u can propose a fix gr8.

@BrenBarn
Copy link
Author

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

@jreback
Copy link
Contributor

jreback commented Oct 11, 2015

ok pls submit a pr with tests pls

@jreback jreback added this to the 0.17.1 milestone Oct 12, 2015
@jreback jreback added the Bug label Oct 12, 2015
jreback added a commit that referenced this issue Oct 13, 2015
Fix mistake in Pytables querying with numpy scalar value.  Fixes #11283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants