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