Skip to content

Commit

Permalink
Merge pull request #163 from GoogleCloudPlatform/black-exponentoperator
Browse files Browse the repository at this point in the history
pre-commit autoupdate and related changes
  • Loading branch information
BenoitDherin committed Feb 24, 2022
2 parents a123059 + 59d9ae8 commit 7115916
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -24,7 +24,7 @@ repos:
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.2.2
rev: 1.2.3
hooks:
- id: nbqa-black
args: [-l80]
Expand All @@ -38,7 +38,7 @@ repos:
- id: isort
args: ["--profile", "black", "-l80"]
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black
args: [-l 80]
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -116,3 +116,11 @@ However if you must exclude a file, you can do it with the [`exclude`](https://p
pre-commit.ci comes with an autoupdate feature that cannot be disabled, it runs at least once a quarter (see in the config file `autoupdate_schedule: quarterly`).

You can either accept and merge this PR, or if you probably don't want the Google CLA check to be failing, then create your own branch, run `pre-commit autoupdate`, and commit and merge the results, and delete the original PR.

#### _pre-commit.ci is failing because `nbqa-black` and `black-jupyter` disagree (and maybe it worked fine locally)_

`nbqa-black` uses your local version of `black` (meaning the latest version on the server side), and this can clash with the `black` version pinned in the `pre-commit-config.yaml`.

The solution is to upgrade your local `black` (such as `pip install --upgrade black`), run `pre-commit autoupdate` and push the changes.

(In theory there would be a solution, in the pre-commit-config.yaml file in the nbqa-black section one could add something like `additional_dependencies : ['black:21.12b0']` ([see also the same advice in the nbQA doc](https://github.com/nbQA-dev/nbQA#pre-commit)), but probably this would add an unnecessary layer of manual maintenance burden (e.g. having to manually bump this version and sync with `black`'s).)
Expand Up @@ -148,7 +148,7 @@ def transform(inputs, numeric_cols, nbuckets):
)
ploc = fc.crossed_column([b_plat, b_plon], nbuckets * nbuckets)
dloc = fc.crossed_column([b_dlat, b_dlon], nbuckets * nbuckets)
pd_pair = fc.crossed_column([ploc, dloc], nbuckets ** 4)
pd_pair = fc.crossed_column([ploc, dloc], nbuckets**4)
feature_columns["pickup_and_dropoff"] = fc.embedding_column(pd_pair, 100)

return transformed, feature_columns
Expand Down
Expand Up @@ -148,7 +148,7 @@ def transform(inputs, numeric_cols, nbuckets):
)
ploc = fc.crossed_column([b_plat, b_plon], nbuckets * nbuckets)
dloc = fc.crossed_column([b_dlat, b_dlon], nbuckets * nbuckets)
pd_pair = fc.crossed_column([ploc, dloc], nbuckets ** 4)
pd_pair = fc.crossed_column([ploc, dloc], nbuckets**4)
feature_columns["pickup_and_dropoff"] = fc.embedding_column(pd_pair, 100)

return transformed, feature_columns
Expand Down
Expand Up @@ -508,7 +508,7 @@
" # create crossed columns\n",
" ploc = fc.crossed_column([b_plat, b_plon], nbuckets * nbuckets)\n",
" dloc = fc.crossed_column([b_dlat, b_dlon], nbuckets * nbuckets)\n",
" pd_pair = fc.crossed_column([ploc, dloc], nbuckets ** 4)\n",
" pd_pair = fc.crossed_column([ploc, dloc], nbuckets**4)\n",
"\n",
" # create embedding columns\n",
" feature_columns[\"pickup_and_dropoff\"] = fc.embedding_column(pd_pair, 100)\n",
Expand Down
Expand Up @@ -629,7 +629,7 @@
"outputs": [],
"source": [
"X = tf.constant(np.linspace(0, 2, 1000), dtype=tf.float32)\n",
"Y = X * tf.exp(-(X ** 2))"
"Y = X * tf.exp(-(X**2))"
]
},
{
Expand Down
Expand Up @@ -625,7 +625,7 @@
"outputs": [],
"source": [
"X = tf.constant(np.linspace(0, 2, 1000), dtype=tf.float32)\n",
"Y = X * tf.exp(-(X ** 2))"
"Y = X * tf.exp(-(X**2))"
]
},
{
Expand Down
Expand Up @@ -577,7 +577,7 @@
"outputs": [],
"source": [
"X = tf.constant(np.linspace(0, 2, 1000), dtype=tf.float32)\n",
"Y = X * tf.exp(-(X ** 2))"
"Y = X * tf.exp(-(X**2))"
]
},
{
Expand Down
Expand Up @@ -180,7 +180,7 @@
" hash_bucket_size=NBUCKETS * NBUCKETS,\n",
")\n",
"fc_crossed_pd_pair = fc.crossed_column(\n",
" [fc_crossed_dloc, fc_crossed_ploc], hash_bucket_size=NBUCKETS ** 4\n",
" [fc_crossed_dloc, fc_crossed_ploc], hash_bucket_size=NBUCKETS**4\n",
")\n",
"\n",
"# 3. Create embedding columns for the crossed columns\n",
Expand Down
Expand Up @@ -286,7 +286,7 @@
},
"source": [
"def f(x, y):\n",
" return 2 * x * y ** 2\n",
" return 2 * x * y**2\n",
"\n",
"\n",
"# YOUR ACTION REQUIRED:\n",
Expand Down Expand Up @@ -423,11 +423,11 @@
"\n",
"@jax.jit\n",
"def f1_jit(x):\n",
" return x ** 0.5\n",
" return x**0.5\n",
"\n",
"\n",
"def f2(x):\n",
" return x ** 0.5\n",
" return x**0.5\n",
"\n",
"\n",
"# It's really the same.\n",
Expand Down Expand Up @@ -788,7 +788,7 @@
" for value in value_flat:\n",
" if isinstance(value, jnp.ndarray):\n",
" value = value.sum()\n",
" tot += value ** 2\n",
" tot += value**2\n",
" return tot\n",
"\n",
"\n",
Expand Down
8 changes: 4 additions & 4 deletions notebooks/jax/solutions/jax_fundamentals.ipynb
Expand Up @@ -603,7 +603,7 @@
],
"source": [
"def f(x, y):\n",
" return 2 * x * y ** 2\n",
" return 2 * x * y**2\n",
"\n",
"\n",
"# YOUR ACTION REQUIRED:\n",
Expand Down Expand Up @@ -862,11 +862,11 @@
"\n",
"@jax.jit\n",
"def f1_jit(x):\n",
" return x ** 0.5\n",
" return x**0.5\n",
"\n",
"\n",
"def f2(x):\n",
" return x ** 0.5\n",
" return x**0.5\n",
"\n",
"\n",
"# It's really the same.\n",
Expand Down Expand Up @@ -1612,7 +1612,7 @@
" for value in value_flat:\n",
" if isinstance(value, jnp.ndarray):\n",
" value = value.sum()\n",
" tot += value ** 2\n",
" tot += value**2\n",
" return tot\n",
"\n",
"\n",
Expand Down
Expand Up @@ -1267,7 +1267,7 @@
" plots.\n",
" \"\"\"\n",
" # fn plot args\n",
" x = tf.linspace(start_val, end_val, m_steps ** 2 + 1)\n",
" x = tf.linspace(start_val, end_val, m_steps**2 + 1)\n",
" y = fn(x)\n",
"\n",
" fig = plt.figure(figsize=(16, 4))\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/supplemental/labs/autoencoder.ipynb
Expand Up @@ -609,7 +609,7 @@
" filenames = sorted(filenames)\n",
" last = -1\n",
" for i, filename in enumerate(filenames):\n",
" frame = 2 * (i ** 0.5)\n",
" frame = 2 * (i**0.5)\n",
" if round(frame) > round(last):\n",
" last = frame\n",
" else:\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/supplemental/labs/deepconv_gan.ipynb
Expand Up @@ -828,7 +828,7 @@
" filenames = sorted(filenames)\n",
" last = -1\n",
" for i, filename in enumerate(filenames):\n",
" frame = 2 * (i ** 0.5)\n",
" frame = 2 * (i**0.5)\n",
" if round(frame) > round(last):\n",
" last = frame\n",
" else:\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/supplemental/solutions/autoencoder.ipynb
Expand Up @@ -653,7 +653,7 @@
" filenames = sorted(filenames)\n",
" last = -1\n",
" for i, filename in enumerate(filenames):\n",
" frame = 2 * (i ** 0.5)\n",
" frame = 2 * (i**0.5)\n",
" if round(frame) > round(last):\n",
" last = frame\n",
" else:\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/supplemental/solutions/deepconv_gan.ipynb
Expand Up @@ -888,7 +888,7 @@
" filenames = sorted(filenames)\n",
" last = -1\n",
" for i, filename in enumerate(filenames):\n",
" frame = 2 * (i ** 0.5)\n",
" frame = 2 * (i**0.5)\n",
" if round(frame) > round(last):\n",
" last = frame\n",
" else:\n",
Expand Down

0 comments on commit 7115916

Please sign in to comment.