eladnoor / component-contribution

Standard reaction Gibbs energy estimation for biochemical reactions
Other
17 stars 15 forks source link

python bugs #10

Closed dmccloskey closed 9 years ago

dmccloskey commented 10 years ago

There appear to be a few memory errors in the python implementation:

1: octave reports a memory error

by using numpy instead of octave in the function calls in python.component_contribution.py

    # Linear regression for the reactant layer (aka RC)
    inv_S, r_rc, P_R_rc, P_N_rc = ComponentContribution._invert_project(S * W)

    # Linear regression for the group layer (aka GC)
    inv_GS, r_gc, P_R_gc, P_N_gc = ComponentContribution._invert_project(GS * W)

the issue was resolved.

2: incompatibility with python 2.7.6 and numpy 1.8.0

I have ran the wolf.py file using python 2.7.5 and numpy 1.7.1 without any problems.

When upgrading to python 2.7.6 and numpy 1.8.0, I receive an "IndexError: too many indices" when slicing and copying the numpy.array in the following lines in python.training_data.py:

    self.dG0_prime = self.dG0_prime[:, rxn_inds_to_keep]
    self.T = self.T[:, rxn_inds_to_keep]
    self.I = self.I[:, rxn_inds_to_keep]
    self.pH = self.pH[:, rxn_inds_to_keep]
    self.pMg = self.pMg[:, rxn_inds_to_keep]
    self.weight = self.weight[:, rxn_inds_to_keep]

by removing the semi-colon the problem is resolved:

    self.dG0_prime = self.dG0_prime[rxn_inds_to_keep]
    self.T = self.T[rxn_inds_to_keep]
    self.I = self.I[rxn_inds_to_keep]
    self.pH = self.pH[rxn_inds_to_keep]
    self.pMg = self.pMg[rxn_inds_to_keep]
    self.weight = self.weight[rxn_inds_to_keep]

This works both for numpy 1.7.1 and numpy 1.8.0. For some reason, numpy 1.8.0 will not allow array slicing of the form "[:,[...]]" for 1D arrays whereas numpy 1.7.1. does not care.

However, python 2.7.6. subsequently crashes on the call to "inv_S, r_rc, P_R_rc, P_N_rc = ComponentContribution._invert_project(S * W)" whereas python 2.7.5 exits the wolf.py file without any errors.

I have not found a solution to the python.exe crash using 2.7.6.

eladnoor commented 10 years ago

Thank you for raising the issue. I am using Octave 3.6.4, python 2.7.4 and numpy 1.7.1 I am not getting the same memory errors from octave, what version are you using?

About the crash involving python 2.7.6 and numpy 1.8.0, I am not in a position to locate the bug. Since I use Ubuntu linux, I prefer keeping the default versions of python and numpy which have been tested by others. Until there is an update for the Ubuntu repository, would it be possible for you to use the older versions (2.7.4 and 1.7.1)?

eladnoor commented 9 years ago

The issue seems to be resolved both on Linux and Windows 7. Therefore I am closing this bug.