joaosferreira's Blog

Week 5 Check-in

Published: 07/07/2020

What did you do this week?

I continued the PR started in the previous week by adding more multimethods for array manipulation. The following multimethods were added:

Tiling arrays

  • tile
  • repeat

Adding and removing elements

  • delete
  • insert
  • append
  • resize
  • trim_zeros

Rearranging elements

  • flip
  • fliplr
  • flipud
  • reshape
  • roll
  • rot90

Most of the work was adding default implementations for the above multimethods which relied heavily on array slicing. Contrary to what I mentioned in my last blog post, not much time was dedicated to writing overriden_class for other backends so I will try to compensate in the next weeks.

What is coming up next?

As described in my proposal's timeline I'll be starting a new PR that adds multimethods for mathematical functions. This will be the focus of this week's work as some of these multimethods are also needed by sangyx, another GSoC student working on uarray. He is working on the udiff library that uses uarray and unumpy for automatic differentiation. To avoid getting in his way I will try to finish this PR as soon as possible.

Did you get stuck anywhere?

There were times when I didn't know exactly how to implement a specific default but this was easily overcome with the help of my mentors who would point me in the right direction. Asking for help sooner rather than later has proven to be invaluable. Looking back I think there were no major blocks this week.

View Blog Post

Week 4 Check-in

Published: 06/30/2020

What did you do this week?

I started a PR that adds multimethods for array manipulation routines. I'll name the multimethods according to the NumPy docs sectioning:

Basic operations

  • copyto

Changing number of dimensions

  • expand_dims
  • squeeze

Changing kind of array

  • asfarray
  • asfortranarray
  • asarray_chkfinite
  • require

Joining arrays

  • dstack

Splitting arrays

  • split
  • array_split
  • dsplit
  • hsplit
  • vsplit

As mentioned in my last blog post, this week I also started reviewing a PR that implements metaclasses from which classes in unumpy instantiate. They are used to override these classes with ones from the backend being used through a property method called overriden_class. Currently only the NumPy backend has this method but I've been trying to implement it in other backends as well.

What is coming up next?

The current PR should last one more week since I'll continue to add more multimethods for array manipulation routines. I will also be working on adding overriden_class to other backends as I've been doing this past week.

Did you get stuck anywhere?

I think the only place I got stuck was trying to implement overriden_class for other backends. To be more specific, I tried implementing it in the Dask backend first and foremost, however, this backend is different since it uses another backend internally. From my understanding this causes that some classes might have to be overridden by the inner backend and others by Dask itself. With that said, I might need help later on with this issue. In general, I feel that this metaclasses feature has been the most challenging part of my project so far. Although this wasn't initially included in my proposal and can be considered extra work I welcome the challenge and hope that my mentors keep entrusting me more of these features. Also, given that the semester is almost ending I start having more free time on my hands to tackle these problems which is what I want.

View Blog Post

Week 3 Check-in

Published: 06/22/2020

What did you do this week?

I continued the work started in last week's PR by adding more multimethods on array creation:

Numerical ranges:

  • geomspace

Building matrices:

  • diagflat
  • tri
  • tril
  • triu
  • vander

These additions conclude the mentioned PR which at the time of writing this is almost ready to be merged. I also tried to implement a metaclass type for classes in unumpy.

What is coming up next?

I'll be starting a new PR that intendes to expand unumpy's coverage of array manipulation routines. The PR is expected to last two weeks given the extensive and diverse nature of the multimethods covered. Also, following the discussion about the inclusion of a metaclass type from which other classes in unumpy instantiate, it's expected that I review a PR by one of my mentors on this. This is a good opportunity for me to start getting used to reviewing PRs. As a note, I think the workload in the next two weeks might increase a bit but as college assignments start to decrease a good balance between the two should stay constant.

Did you get stuck anywhere?

The biggest challenge this week was trying to implement the metaclass type. Although I was given some good pointers on how to proceed with this I still faced some problems on doing this correctly. Creating a metaclass with the added difficulty of writing multimethods for its methods was a bit overwhelming. I spent almost an entire day on this and got little results. Looking back I should have asked for help which would surely have helped me unblock. I'll be sure to keep that in mind next time. With that said, I'm still learning the ropes but I already feel that my Python skills are improving significantly.

View Blog Post

Week 2 Check-in

Published: 06/15/2020

What did you do this week?

This week I started a PR that further adds multimethods for array creation routines. I'll name the additions according to the NumPy docs sectioning:

Ones and zeros:

  • identity
  • ones_like
  • zeros_like
  • full_like

From existing data:

  • asanyarray
  • ascontiguousarray
  • copy
  • frombuffer
  • fromfile
  • fromfunction
  • fromiter
  • fromstring
  • loadtxt

During this week I also started learning about metaclasses in Python. This was encouraged by my mentors as a way to level up my Python skills so that I can tackle more complicated features in unumpy. This was mostly done by reading documentation, posts and articles about the subject and watching one of my mentors code some examples.

What is coming up next?

The current PR will be stretched to this upcoming week where I'll be covering more multimethods for these routines. Also, as briefly discussed in my previous blog post, I will eventually be picking up a PR that adds multimethods for the random module. However, as stated in this issue, classes in unumpy like np.random.RandomState could benefit from a custom metaclass. Given the importance of this feature for current and future implementations additional work during this week will be focused on the creation of this metaclass.

Did you get stuck anywhere?

There were some difficulties writing tests for some of these routines as there were a lot of errors that I didn't understand at first. Going over each one separately and writing why I thought they were failing actually helped in fixing some of them. At the time of writing this they are almost all resolved with only one exception.

View Blog Post

Week 1 Check-in

Published: 06/08/2020

What did you do this week?

I started a new PR that adds mathematical constants and mutlimethods for logic routines. These included:

Math constants:

  • euler_gamma
  • nan and aliases
  • inf and aliases
  • NINF
  • newaxis

Logic functions:

  • isposinf
  • isneginf
  • iscomplex
  • iscomplexobj
  • isreal
  • isrealobj
  • isscalar
  • array_equal
  • array_equiv

I've also continued to work on the PR started during community bonding. This one also originated a new issue. 

What is coming up next?

I'll be adding more multimethods, this time addressing routines for array creation. I've already done two multimethods on array creation when I was applying for GSoC which might help this coming week. I'm also thinking about picking up another PR left off by one of my mentors. The one about NumPy's random module seems interesting and challenging. However, this still has to be discussed with my mentors since this was not part of my proposal and it also depends on the available time I'll have. Although I have an exam and a project assignment to deliver I hope to keep a good rhythm going during this week. Let's see how it goes!

Did you get stuck anywhere?

I haven't had any major blocks this week. The default implementation for norm in the Linear Algebra module was the toughest as I was trying to implement a simple solution that would take into account all the corner cases. I realized that sometimes an elegant solution is not easily attainable and that correctness is more important. The result was not that bad I hope.

This week was also the start of my weekly meetings with my mentors. We discussed my PRs and other things about the project which was quite helpful. I really appreciate their availability and commitment.

View Blog Post