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

bug fix: _fixtypes not working as designed #2

Merged
merged 1 commit into from Jun 20, 2015

Conversation

Projects
None yet
2 participants
@granteagon
Contributor

granteagon commented May 12, 2015

fixes:

<ipython-input-27-8ca8add8b39a> in <module>()
----> 1 genderize.Genderize().get(['Molly'])

/home/me/.virtualenvs/foo/lib/python2.7/site-packages/genderize/__init__.pyc in get(self, names, country_id, language_id)
     71         if response.ok:
     72             print 'decoded', decoded
---> 73             return [self._fixtypes(data) for data in decoded]
     74         else:
     75             raise GenderizeException(decoded['error'], response.status_code)

/home/me/.virtualenvs/foo/lib/python2.7/site-packages/genderize/__init__.pyc in _fixtypes(data)
     38         if 'probability' in data:
     39             print data
---> 40             data['probability'] = float(data['probability'])
     41         return data
     42

TypeError: string indices must be integers
bug fix: _fixtypes not working as designed
fixes:
```
<ipython-input-27-8ca8add8b39a> in <module>()
----> 1 genderize.Genderize().get(['Molly'])

/home/me/.virtualenvs/foo/lib/python2.7/site-packages/genderize/__init__.pyc in get(self, names, country_id, language_id)
     71         if response.ok:
     72             print 'decoded', decoded
---> 73             return [self._fixtypes(data) for data in decoded]
     74         else:
     75             raise GenderizeException(decoded['error'], response.status_code)

/home/me/.virtualenvs/foo/lib/python2.7/site-packages/genderize/__init__.pyc in _fixtypes(data)
     38         if 'probability' in data:
     39             print data
---> 40             data['probability'] = float(data['probability'])
     41         return data
     42

TypeError: string indices must be integers
```

SteelPangolin added a commit that referenced this pull request Jun 20, 2015

Merge pull request #2 from granteagon/granteagon-patch-_fixtypes
bug fix: _fixtypes not working as designed

@SteelPangolin SteelPangolin merged commit 42288be into SteelPangolin:master Jun 20, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@SteelPangolin

This comment has been minimized.

Show comment
Hide comment
@SteelPangolin
Owner

SteelPangolin commented Jun 20, 2015

Thanks @granteagon!

SteelPangolin added a commit that referenced this pull request Jun 21, 2015

Always return a list from Genderize.get()
This fixes the actual problem behind PR #2, which is that the API
returns a single object when a single name is requested, and a list
otherwise. The single object is now promoted to a list.

The get1() method is tested now, which covers the single-object case.

This change also makes `test.py` nonexecutable. It was previously
executable, so `nosetests` was ignoring it, and thus testing nothing:
https://nose.readthedocs.org/en/latest/usage.html#extended-usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment