Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TL;DR of Supported Operations for Docs #83

Open
jessebett opened this issue Mar 1, 2019 · 3 comments
Open

TL;DR of Supported Operations for Docs #83

jessebett opened this issue Mar 1, 2019 · 3 comments

Comments

@jessebett
Copy link

When writing the docs, it would be nice to follow jax's lead and include a TL;DR of what sorts of operations are supported. From their docs:

TLDR Do use

    Functional programming
    Many of NumPy’s functions (help us add more!)
    Some SciPy functions
    Indexing and slicing of arrays like x = A[[5, 1, 7], :, 2:4]
    Explicit array creation from lists like A = np.array([x, y])

Don’t use

    Assignment into arrays like A[0, 0] = x
    Implicit casting to arrays like np.sum([x, y]) (use np.sum(np.array([x, y]) instead)
    A.dot(B) method syntax for functions of more than one argument (use np.dot(A, B) instead)
    Side-effects like mutation of arguments or mutation of global variables
    The out argument of NumPy functions
    Dtype casting like np.float64(x) (use x.astype('float64') or x.astype(np.float64) instead).

For jit functions, also don’t use

    Control flow based on dynamic values if x > 0: .... Control flow based on shapes is fine: if x.shape[0] > 2: ... and for subarr in array.
    Slicing A[i:i+5] for dynamic index i (use lax.dynamic_slice instead) or boolean indexing A[bool_ind] for traced values bool_ind.
@MikeInnes
Copy link
Member

This should be pretty easy for us since the only thing you can't do is assignment into arrays (yet – #75). Some general docs and usage tips are definitely a good idea though.

@baggepinnen
Copy link
Contributor

This should be pretty easy for us since the only thing you can't do is assignment into arrays (yet – #75). Some general docs and usage tips are definitely a good idea though.

How about try/catch blocks?
#47 (comment)

@MikeInnes
Copy link
Member

MikeInnes commented Mar 6, 2019

Yup, just remembered that when investigating that issue :) I'm hoping that's an easy fix though, whereas the mutation restriction will probably be part of a stable release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants