joaosferreira's Blog

Final Week Check-in

Published: 08/31/2020

What did you do this week?

This week I concluded the PR for the random module by adding multimethods for the Generator class. This PR was the last one of my GSoC project. I also wrote the project's final report for my third and final evaluation where I included a short description of the project, links to the the code, a summary of the current state of the project, discussed future work, and enumerated challenges and learnings.

What will you do after GSoC has ended?

They say all good things come to an end and this blog post marks the end of my GSoC journey. Soon I will start working on my master's thesis and look for job opportunities in the industry. I also intend to keep working on unumpy and other open-source software projects.

View Blog Post

Week 12 Check-in

Published: 08/25/2020

What did you do this week?

This week I started a new PR that adds multimethods for NumPy's random module. This continues the work started by one of my mentors by revising some multimethods and adding new ones as well as important classes like RandomState and Generator along with their methods. The multimethods added so far are manifold and so I won't extend the length of this blog post by enumerating them. You can however read the full list of multimethods in the PR link provided above. I also patched one ongoing PR that added multimethods for statistical functions by refactoring some default implementations. The defaults were redundantly using, in most but not all cases, a helper function for reducing the array argument's dimensions. This was brought to my attention by one of my mentors which resulted in a simple refactoring of the defaults.

What is coming up next?

The final week of GSoC is ahead of me and with that said now is the time to finish my project and write the final report. As for the first, this means mostly concluding the random module PR. If I have time I will also work on the documentation of unumpy's multimethods by linking it to NumPy's documentation through Sphinx. Although this might be an easy task, since this is my first time working with Sphinx I don't have an estimate for how long it will take me to do it. Ultimately, this might have to be done after GSoC has ended. More importantly, this upcoming week I want to focus on writing a good final report to showcase the work done during the program. This is of the utmost importance, as it is a necessary step in order to successfully pass the third and final evaluation.

Did you get stuck anywhere?

There were no blockers this week.

View Blog Post

Week 11 Check-in

Published: 08/19/2020

What did you do this week?

This week's work was divided into two parts: fixing some issues in the backends and patching up older PRs. While working on the PR for indexing routines we noticed a bug in the backends that caused some classes to not be dispatched properly. What was happening was that all the classes added in the PR were calling NumPy classes regardless of the backend being used instead of calling the equivalent classes in the respective backends. This issue also touched on another problem that I encountered while preparing the new PR for the random module. The backends were also not dispatching the multimethods in modules correctly. This was apparent by the linalg module's tests which at the time were fixed to the NumPy backend. Because of this I created a new PR that fixed both of these issues and extended the linalg tests to other backends which allowed the PR for indexing routines to be patched and merged. I also worked on a previous PR that adds multimethods for statistical functions by adding default implementations to most of the reduction methods (e.g., median, mean, var).

What is coming up next?

This week I was expected to start a new PR that adds multimethods for NumPy's random module but as I talked about in the first part of this blog post, some issues had to be fixed first. Although this delayed the PR to the next week all work seems to be on schedule. If I have time in this upcoming week I will also start writing documentation for the unumpy project and my GSoC final report. In the latter I intend to add a short description of the work that was done, allow who reads it to easily find the code, summarize the current state of the project, discuss future work, and enumerated challenges and learnings.

Did you get stuck anywhere?

I was able to unblock from last week's default implementation of median with some help. Overall, the other defaults were done without many difficulties.

View Blog Post

Week 10 Check-in

Published: 08/11/2020

What did you do this week?

This week I started a new PR that adds multimethods for statistical functions. The multimethods added are the following:

Order statistics

  • percentile
  • nanpercentile
  • quantile
  • nanquantile

Averages and variances

  • median
  • average
  • mean
  • nanmedian
  • nanmean
  • nanstd
  • nanvar


  • corrcoef
  • correlate
  • cov


  • histogram
  • histogram2d
  • histogramdd
  • bincount
  • histogram_bin_edges
  • digitize

As of now these new additions have the essential parts of a multimethod, both an argument extractor and replacer but are missing default implementations. I've also modified some of the argument replacers to support the out keyword making them more general purpose thus removing the need for some of the other more specific argument replacers.

What is coming up next?

I'll continue the PR started this week by working on default implementations for the simpler multimethods like median and mean. I will also start a new PR that adds multimethods for NumPy's random module that picks up on an older PR left off by one of my mentors. I've been wanting to work on these multimethods for a while but wasn't able to because of other project commitments. After discussing with my mentors we decided to change the work expected for the following week from the JAX backend implementation to the random module since this has a higher priority.

Did you get stuck anywhere?

Yes, working on the default implementation for median. Although this might be one of the easiest defaults from the multimethods in the current PR it has proven to be a bit of a challenge. The idea is to transverse the array along the given axes and apply a reduction function. Because of the array manipulations necessary to accomplish this and since I can't use item assignment the default is being more complicated than initial thought. More recently one of my mentors provided a general template for implementing it which might help me unblock. If I can do this other reduction multimethods' defaults should easily follow.

View Blog Post

Week 9 Check-in

Published: 08/04/2020

What did you do this week?

This week I continued the PR started in the previous week by adding more multimethods for indexing routines. The multimethods added are the following:

Generating index arrays

  • c_
  • r_
  • s_

Indexing-like operations

  • take
  • take_along_axis
  • choose
  • diagonal
  • select

Inserting data into arrays

  • place
  • put
  • put_along_axis
  • putmask
  • fill_diagonal

Iterating over arrays

  • nditer
  • ndenumerate
  • ndindex
  • nested_iters
  • lib.Arrayterator

Most of the work developed during this week was adding default implementations to the new mutimethods. Also, this is the first PR that makes use of the overriding of unumpy's classes to implement some classes for indexing routines. Unfortunately, I wasn't able to start the PR that adds multimethods for Numpy's random module that I set out to do in the last blog post. Nevertheless, since this is considered extra work there are no delays in the timeline. I will try to do this PR in the following weeks.

What is coming up next?

I will start a new PR that adds mutimethods for statistic functions. The work for this following week might be more demanding since the PR is expected to last only one week and it covers a considerable amount of multimethods. Also, some of the default implementations might add an extra challenge. Let's see how it goes! I also need to patch up the PR for the indexing routines which should be almost done.

Did you get stuck anywhere?

I didn't get stuck this week.

View Blog Post