Bookworm-project / BookwormDB

Tools for text tokenization and encoding
MIT License
84 stars 12 forks source link

query raises an error if groups is an empty list #141

Closed chrissbarnett closed 5 years ago

chrissbarnett commented 6 years ago

I had an issue where a query to bookworm with the group param set to [] resulted in an error: {"message":"Database error. Try checking field names.","status":"error"}

Following the stack trace led to 'fixNumpyType' in 'general_API.py', which was raising an exception because 'int' object has no attribute 'dtype'

In my installation, I modified this method to directly check for the numpy type, and this seemed to resolve the problem. I'm not 100% sure that this resolves the issue that the method was originally intended to resolve.

import numpy as np
.
.
.
        def fixNumpyType(input):
            # This is, weirdly, an occasional problem but not a constant one.
            if type(input) is np.int64:
                return int(input)
            else:
                return input

The numpy and pandas versions I am using:

bmschmidt commented 6 years ago

Thanks!

This makes sense as a fix. As the comment at the head indicates, this whole code block is a little suspect. Will try push it into the main branch soon.

bmschmidt commented 6 years ago

OK, this is up and passing tests as of the latest commit. https://github.com/Bookworm-project/BookwormDB/commit/22bf94ee7be2acb6837774dad247e5b4e2cd9513

chrissbarnett commented 6 years ago

thanks!