Week 6
Phase 1 continues …. Hello everyone, hope this blog finds you well.
This week was an essential week as far as the robustness and concreteness of my project is concerned. We wrote tests for all kinds of numpy routines and this led to resolution of many bugs and edge cases.
Aim :
My aim for this week was to fasttrack the testing phase, and provide coverage for about 60-80% of the codebase.
Alongside I wanted to fix bugs that come up in testing and manually test all routines of the Random
module.
Work :
I raised the following pull requests for testing this week.
- PR#20 : Added tests for add, sub, mul, div
- PR#21 : Add tests for some dunder methods
- PR#22 : Add test for the copy function
- PR#23 : Add tests for miscellaneous functions
-
PR#25 : Adjust __getitem__ to return output according to dimension.
In numpy the
__getitem__(index: int)
function can return output in multiple types (depending on the dimension explored).>>> import numpy as np >>> arr1 = np.array([1, 2, 3, 4]) >>> arr1[0] np.int64(1) >>> arr1 = np.array([[1, 2], [3, 4]]) >>> arr1[0] array([1, 2])
As of now, my implementation handles it as follows
>>> import numpy_bindings as np >>> arr1 = np.array([1, 2, 3, 4]) >>> arr1[0] ndarray( 1 ) >>> arr1 = np.array([[1, 2], [3, 4]]) >>> arr1[0] ndarray( {1, 2} )
As you can see In case 1, the element is indexed correctly but the ndarray constructor is wrapped around it. This is solved by the above pull request.
-
PR#26 : Modify get_item_tuple to fix access issue.
I have changed the function as follows -
numpy/include/numpy.hpp
- Access patterns have been updated to utilize
xt::view
for better handling of array slices. - Example:
xt::view(_array, i1, i2) = value;
numpy/src/numpy.cpp
- The
set_item_tuple
function has been split into two separate functions:set_item_tuple_int
for handling integer values.set_item_tuple_float
for handling floating-point values.- Example:
void set_item_tuple_int(py::tuple args, int value);
- Access patterns have been updated to utilize
- PR#27 : Fix __getitem__ and add tests
-
PR#28 : Make __eq__() implementation element wise to match numpy
On Main
>>> import numpy_bindings as np >>> a = np.array([1, 2, 3]) >>> b = np.array([1, 2, 3]) >>> a == b True
On Branch
>>> import numpy_bindings as np >>> a = np.array([1, 2, 3]) >>> b = np.array([1, 2, 3]) >>> a == b ndarray( {1, 1, 1} )
Only thing we need to make sure now is
__eq__()
returns a boolean array. I will make sure to correct that in future weeks.
Future Work :
In this upcoming week, we will have our mid term evaluation for which I need to setup examples and also give a working demo to my mentors.