Document why 'import name as name' is used

This commit is contained in:
Jake VanderPlas 2022-12-14 15:07:04 -08:00
parent a66b3dcdd3
commit 26f2f97805
55 changed files with 166 additions and 2 deletions

View File

@ -35,6 +35,9 @@ del _cloud_tpu_init
from jax import config as _config_module
del _config_module
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.basearray import Array as Array
from jax._src.config import (

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.custom_derivatives import (
_initial_style_jaxpr,
_sum_tangents,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.dtypes import (
_jax_types, # TODO(phawkins): fix users and remove?
bfloat16 as bfloat16,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.errors import (
JAXTypeError as JAXTypeError,
JAXIndexError as JAXIndexError,

View File

@ -14,6 +14,10 @@
# TODO(https://github.com/google/jax/issues/13487): Remove PartitionSpec in
# 3 months from `jax.experimental.PartitionSpec`.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax.interpreters.pxla import PartitionSpec as PartitionSpec
from jax.experimental.x64_context import (
enable_x64 as enable_x64,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.checkify import (
Error as Error,
ErrorCategory as ErrorCategory,

View File

@ -183,6 +183,9 @@ To fit the same model on sparse data, we can apply the :func:`sparsify` transfor
-0.670236 0.03132951 -0.05356663]
"""
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax.experimental.sparse.ad import (
grad as grad,
value_and_grad as value_and_grad,

View File

@ -20,6 +20,9 @@ JAX, such as `PIX`_.
.. _PIX: https://github.com/deepmind/dm_pix
"""
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.image.scale import (
resize as resize,
ResizeMethod as ResizeMethod,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.lax.lax import (
DotDimensionNumbers as DotDimensionNumbers,
Precision as Precision,

View File

@ -14,6 +14,9 @@
"""Common functions for neural network libraries."""
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax.numpy import tanh as tanh
from jax.nn import initializers as initializers
from jax._src.nn.functions import (

View File

@ -17,6 +17,9 @@ Common neural network layer initializers, consistent with definitions
used in Keras and Sonnet.
"""
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.nn.initializers import (
constant as constant,
Initializer as Initializer,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.numpy.fft import (
ifft as ifft,
ifft2 as ifft2,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.numpy.linalg import (
cholesky as cholesky,
det as det,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.ops.scatter import (
segment_sum as segment_sum,
segment_prod as segment_prod,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.prng import (
PRNGImpl as PRNGImpl,
seed_with_impl as seed_with_impl,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.profiler import (
StepTraceAnnotation as StepTraceAnnotation,
TraceAnnotation as TraceAnnotation,

View File

@ -143,6 +143,8 @@ else:
PRNGKeyArray = _PRNGKeyArray
KeyArray = PRNGKeyArray
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.random import (
PRNGKey as PRNGKey,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from typing import TYPE_CHECKING
if TYPE_CHECKING:

View File

@ -1,4 +1,4 @@
# Copyright 2022 The JAX Authors.
# Copyright 2022 The JAX Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -12,4 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax.scipy.cluster import vq as vq

View File

@ -1,4 +1,4 @@
# Copyright 2022 The JAX Authors.
# Copyright 2022 The JAX Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -12,4 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.cluster.vq import vq as vq

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.fft import (
dct as dct,
dctn as dctn,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.linalg import (
block_diag as block_diag,
cholesky as cholesky,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.ndimage import (
map_coordinates as map_coordinates,
)

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.optimize.minimize import (
minimize as minimize,
OptimizeResults as OptimizeResults,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.signal import (
convolve as convolve,
convolve2d as convolve2d,

View File

@ -12,4 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax.scipy.sparse import linalg as linalg

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.sparse.linalg import (
cg as cg,
gmres as gmres,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.special import (
betainc as betainc,
betaln as betaln,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax.scipy.stats import bernoulli as bernoulli
from jax.scipy.stats import beta as beta
from jax.scipy.stats import cauchy as cauchy

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.bernoulli import (
logpmf as logpmf,
pmf as pmf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.beta import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.betabinom import (
logpmf as logpmf,
pmf as pmf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.cauchy import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.chi2 import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.dirichlet import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.expon import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.gamma import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.gennorm import (
cdf as cdf,
logpdf as logpdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.geom import (
logpmf as logpmf,
pmf as pmf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.laplace import (
cdf as cdf,
logpdf as logpdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.logistic import (
cdf as cdf,
isf as isf,

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.multinomial import (
logpmf as logpmf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.multivariate_normal import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.norm import (
cdf as cdf,
logcdf as logcdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.pareto import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.poisson import (
logpmf as logpmf,
pmf as pmf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.t import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.truncnorm import (
cdf as cdf,
logcdf as logcdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.uniform import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.scipy.stats.vonmises import (
logpdf as logpdf,
pdf as pdf,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.sharding import (
Sharding as Sharding,
XLACompatibleSharding as XLACompatibleSharding,

View File

@ -21,6 +21,9 @@ that represent the stages of this process.
For more, see the `AOT walkthrough <https://jax.readthedocs.io/en/latest/aot.html>`_.
"""
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.stages import (
Compiled as Compiled,
Lowered as Lowered,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.public_test_util import (
check_grads as check_grads,
check_jvp as check_jvp,

View File

@ -35,6 +35,9 @@ See the `JAX pytrees note <pytrees.html>`_
for examples.
"""
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.tree_util import (
Partial as Partial,
PyTreeDef as PyTreeDef,

View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570
from jax._src.util import (
HashableFunction as HashableFunction,
as_hashable_function as as_hashable_function,