Skip to content
This repository was archived by the owner on Jul 15, 2024. It is now read-only.

Commit 85c84ad

Browse files
committed
Add black pre-commit hook
1 parent 87fb358 commit 85c84ad

12 files changed

+190
-181
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ repos:
33
rev: 0.6.0
44
hooks:
55
- id: nbstripout
6+
- repo: https://github.com/psf/black
7+
rev: 23.3.0
8+
hooks:
9+
- id: black-jupyter

examples/Reading-Parquet-Files-using-DuckDB.ipynb

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
"source": [
4242
"import ibis\n",
4343
"\n",
44-
"t = ibis.read_parquet(f\"s3://gbif-open-data-us-east-1/occurrence/2023-04-01/occurrence.parquet/000000\")\n",
44+
"t = ibis.read_parquet(\n",
45+
" f\"s3://gbif-open-data-us-east-1/occurrence/2023-04-01/occurrence.parquet/000000\"\n",
46+
")\n",
4547
"t"
4648
]
4749
},
@@ -66,11 +68,23 @@
6668
},
6769
"outputs": [],
6870
"source": [
69-
"cols = ['gbifid', 'datasetkey', 'occurrenceid', 'kingdom',\n",
70-
" 'phylum', 'class', 'order', 'family', 'genus',\n",
71-
" 'species', 'day', 'month', 'year']\n",
71+
"cols = [\n",
72+
" \"gbifid\",\n",
73+
" \"datasetkey\",\n",
74+
" \"occurrenceid\",\n",
75+
" \"kingdom\",\n",
76+
" \"phylum\",\n",
77+
" \"class\",\n",
78+
" \"order\",\n",
79+
" \"family\",\n",
80+
" \"genus\",\n",
81+
" \"species\",\n",
82+
" \"day\",\n",
83+
" \"month\",\n",
84+
" \"year\",\n",
85+
"]\n",
7286
"\n",
73-
"t.select(cols).filter(t['family'].isin(['Corvidae'])).limit(5).execute()"
87+
"t.select(cols).filter(t[\"family\"].isin([\"Corvidae\"])).limit(5).execute()"
7488
]
7589
},
7690
{
@@ -111,7 +125,9 @@
111125
},
112126
"outputs": [],
113127
"source": [
114-
"t = ibis.read_parquet(f\"s3://gbif-open-data-us-east-1/occurrence/2023-04-01/occurrence.parquet/*\")"
128+
"t = ibis.read_parquet(\n",
129+
" f\"s3://gbif-open-data-us-east-1/occurrence/2023-04-01/occurrence.parquet/*\"\n",
130+
")"
115131
]
116132
},
117133
{
@@ -132,11 +148,11 @@
132148
"outputs": [],
133149
"source": [
134150
"df = (\n",
135-
" t.select(['gbifid', 'family', 'species'])\n",
136-
" .filter(t['family'].isin(['Corvidae']))\n",
151+
" t.select([\"gbifid\", \"family\", \"species\"])\n",
152+
" .filter(t[\"family\"].isin([\"Corvidae\"]))\n",
137153
" # Here we limit by 10,000 to fetch a quick batch of results\n",
138154
" .limit(10000)\n",
139-
" .group_by('species')\n",
155+
" .group_by(\"species\")\n",
140156
" .count()\n",
141157
" .execute()\n",
142158
")\n",

examples/Substrait.ipynb

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@
4949
"class DatabaseServer:\n",
5050
" DB_NAME = \"palmer_penguins.ddb\"\n",
5151
" DB_URL = \"https://storage.googleapis.com/ibis-tutorial-data/palmer_penguins.ddb\"\n",
52-
" \n",
52+
"\n",
5353
" def __init__(self):\n",
5454
" if not os.path.exists(self.DB_NAME):\n",
5555
" urlretrieve(self.DB_URL, self.DB_NAME)\n",
5656
" self.db = duckdb.connect(self.DB_NAME)\n",
5757
" self.db.install_extension(\"substrait\")\n",
5858
" self.db.load_extension(\"substrait\")\n",
59-
" \n",
59+
"\n",
6060
" def execute(self, substrait):\n",
6161
" result = self.db.from_substrait(substrait)\n",
6262
" return result.fetchall()\n",
63-
" \n",
63+
"\n",
6464
"\n",
6565
"db_server = DatabaseServer()"
6666
]
@@ -84,7 +84,7 @@
8484
"from ibis.expr.datatypes.core import Float64, Int64, String\n",
8585
"\n",
8686
"table = ibis.table(\n",
87-
" name=\"penguins\", \n",
87+
" name=\"penguins\",\n",
8888
" schema=[\n",
8989
" (\"species\", String()),\n",
9090
" (\"island\", String()),\n",
@@ -93,8 +93,8 @@
9393
" (\"flipper_length_mm\", Int64()),\n",
9494
" (\"body_mass_g\", Int64()),\n",
9595
" (\"sex\", String()),\n",
96-
" (\"year\", Int64)\n",
97-
" ]\n",
96+
" (\"year\", Int64),\n",
97+
" ],\n",
9898
")\n",
9999
"\n",
100100
"print(table)"
@@ -122,12 +122,7 @@
122122
"\n",
123123
"compiler = SubstraitCompiler()\n",
124124
"\n",
125-
"query = (\n",
126-
" table\n",
127-
" .select(_.species)\n",
128-
" .group_by(_.species)\n",
129-
" .agg(count=_.species.count())\n",
130-
")\n",
125+
"query = table.select(_.species).group_by(_.species).agg(count=_.species.count())\n",
131126
"\n",
132127
"substrait_plan = compiler.compile(query)\n",
133128
"\n",
@@ -172,8 +167,7 @@
172167
"outputs": [],
173168
"source": [
174169
"query = (\n",
175-
" table\n",
176-
" .select(_.island, _.species)\n",
170+
" table.select(_.island, _.species)\n",
177171
" .group_by([_.island, _.species])\n",
178172
" .agg(num=_.species.count())\n",
179173
" .order_by([ibis.asc(_.island), ibis.asc(_.species)])\n",
@@ -198,8 +192,7 @@
198192
"outputs": [],
199193
"source": [
200194
"query = (\n",
201-
" table\n",
202-
" .select(_.island, _.species, _.body_mass_g)\n",
195+
" table.select(_.island, _.species, _.body_mass_g)\n",
203196
" .group_by([_.island, _.species])\n",
204197
" .agg(num=_.species.count(), avg_weight=_.body_mass_g.mean())\n",
205198
" .order_by([ibis.asc(_.island), ibis.asc(_.species)])\n",

examples/clickhouse-hackernews.ipynb

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"import ibis\n",
2626
"from ibis import _\n",
2727
"\n",
28-
"ibis.options.interactive = True "
28+
"ibis.options.interactive = True"
2929
]
3030
},
3131
{
@@ -46,10 +46,7 @@
4646
"outputs": [],
4747
"source": [
4848
"con = ibis.clickhouse.connect(\n",
49-
" host=\"play.clickhouse.com\", \n",
50-
" port=9440, \n",
51-
" user=\"play\", \n",
52-
" secure=True\n",
49+
" host=\"play.clickhouse.com\", port=9440, user=\"play\", secure=True\n",
5350
")"
5451
]
5552
},
@@ -131,9 +128,9 @@
131128
"source": [
132129
"top_posts_by_score = (\n",
133130
" t.filter(_.title != \"\")\n",
134-
" .select(\"title\", \"score\")\n",
135-
" .order_by(ibis.desc(\"score\"))\n",
136-
" .limit(5)\n",
131+
" .select(\"title\", \"score\")\n",
132+
" .order_by(ibis.desc(\"score\"))\n",
133+
" .limit(5)\n",
137134
")\n",
138135
"\n",
139136
"top_posts_by_score"
@@ -163,11 +160,7 @@
163160
"outputs": [],
164161
"source": [
165162
"top_commenters = (\n",
166-
" t.filter(_.by != \"\")\n",
167-
" .group_by(\"by\")\n",
168-
" .count()\n",
169-
" .order_by(ibis.desc(\"count\"))\n",
170-
" .limit(5)\n",
163+
" t.filter(_.by != \"\").group_by(\"by\").count().order_by(ibis.desc(\"count\")).limit(5)\n",
171164
")\n",
172165
"\n",
173166
"top_commenters"
@@ -214,10 +207,10 @@
214207
"source": [
215208
"top_commenters_by_score = (\n",
216209
" t.filter(_.by != \"\")\n",
217-
" .group_by(\"by\")\n",
218-
" .agg(total_score=_.score.sum())\n",
219-
" .order_by(ibis.desc(\"total_score\"))\n",
220-
" .limit(5)\n",
210+
" .group_by(\"by\")\n",
211+
" .agg(total_score=_.score.sum())\n",
212+
" .order_by(ibis.desc(\"total_score\"))\n",
213+
" .limit(5)\n",
221214
")\n",
222215
"\n",
223216
"top_commenters_by_score"

tutorial/01-Introduction-to-Ibis.ipynb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"outputs": [],
3838
"source": [
3939
"from tutorial_utils import setup\n",
40+
"\n",
4041
"setup()"
4142
]
4243
},
@@ -108,7 +109,7 @@
108109
"metadata": {},
109110
"outputs": [],
110111
"source": [
111-
"connection = ibis.sqlite.connect('geography.db')"
112+
"connection = ibis.sqlite.connect(\"geography.db\")"
112113
]
113114
},
114115
{
@@ -150,7 +151,7 @@
150151
"metadata": {},
151152
"outputs": [],
152153
"source": [
153-
"countries = connection.table('countries')"
154+
"countries = connection.table(\"countries\")"
154155
]
155156
},
156157
{
@@ -184,7 +185,7 @@
184185
"metadata": {},
185186
"outputs": [],
186187
"source": [
187-
"countries['name', 'continent', 'population']"
188+
"countries[\"name\", \"continent\", \"population\"]"
188189
]
189190
},
190191
{
@@ -219,7 +220,7 @@
219220
"metadata": {},
220221
"outputs": [],
221222
"source": [
222-
"countries['name', 'continent', 'population'].limit(3)"
223+
"countries[\"name\", \"continent\", \"population\"].limit(3)"
223224
]
224225
},
225226
{
@@ -239,7 +240,7 @@
239240
"metadata": {},
240241
"outputs": [],
241242
"source": [
242-
"countries[['continent']].distinct()"
243+
"countries[[\"continent\"]].distinct()"
243244
]
244245
},
245246
{
@@ -256,7 +257,7 @@
256257
"metadata": {},
257258
"outputs": [],
258259
"source": [
259-
"countries['continent'] == 'AS'"
260+
"countries[\"continent\"] == \"AS\""
260261
]
261262
},
262263
{
@@ -274,8 +275,8 @@
274275
"metadata": {},
275276
"outputs": [],
276277
"source": [
277-
"asian_countries = countries['name', 'continent', 'population'].filter(\n",
278-
" countries['continent'] == 'AS'\n",
278+
"asian_countries = countries[\"name\", \"continent\", \"population\"].filter(\n",
279+
" countries[\"continent\"] == \"AS\"\n",
279280
")\n",
280281
"asian_countries"
281282
]
@@ -310,7 +311,7 @@
310311
"metadata": {},
311312
"outputs": [],
312313
"source": [
313-
"asian_countries.order_by('population').limit(10)"
314+
"asian_countries.order_by(\"population\").limit(10)"
314315
]
315316
},
316317
{
@@ -329,7 +330,7 @@
329330
"metadata": {},
330331
"outputs": [],
331332
"source": [
332-
"asian_countries.order_by(ibis.desc('population')).limit(10)"
333+
"asian_countries.order_by(ibis.desc(\"population\")).limit(10)"
333334
]
334335
},
335336
{

0 commit comments

Comments
 (0)