dswah / pyGAM

[HELP REQUESTED] Generalized Additive Models in Python
https://pygam.readthedocs.io
Apache License 2.0
862 stars 159 forks source link

Fix not-None element existance judgement bug #217

Closed csgka1 closed 5 years ago

csgka1 commented 5 years ago

Fixed a bug that the function want to judge whether element == None for each element in the ndarray but actually judge whether None == array itself.

csgka1 commented 5 years ago

The Error occured When I was running the example code in the documentation, saying "bool type doesn't have method 'any'". I watched it in the debugger and I found the value of (np.atleast_1d(self.constraints) != None) is False rather than ndarray[False].

codecov[bot] commented 5 years ago

Codecov Report

Merging #217 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #217   +/-   ##
=======================================
  Coverage   94.86%   94.86%           
=======================================
  Files          22       22           
  Lines        3056     3056           
=======================================
  Hits         2899     2899           
  Misses        157      157
Impacted Files Coverage Δ
pygam/terms.py 93.61% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9b426bb...c387dc8. Read the comment docs.

dswah commented 5 years ago

@BeefOnionDumplings this is cool. can you point to the code sample that caused the bug?

i'd like to include a regression test to prove that this fixes PR the issue.

csgka1 commented 5 years ago

Just the example code in the quick start part of the documentation. In fact it happens when I fit any model.

dswah commented 5 years ago

@BeefOnionDumplings please tell me more about the bug. i just ran the whole quickstart guide but could not replicate the error!

I am using the following system: python 3.6 pygam 0.7.1 numpy 1.15.1 scipy 1.1.0

can you tell me more about the bug? (does it happen during the call to fit() ?) what python are you using? which pygam, numpy, and scipy?

thanks, dani

csgka1 commented 5 years ago

@dswah It happens during the call to fit(). My execution environment is python 3.5.2, numpy 1.12.1, pygam 0.7.1. Maybe np.equal() has a better compatibility than syntactic sugar under this situation.

dswah commented 5 years ago

@BeefOnionDumplings thanks for the details. i was able to reproduce the exception using numpy 1.12.1

i think it's a good idea to use this numpy value check.

i think we will forgo writing a regression test for this PR, since it requires having a test suite with a different version of numpy.