From f3336eb15b2f311e2eed2a1cf9a00dd9f8d82cec Mon Sep 17 00:00:00 2001 From: Neeraj Pradhan Date: Fri, 10 Jan 2020 15:41:08 -0800 Subject: [PATCH] Update license to Apache 2 (#516) --- .gitignore | 1 + LICENSE.md | 223 ++++++++++++++++-- docs/source/conf.py | 3 + examples/baseball.py | 3 + examples/bnn.py | 3 + examples/covtype.py | 3 + examples/funnel.py | 3 + examples/gp.py | 3 + examples/hmm.py | 3 + examples/minipyro.py | 3 + examples/neutra.py | 3 + examples/sparse_regression.py | 3 + examples/stochastic_volatility.py | 3 + examples/ucbadmit.py | 3 + examples/vae.py | 3 + notebooks/source/conf.py | 3 + numpyro/__init__.py | 3 + numpyro/compat/distributions.py | 3 + numpyro/compat/handlers.py | 3 + numpyro/compat/infer.py | 3 + numpyro/compat/ops.py | 3 + numpyro/compat/optim.py | 3 + numpyro/compat/pyro.py | 3 + numpyro/compat/util.py | 4 + numpyro/contrib/autoguide/__init__.py | 3 + numpyro/contrib/distributions/__init__.py | 3 + numpyro/contrib/distributions/continuous.py | 3 + numpyro/contrib/distributions/discrete.py | 3 + numpyro/contrib/distributions/distribution.py | 3 + numpyro/contrib/distributions/multivariate.py | 3 + numpyro/contrib/nn/__init__.py | 3 + numpyro/contrib/nn/auto_reg_nn.py | 3 + numpyro/contrib/nn/masked_dense.py | 3 + numpyro/diagnostics.py | 3 + numpyro/distributions/__init__.py | 3 + numpyro/distributions/conjugate.py | 3 + numpyro/distributions/constraints.py | 3 + numpyro/distributions/continuous.py | 3 + numpyro/distributions/discrete.py | 3 + numpyro/distributions/distribution.py | 3 + numpyro/distributions/flows.py | 3 + numpyro/distributions/transforms.py | 3 + numpyro/distributions/util.py | 3 + numpyro/examples/datasets.py | 3 + numpyro/handlers.py | 3 + numpyro/infer/__init__.py | 3 + numpyro/infer/elbo.py | 3 + numpyro/infer/hmc_util.py | 3 + numpyro/infer/mcmc.py | 3 + numpyro/infer/svi.py | 3 + numpyro/infer/util.py | 3 + numpyro/optim.py | 3 + numpyro/patch.py | 4 + numpyro/primitives.py | 3 + numpyro/util.py | 3 + numpyro/version.py | 3 + scripts/update_headers.py | 58 +++++ setup.py | 6 +- test/conftest.py | 3 + test/contrib/test_autoguide.py | 3 + test/contrib/test_distributions_contrib.py | 3 + test/contrib/test_nn.py | 3 + test/pyroapi/conftest.py | 3 + test/pyroapi/test_pyroapi.py | 3 + test/test_diagnostics.py | 3 + test/test_distributions.py | 3 + test/test_distributions_util.py | 3 + test/test_example_utils.py | 3 + test/test_examples.py | 3 + test/test_flows.py | 3 + test/test_handlers.py | 3 + test/test_hmc_util.py | 3 + test/test_infer_util.py | 3 + test/test_mcmc.py | 3 + test/test_optimizers.py | 3 + test/test_svi.py | 3 + test/test_util.py | 3 + 77 files changed, 487 insertions(+), 22 deletions(-) create mode 100644 scripts/update_headers.py diff --git a/.gitignore b/.gitignore index 58f4f4fe1..b7bc186d3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ notebooks/source/examples/ .idea .vscode *~ +*.el # data files *.pdf diff --git a/LICENSE.md b/LICENSE.md index 6dd8747b7..d64569567 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,21 +1,202 @@ -MIT License - -Copyright (c) 2019 Uber Technologies, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/source/conf.py b/docs/source/conf.py index 377db2dd3..711aee977 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import os import sys diff --git a/examples/baseball.py b/examples/baseball.py index cf9d0da06..079c624aa 100644 --- a/examples/baseball.py +++ b/examples/baseball.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Baseball ======== diff --git a/examples/bnn.py b/examples/bnn.py index 56a4f8d96..5a09ede99 100644 --- a/examples/bnn.py +++ b/examples/bnn.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Bayesian Neural Network ======================= diff --git a/examples/covtype.py b/examples/covtype.py index 332a59d91..9b3ebbc17 100644 --- a/examples/covtype.py +++ b/examples/covtype.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import argparse import time diff --git a/examples/funnel.py b/examples/funnel.py index a06514bd7..8efdc2e6f 100644 --- a/examples/funnel.py +++ b/examples/funnel.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Neal's Funnel ============= diff --git a/examples/gp.py b/examples/gp.py index 4171945f7..9e4541571 100644 --- a/examples/gp.py +++ b/examples/gp.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Gaussian Process ================ diff --git a/examples/hmm.py b/examples/hmm.py index 96450c47d..0ad3e0fe1 100644 --- a/examples/hmm.py +++ b/examples/hmm.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Hidden Markov Model =================== diff --git a/examples/minipyro.py b/examples/minipyro.py index 37411cdd3..e30df4418 100644 --- a/examples/minipyro.py +++ b/examples/minipyro.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import argparse from jax import random diff --git a/examples/neutra.py b/examples/neutra.py index 0c529a2c8..be61cf2d5 100644 --- a/examples/neutra.py +++ b/examples/neutra.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ This example illustrates how to use a trained AutoIAFNormal autoguide to transform a posterior to a Gaussian-like one. The transform will be used to get better mixing rate for NUTS sampler. diff --git a/examples/sparse_regression.py b/examples/sparse_regression.py index 35be77bb8..43d01929f 100644 --- a/examples/sparse_regression.py +++ b/examples/sparse_regression.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Sparse Regression ================= diff --git a/examples/stochastic_volatility.py b/examples/stochastic_volatility.py index da647fbdb..4dd9e698f 100644 --- a/examples/stochastic_volatility.py +++ b/examples/stochastic_volatility.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Stochastic Volatility ===================== diff --git a/examples/ucbadmit.py b/examples/ucbadmit.py index ce29fab46..1e11160c2 100644 --- a/examples/ucbadmit.py +++ b/examples/ucbadmit.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Generalized Linear Mixed Models =============================== diff --git a/examples/vae.py b/examples/vae.py index 76a82377c..206f22662 100644 --- a/examples/vae.py +++ b/examples/vae.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Variational Autoencoder ======================= diff --git a/notebooks/source/conf.py b/notebooks/source/conf.py index 39ad9aabf..0d4d2a980 100644 --- a/notebooks/source/conf.py +++ b/notebooks/source/conf.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import os import glob import shutil diff --git a/numpyro/__init__.py b/numpyro/__init__.py index 8f18de74f..3b6ca9a63 100644 --- a/numpyro/__init__.py +++ b/numpyro/__init__.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpyro import compat, diagnostics, distributions, handlers, infer, optim from numpyro.distributions.distribution import enable_validation, validation_enabled import numpyro.patch # noqa: F401 diff --git a/numpyro/compat/distributions.py b/numpyro/compat/distributions.py index eba20424a..5139440ed 100644 --- a/numpyro/compat/distributions.py +++ b/numpyro/compat/distributions.py @@ -1 +1,4 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpyro.distributions import * # noqa: F401, F403 diff --git a/numpyro/compat/handlers.py b/numpyro/compat/handlers.py index 1c9fab41d..d5b0071b2 100644 --- a/numpyro/compat/handlers.py +++ b/numpyro/compat/handlers.py @@ -1 +1,4 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpyro.handlers import * # noqa: F401, F403 diff --git a/numpyro/compat/infer.py b/numpyro/compat/infer.py index d1f44d6c2..6f2f0b37b 100644 --- a/numpyro/compat/infer.py +++ b/numpyro/compat/infer.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import math from jax import jit diff --git a/numpyro/compat/ops.py b/numpyro/compat/ops.py index 445db7417..9eda97278 100644 --- a/numpyro/compat/ops.py +++ b/numpyro/compat/ops.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import numpy as onp import jax.numpy as np diff --git a/numpyro/compat/optim.py b/numpyro/compat/optim.py index 049797a1c..0bcc8e54b 100644 --- a/numpyro/compat/optim.py +++ b/numpyro/compat/optim.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpyro import optim diff --git a/numpyro/compat/pyro.py b/numpyro/compat/pyro.py index 6bb7b2972..f9dd0343d 100644 --- a/numpyro/compat/pyro.py +++ b/numpyro/compat/pyro.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import warnings from numpyro.compat.util import UnsupportedAPIWarning diff --git a/numpyro/compat/util.py b/numpyro/compat/util.py index 8d1ab736b..dee070180 100644 --- a/numpyro/compat/util.py +++ b/numpyro/compat/util.py @@ -1,3 +1,7 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + + class UnsupportedAPIWarning(Warning): """ Warn users on Pyro operations that do not have a meaningful interpretation diff --git a/numpyro/contrib/autoguide/__init__.py b/numpyro/contrib/autoguide/__init__.py index 2eae23f55..5c34945bb 100644 --- a/numpyro/contrib/autoguide/__init__.py +++ b/numpyro/contrib/autoguide/__init__.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ .. warning:: The interface for the `contrib.autoguide` module is experimental, and diff --git a/numpyro/contrib/distributions/__init__.py b/numpyro/contrib/distributions/__init__.py index 4aeded26a..9c5f53731 100644 --- a/numpyro/contrib/distributions/__init__.py +++ b/numpyro/contrib/distributions/__init__.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpyro.contrib.distributions.continuous import ( beta, cauchy, diff --git a/numpyro/contrib/distributions/continuous.py b/numpyro/contrib/distributions/continuous.py index 3322e5683..e4fd6d2a1 100644 --- a/numpyro/contrib/distributions/continuous.py +++ b/numpyro/contrib/distributions/continuous.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # Source code modified from scipy.stats._continous_distns.py # # Copyright (c) 2001, 2002 Enthought, Inc. diff --git a/numpyro/contrib/distributions/discrete.py b/numpyro/contrib/distributions/discrete.py index ff058d7f5..a30575f9b 100644 --- a/numpyro/contrib/distributions/discrete.py +++ b/numpyro/contrib/distributions/discrete.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # Source code modified from scipy.stats._discrete_distns.py # # Copyright (c) 2001, 2002 Enthought, Inc. diff --git a/numpyro/contrib/distributions/distribution.py b/numpyro/contrib/distributions/distribution.py index 7352fd7bd..6b0c74a89 100644 --- a/numpyro/contrib/distributions/distribution.py +++ b/numpyro/contrib/distributions/distribution.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # Source code modified from scipy.stats._distn_infrastructure.py # # Copyright (c) 2001, 2002 Enthought, Inc. diff --git a/numpyro/contrib/distributions/multivariate.py b/numpyro/contrib/distributions/multivariate.py index 7d094d969..038d5e69c 100644 --- a/numpyro/contrib/distributions/multivariate.py +++ b/numpyro/contrib/distributions/multivariate.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # Source code modified from scipy.stats._multivariate.py # # Copyright (c) 2001, 2002 Enthought, Inc. diff --git a/numpyro/contrib/nn/__init__.py b/numpyro/contrib/nn/__init__.py index 4eeb717e7..6237c311a 100644 --- a/numpyro/contrib/nn/__init__.py +++ b/numpyro/contrib/nn/__init__.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpyro.contrib.nn.auto_reg_nn import AutoregressiveNN from numpyro.contrib.nn.masked_dense import MaskedDense diff --git a/numpyro/contrib/nn/auto_reg_nn.py b/numpyro/contrib/nn/auto_reg_nn.py index 23a339421..4d69ecc36 100644 --- a/numpyro/contrib/nn/auto_reg_nn.py +++ b/numpyro/contrib/nn/auto_reg_nn.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # lightly adapted from https://github.com/pyro-ppl/pyro/blob/dev/pyro/nn/auto_reg_nn.py from jax import ops diff --git a/numpyro/contrib/nn/masked_dense.py b/numpyro/contrib/nn/masked_dense.py index c35cfccba..672e2069f 100644 --- a/numpyro/contrib/nn/masked_dense.py +++ b/numpyro/contrib/nn/masked_dense.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from jax import random from jax.nn.initializers import glorot_normal, normal import jax.numpy as np diff --git a/numpyro/diagnostics.py b/numpyro/diagnostics.py index 63c41ac60..147040157 100644 --- a/numpyro/diagnostics.py +++ b/numpyro/diagnostics.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ This provides a small set of utilities in NumPyro that are used to diagnose posterior samples. """ diff --git a/numpyro/distributions/__init__.py b/numpyro/distributions/__init__.py index aa22b3409..c1629f483 100644 --- a/numpyro/distributions/__init__.py +++ b/numpyro/distributions/__init__.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpyro.distributions.conjugate import BetaBinomial, GammaPoisson import numpyro.distributions.constraints # noqa: F401 from numpyro.distributions.continuous import ( diff --git a/numpyro/distributions/conjugate.py b/numpyro/distributions/conjugate.py index 518fefe81..b63679bb5 100644 --- a/numpyro/distributions/conjugate.py +++ b/numpyro/distributions/conjugate.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from jax import lax, random import jax.numpy as np from jax.scipy.special import gammaln diff --git a/numpyro/distributions/constraints.py b/numpyro/distributions/constraints.py index 4f0159986..74237fec3 100644 --- a/numpyro/distributions/constraints.py +++ b/numpyro/distributions/constraints.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # The implementation follows the design in PyTorch: torch.distributions.constraints.py # # Copyright (c) 2016- Facebook, Inc (Adam Paszke) diff --git a/numpyro/distributions/continuous.py b/numpyro/distributions/continuous.py index 3b74295f3..32ec0b5c3 100644 --- a/numpyro/distributions/continuous.py +++ b/numpyro/distributions/continuous.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # The implementation largely follows the design in PyTorch's `torch.distributions` # # Copyright (c) 2016- Facebook, Inc (Adam Paszke) diff --git a/numpyro/distributions/discrete.py b/numpyro/distributions/discrete.py index 9ebbb970c..41a32c85e 100644 --- a/numpyro/distributions/discrete.py +++ b/numpyro/distributions/discrete.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # The implementation largely follows the design in PyTorch's `torch.distributions` # # Copyright (c) 2016- Facebook, Inc (Adam Paszke) diff --git a/numpyro/distributions/distribution.py b/numpyro/distributions/distribution.py index 27c7d331f..29727ed41 100644 --- a/numpyro/distributions/distribution.py +++ b/numpyro/distributions/distribution.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # The implementation follows the design in PyTorch: torch.distributions.distribution.py # # Copyright (c) 2016- Facebook, Inc (Adam Paszke) diff --git a/numpyro/distributions/flows.py b/numpyro/distributions/flows.py index 5ced0e934..e8dd23a1d 100644 --- a/numpyro/distributions/flows.py +++ b/numpyro/distributions/flows.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from jax import lax import jax.numpy as np diff --git a/numpyro/distributions/transforms.py b/numpyro/distributions/transforms.py index 0b74d9a81..40090ca88 100644 --- a/numpyro/distributions/transforms.py +++ b/numpyro/distributions/transforms.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import math from jax import ops diff --git a/numpyro/distributions/util.py b/numpyro/distributions/util.py index 82365b9f1..c842c8ffd 100644 --- a/numpyro/distributions/util.py +++ b/numpyro/distributions/util.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from functools import update_wrapper import math diff --git a/numpyro/examples/datasets.py b/numpyro/examples/datasets.py index c266afe45..6b1f6d3c7 100644 --- a/numpyro/examples/datasets.py +++ b/numpyro/examples/datasets.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from collections import namedtuple import csv import gzip diff --git a/numpyro/handlers.py b/numpyro/handlers.py index 82441c096..6ee1c5251 100644 --- a/numpyro/handlers.py +++ b/numpyro/handlers.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ This provides a small set of effect handlers in NumPyro that are modeled after Pyro's `poutine `_ module. diff --git a/numpyro/infer/__init__.py b/numpyro/infer/__init__.py index 252b61798..2b87bd0c7 100644 --- a/numpyro/infer/__init__.py +++ b/numpyro/infer/__init__.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpyro.infer.elbo import ELBO, RenyiELBO from numpyro.infer.mcmc import HMC, MCMC, NUTS from numpyro.infer.svi import SVI diff --git a/numpyro/infer/elbo.py b/numpyro/infer/elbo.py index b7ff484e6..337266684 100644 --- a/numpyro/infer/elbo.py +++ b/numpyro/infer/elbo.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from jax import random, vmap from jax.lax import stop_gradient import jax.numpy as np diff --git a/numpyro/infer/hmc_util.py b/numpyro/infer/hmc_util.py index b1a7155a9..43fe545d3 100644 --- a/numpyro/infer/hmc_util.py +++ b/numpyro/infer/hmc_util.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from collections import namedtuple from jax import grad, random, value_and_grad, vmap diff --git a/numpyro/infer/mcmc.py b/numpyro/infer/mcmc.py index 93d4ab921..832295f5d 100644 --- a/numpyro/infer/mcmc.py +++ b/numpyro/infer/mcmc.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from abc import ABC, abstractmethod from collections import namedtuple import functools diff --git a/numpyro/infer/svi.py b/numpyro/infer/svi.py index a332a82d5..cde7f0021 100644 --- a/numpyro/infer/svi.py +++ b/numpyro/infer/svi.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from functools import namedtuple import jax diff --git a/numpyro/infer/util.py b/numpyro/infer/util.py index 42c42818a..ddf4349e3 100644 --- a/numpyro/infer/util.py +++ b/numpyro/infer/util.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from functools import partial import warnings diff --git a/numpyro/optim.py b/numpyro/optim.py index daf8564e9..7a8902848 100644 --- a/numpyro/optim.py +++ b/numpyro/optim.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + """ Optimizer classes defined here are light wrappers over the corresponding optimizers sourced from :mod:`jax.experimental.optimizers` with an interface that is better diff --git a/numpyro/patch.py b/numpyro/patch.py index e6c3b4b8c..ca02562de 100644 --- a/numpyro/patch.py +++ b/numpyro/patch.py @@ -1,3 +1,7 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + + def patch_dependency(target, root_module): parts = target.split('.') assert parts[0] == root_module.__name__ diff --git a/numpyro/primitives.py b/numpyro/primitives.py index 27d3921cd..0d8143c79 100644 --- a/numpyro/primitives.py +++ b/numpyro/primitives.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from collections import namedtuple import functools diff --git a/numpyro/util.py b/numpyro/util.py index 696f1854c..b804e18af 100644 --- a/numpyro/util.py +++ b/numpyro/util.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from collections import namedtuple, OrderedDict from contextlib import contextmanager import os diff --git a/numpyro/version.py b/numpyro/version.py index d93b5b242..5bdc40b7e 100644 --- a/numpyro/version.py +++ b/numpyro/version.py @@ -1 +1,4 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + __version__ = '0.2.3' diff --git a/scripts/update_headers.py b/scripts/update_headers.py new file mode 100644 index 000000000..3cf075113 --- /dev/null +++ b/scripts/update_headers.py @@ -0,0 +1,58 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + +import os +import glob + +root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +blacklist = ["/build/", "/dist/", "/pyro_api.egg"] +file_types = [ + ("*.py", "# {}"), + ("*.cpp", "// {}"), +] + +for basename, comment in file_types: + copyright_line = comment.format("Copyright Contributors to the Pyro project.\n") + # See https://spdx.org/ids-how + spdx_line = comment.format("SPDX-License-Identifier: Apache-2.0\n") + + filenames = glob.glob(os.path.join(root, "**", basename), recursive=True) + filenames.sort() + filenames = [ + filename + for filename in filenames + if not any(word in filename for word in blacklist) + ] + for filename in filenames: + with open(filename) as f: + lines = f.readlines() + + # Ignore empty files like __init__.py + if all(line.isspace() for line in lines): + continue + + # Ensure first few line are copyright notices. + lineno = 0 + if not lines[lineno].startswith(comment.format("Copyright")): + lines.insert(lineno, copyright_line) + else: + lines[lineno] = copyright_line + lineno += 1 + while lines[lineno].startswith(comment.format("Copyright")): + lineno += 1 + + # Ensure next line is an SPDX short identifier. + if not lines[lineno].startswith(comment.format("SPDX-License-Identifier")): + lines.insert(lineno, spdx_line) + else: + lines[lineno] = spdx_line + lineno += 1 + + # Ensure next line is blank. + if not lines[lineno].isspace(): + lines.insert(lineno, "\n") + + with open(filename, "w") as f: + f.write("".join(lines)) + + print("updated {}".format(filename[len(root) + 1:])) diff --git a/setup.py b/setup.py index 3726569e3..a373112f3 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from __future__ import absolute_import, division, print_function import os @@ -48,11 +51,12 @@ long_description=long_description, long_description_content_type='text/markdown', keywords='probabilistic machine learning bayesian statistics', + license='Apache License 2.0', classifiers=[ 'Intended Audience :: Developers', 'Intended Audience :: Education', 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', + 'License :: OSI Approved :: Apache Software License', 'Operating System :: POSIX :: Linux', 'Operating System :: MacOS :: MacOS X', 'Programming Language :: Python :: 3.6', diff --git a/test/conftest.py b/test/conftest.py index 1ecf63d3e..5c38ae12c 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import os from numpyro.util import set_rng_seed diff --git a/test/contrib/test_autoguide.py b/test/contrib/test_autoguide.py index ed4abb8e7..1f1ecc112 100644 --- a/test/contrib/test_autoguide.py +++ b/test/contrib/test_autoguide.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from functools import partial from numpy.testing import assert_allclose diff --git a/test/contrib/test_distributions_contrib.py b/test/contrib/test_distributions_contrib.py index a6cf04299..9b11fa32b 100644 --- a/test/contrib/test_distributions_contrib.py +++ b/test/contrib/test_distributions_contrib.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from functools import reduce from operator import mul diff --git a/test/contrib/test_nn.py b/test/contrib/test_nn.py index d1056e59c..7ffd3263f 100644 --- a/test/contrib/test_nn.py +++ b/test/contrib/test_nn.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + # lightly adapted from https://github.com/pyro-ppl/pyro/blob/dev/tests/nn/ import numpy as onp diff --git a/test/pyroapi/conftest.py b/test/pyroapi/conftest.py index b2f52eb4a..6774882de 100644 --- a/test/pyroapi/conftest.py +++ b/test/pyroapi/conftest.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import pytest diff --git a/test/pyroapi/test_pyroapi.py b/test/pyroapi/test_pyroapi.py index 0c4e26317..f61fca833 100644 --- a/test/pyroapi/test_pyroapi.py +++ b/test/pyroapi/test_pyroapi.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from pyroapi import pyro_backend from pyroapi.tests import * # noqa F401 import pytest diff --git a/test/test_diagnostics.py b/test/test_diagnostics.py index 2837d53dc..381f9b8fb 100644 --- a/test/test_diagnostics.py +++ b/test/test_diagnostics.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import numpy as onp from numpy.testing import assert_allclose import pytest diff --git a/test/test_distributions.py b/test/test_distributions.py index 84832f9bc..7c4743fe5 100644 --- a/test/test_distributions.py +++ b/test/test_distributions.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from collections import namedtuple from functools import partial import inspect diff --git a/test/test_distributions_util.py b/test/test_distributions_util.py index 783fc41f1..b75c620f1 100644 --- a/test/test_distributions_util.py +++ b/test/test_distributions_util.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numbers import Number import numpy as onp diff --git a/test/test_example_utils.py b/test/test_example_utils.py index 0c2cc89ee..117f51a18 100644 --- a/test/test_example_utils.py +++ b/test/test_example_utils.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import jax.numpy as np from numpyro.examples.datasets import BASEBALL, COVTYPE, MNIST, SP500, load_dataset diff --git a/test/test_examples.py b/test/test_examples.py index 6ef06161c..e214b6882 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import os from subprocess import check_call import sys diff --git a/test/test_flows.py b/test/test_flows.py index 13d35bb02..54314c891 100644 --- a/test/test_flows.py +++ b/test/test_flows.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from functools import partial import numpy as onp diff --git a/test/test_handlers.py b/test/test_handlers.py index 4e09040f3..615d322e7 100644 --- a/test/test_handlers.py +++ b/test/test_handlers.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpy.testing import assert_allclose, assert_raises import pytest diff --git a/test/test_hmc_util.py b/test/test_hmc_util.py index 4a3ae087d..823792072 100644 --- a/test/test_hmc_util.py +++ b/test/test_hmc_util.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from collections import namedtuple import logging import os diff --git a/test/test_infer_util.py b/test/test_infer_util.py index 74d9516dc..24f464f71 100644 --- a/test/test_infer_util.py +++ b/test/test_infer_util.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from functools import partial from numpy.testing import assert_allclose diff --git a/test/test_mcmc.py b/test/test_mcmc.py index cc192599a..c552db85d 100644 --- a/test/test_mcmc.py +++ b/test/test_mcmc.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import os import numpy as onp diff --git a/test/test_optimizers.py b/test/test_optimizers.py index 3e95a9715..bbdd9862b 100644 --- a/test/test_optimizers.py +++ b/test/test_optimizers.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + import pytest from jax import grad, jit, partial diff --git a/test/test_svi.py b/test/test_svi.py index 9d2a6b55a..925cf8ab7 100644 --- a/test/test_svi.py +++ b/test/test_svi.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpy.testing import assert_allclose import pytest diff --git a/test/test_util.py b/test/test_util.py index 4f4a506f1..6ef6c9a0f 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -1,3 +1,6 @@ +# Copyright Contributors to the Pyro project. +# SPDX-License-Identifier: Apache-2.0 + from numpy.testing import assert_allclose import pytest