GitHub - data-apis/array-api-comparison: Data and tooling to compare the API surfaces of various array libraries. (original) (raw)

Array API Comparison

Data and tooling to compare the API surfaces of various array libraries.

Overview

The goal of this repository is to compare the public API surfaces of various PyData array libraries in order to better understand existing practice. In analyzing both the commonalities and differences across array libraries, we can derive a common API subset which can be standardized and used to ensure consistency (naming and otherwise) across array libraries. This API subset should include attribute names, method names, and positional and keyword arguments.

By deriving a common API subset, we can reduce friction among library consumers by reducing the cognitive overhead of learning array dialects. This is exemplified by the following user story:

As an array library author, I know that, regardless of the input array, whether NumPy, Dask, PyTorch, etc, the array has a method to compute the transpose which is guaranteed to have options x, y, and z.

Currently, the needs of the library author in the above user story are not met, as libraries vary in their naming conventions and the optional arguments they support.

Through specification and array library compliance, we facilitate array interoperability for both users and library developers.


Array Libraries

Currently, the following array libraries are evaluated:


Installation

Navigate to the directory into which you want to clone this repository

$ cd ./repository/destination/directory

Next, clone the repository

$ git clone https://github.com/data-apis/array-api-comparison.git

Once cloned, navigate to the repository directory

$ cd ./array-api-comparison

Create an Anaconda environment

$ conda create -n array-api-comparison -c conda-forge python=3.8 nodejs jupyterlab

To activate the environment,

$ conda activate array-api-comparison

Run the installation sequence


Usage

Usage: make <cmd>

  make help                              Print this message.
  
  make view-docs                         View all array API tables.

  make view-join                         View cross-library array API data.

  make view-intersection                 View the intersection of array library 
                                         APIs.

  make view-intersection-ranks           View a table ranking the intersection
                                         of array library APIs.

  make view-common-apis                  View relatively common array library
                                         APIs.

  make view-common-apis-ranks            View a table ranking relatively common
                                         array library APIs.

  make view-complement                   View array library APIs which are not
                                         in the intersection.

  make view-common-complement            View array library APIs which are not
                                         among the list of relatively common
                                         APIs.

  make view-lib-top-k-common             View a table displaying the top `K`
                                         (relatively) common array library APIs
                                         across various libraries.

  make view-lib-top-k-complement         View a table displaying the top K array
                                         library APIs in the complement across
                                         various libraries.
                                         
  make view-lib-top-k-common-complement  View a table displaying the top `K`
                                         array library APIs in the complement of
                                         the list of (relatively) common APIs
                                         across various libraries.

To run the Jupyter notebooks, run


Organization

This repository contains the following directories:

The data directory contains the following directories

The raw data directory contains the following datasets:

The joins data directory contains the following datasets:

Lastly, the root data directory contains the following additional datasets:

Note: the datasets in the root data directory are generated.

When editing data files, consider the JSON data to be the source of truth. CSV files are generated from the JSON data.


Contributing

To contribute array API data to this repository, add an data/joins/XXXXX_numpy.json file, where XXXXX is the lowercase name of the relevant array library (e.g., cupy). The JSON file should include a JSON array, where each array element has the following fields:

For example,

[
    {
        "name": "all",
        "numpy": "numpy.all"
    },
    {
        "name": "allclose",
        "numpy": "numpy.allclose"
    },
    ...
]

Once added, the CSV variant can be generated using internal tooling.