Small bugs, fixes, and imporvement suggestions

11 views
Skip to first unread message

smfi...@ualberta.ca

unread,
Dec 17, 2017, 5:29:02 PM12/17/17
to algopy
Hi all,

I do not know whether algopy is still maintained. If it is, the developers may want to note the following bugs in version :
  • There is a broadcasting issue in the __sub__ method of the UTPM class in utpm.py. __add__ works without problems, though. Therefore, I suggest that __sub__ is changed to equal __add__. Replace line 357 with the subtract equivalent of lines 324 and 326:
    • x_data, y_data = UTPM._broadcast_arrays(self.data, rhs.data)
    • return UTPM(x_data - y_data)
  • In line131 of utpm.py, a NotImplementedError shall be raised. However, the parantheses are missing so that the error class is raised and not the error itself. it should read
    • raise NotImplementedError()
  • In the class method init_hessian in utpm.py, the values of the variables M and N are computed with a single "/". The resulting values are floats, which in turn cannot be used (anymore) to initialize the numpy array S. Therefore, change lines 1823 and 1824 and use integer division:
    • M = (N*(N+1))//2
    • L = (N*(N-1))//2

Often it is useful to use the fancy indexing techniques that numpy arrays allow. However, the implementation of the UTPM __getitem__ method in utpm.py does not allow that. I suggest changing the implementation slightly:


def __getitem__(self, sl):
if not isinstance(sl, tuple):
sl = (sl,)
tmp = self.data.__getitem__((slice(None),slice(None)) + sl)
return self.__class__(tmp)

That way, only tuples are used for multi-dimensional access and lists for numpy's fancy indexing.

It would be great, if fancy indexing would also work for value assignment, but I did not have an idea to implement that quickly.

have tested the suggested changes and fixes with my current project and it works fine.

Thanks for providing and maintaining algopy!

Sam

Sebastian Walter

unread,
Dec 18, 2017, 3:38:00 AM12/18/17
to alg...@googlegroups.com
Hi Sam,

could you create a fork of algopy on github and send me a pull request? I'd be happy to merge your bugfixes and provide an updated version on pypi.

Best
Sebastian



--
You received this message because you are subscribed to the Google Groups "algopy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to algopy+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages