klocey / partitions

python based code for integer partitioning
4 stars 4 forks source link

run time warning on bias_check() in test.py #17

Closed dmcglinn closed 10 years ago

dmcglinn commented 10 years ago

RunTimeWarning: invalid value encountered in subtract return var(axis, dtype, out, ddof)

This error makes me think something is wrong in line 354 of test.py

dmcglinn commented 10 years ago

Just pushed a new version of test.py the I can't figure out how to fix the runtime error although I was successful at making the paths relative and providing a command line option for testing for bias or not.

klocey commented 10 years ago

Give me a minute to look at it.

On Mon, Dec 9, 2013 at 11:54 AM, Dan McGlinn notifications@github.comwrote:

Just pushed a new version of test.py the I can't figure out how to fix the runtime error although I was successful at making the paths relative and providing a command line option for testing for bias or not.

— Reply to this email directly or view it on GitHubhttps://github.com/klocey/partitions/issues/17#issuecomment-30160523 .

klocey commented 10 years ago

Working on a different project at the moment.

On Mon, Dec 9, 2013 at 11:55 AM, Ken Locey ken@weecology.org wrote:

Give me a minute to look at it.

On Mon, Dec 9, 2013 at 11:54 AM, Dan McGlinn notifications@github.comwrote:

Just pushed a new version of test.py the I can't figure out how to fix the runtime error although I was successful at making the paths relative and providing a command line option for testing for bias or not.

— Reply to this email directly or view it on GitHubhttps://github.com/klocey/partitions/issues/17#issuecomment-30160523 .

klocey commented 10 years ago

RunTimeWarning: invalid value encoutered in subractreturn var(axis, dtype, out, ddof)

This because the partition has zeros and we're asking numpy to convert the array to log abundances:

for partition in partitions: # zeros = True partition = np.log(partition) var = np.var(partition, ddof=1)

We can just use arithmetic abundances. i.e. comment out or remove the line "partitions = np.log(partition)" for the two time where zeros = True (i.e. lines 316 and 299).

This problem should NOT occur for line 354 because the partition can't have zeros. Likewise, it only occurs (for me) at lines 316 and 299.

Ken

On Mon, Dec 9, 2013 at 11:55 AM, Ken Locey ken@weecology.org wrote:

Working on a different project at the moment.

On Mon, Dec 9, 2013 at 11:55 AM, Ken Locey ken@weecology.org wrote:

Give me a minute to look at it.

On Mon, Dec 9, 2013 at 11:54 AM, Dan McGlinn notifications@github.comwrote:

Just pushed a new version of test.py the I can't figure out how to fix the runtime error although I was successful at making the paths relative and providing a command line option for testing for bias or not.

— Reply to this email directly or view it on GitHubhttps://github.com/klocey/partitions/issues/17#issuecomment-30160523 .

klocey commented 10 years ago

If you tinker with the code, you'll see the warning goes away if you don't try converting an array with zeros to log abundances.

klocey commented 10 years ago

Executive decision: Use arithmetic abundances. Remove the lines "partition = np.log(partition)". Lines 299, 316, 336, 353

dmcglinn commented 10 years ago

Sounds good I'll make this change.

Dan

On Mon, Dec 9, 2013 at 12:41 PM, Kenneth John Locey < notifications@github.com> wrote:

Executive decision: Use arithmetic abundances. Remove the lines "partition = np.log(partition)". Lines 299, 316, 336, 353

— Reply to this email directly or view it on GitHubhttps://github.com/klocey/partitions/issues/17#issuecomment-30165897 .

Daniel J. McGlinn, PhD Postdoctoral Researcher Utah State University Department of Biology, BNR 132 Logan, UT 84322-5305 http://mcglinn.web.unc.edu/ cell: 405-612-1780

klocey commented 10 years ago

Sweet. Gracias.