Skip to content

Commit 5113045

Browse files
style: pre-commit fixes
1 parent b688cc6 commit 5113045

11 files changed

+337
-275
lines changed

notebooks/advanced_indexing.ipynb

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@
2525
],
2626
"source": [
2727
"import sys\n",
28-
"sys.path.insert(0, '..')\n",
29-
"import zarr\n",
28+
"\n",
29+
"sys.path.insert(0, \"..\")\n",
3030
"import numpy as np\n",
31+
"\n",
32+
"import zarr\n",
33+
"\n",
3134
"np.random.seed(42)\n",
3235
"import cProfile\n",
36+
"\n",
3337
"zarr.__version__"
3438
]
3539
},
@@ -57,7 +61,7 @@
5761
"source": [
5862
"a = np.arange(10)\n",
5963
"za = zarr.array(a, chunks=2)\n",
60-
"ix = [False, True, False, True, False, True, False, True, False, True]"
64+
"ix = [False, True, False, True, False, True, False, True, False, True]"
6165
]
6266
},
6367
{
@@ -547,7 +551,7 @@
547551
],
548552
"source": [
549553
"# combine with slice\n",
550-
"za.oindex[[1, 3], :]"
554+
"za.oindex[[1, 3], :]"
551555
]
552556
},
553557
{
@@ -973,10 +977,10 @@
973977
}
974978
],
975979
"source": [
976-
"a = np.array([(b'aaa', 1, 4.2),\n",
977-
" (b'bbb', 2, 8.4),\n",
978-
" (b'ccc', 3, 12.6)], \n",
979-
" dtype=[('foo', 'S3'), ('bar', 'i4'), ('baz', 'f8')])\n",
980+
"a = np.array(\n",
981+
" [(b\"aaa\", 1, 4.2), (b\"bbb\", 2, 8.4), (b\"ccc\", 3, 12.6)],\n",
982+
" dtype=[(\"foo\", \"S3\"), (\"bar\", \"i4\"), (\"baz\", \"f8\")],\n",
983+
")\n",
980984
"za = zarr.array(a, chunks=2, fill_value=None)\n",
981985
"za[:]"
982986
]
@@ -999,7 +1003,7 @@
9991003
}
10001004
],
10011005
"source": [
1002-
"za['foo']"
1006+
"za[\"foo\"]"
10031007
]
10041008
},
10051009
{
@@ -1020,7 +1024,7 @@
10201024
}
10211025
],
10221026
"source": [
1023-
"za['foo', 'baz']"
1027+
"za[\"foo\", \"baz\"]"
10241028
]
10251029
},
10261030
{
@@ -1041,7 +1045,7 @@
10411045
}
10421046
],
10431047
"source": [
1044-
"za[:2, 'foo']"
1048+
"za[:2, \"foo\"]"
10451049
]
10461050
},
10471051
{
@@ -1062,7 +1066,7 @@
10621066
}
10631067
],
10641068
"source": [
1065-
"za[:2, 'foo', 'baz']"
1069+
"za[:2, \"foo\", \"baz\"]"
10661070
]
10671071
},
10681072
{
@@ -1083,7 +1087,7 @@
10831087
}
10841088
],
10851089
"source": [
1086-
"za.oindex[[0, 2], 'foo']"
1090+
"za.oindex[[0, 2], \"foo\"]"
10871091
]
10881092
},
10891093
{
@@ -1104,7 +1108,7 @@
11041108
}
11051109
],
11061110
"source": [
1107-
"za.vindex[[0, 2], 'foo']"
1111+
"za.vindex[[0, 2], \"foo\"]"
11081112
]
11091113
},
11101114
{
@@ -1125,7 +1129,7 @@
11251129
}
11261130
],
11271131
"source": [
1128-
"za['bar'] = 42\n",
1132+
"za[\"bar\"] = 42\n",
11291133
"za[:]"
11301134
]
11311135
},
@@ -1147,7 +1151,7 @@
11471151
}
11481152
],
11491153
"source": [
1150-
"za[:2, 'bar'] = 84\n",
1154+
"za[:2, \"bar\"] = 84\n",
11511155
"za[:]"
11521156
]
11531157
},
@@ -1176,7 +1180,7 @@
11761180
}
11771181
],
11781182
"source": [
1179-
"a['foo', 'baz']"
1183+
"a[\"foo\", \"baz\"]"
11801184
]
11811185
},
11821186
{
@@ -1197,7 +1201,7 @@
11971201
}
11981202
],
11991203
"source": [
1200-
"a[['foo', 'baz']]"
1204+
"a[[\"foo\", \"baz\"]]"
12011205
]
12021206
},
12031207
{
@@ -1218,7 +1222,7 @@
12181222
}
12191223
],
12201224
"source": [
1221-
"za['foo', 'baz']"
1225+
"za[\"foo\", \"baz\"]"
12221226
]
12231227
},
12241228
{
@@ -1243,7 +1247,7 @@
12431247
}
12441248
],
12451249
"source": [
1246-
"za[['foo', 'baz']]"
1250+
"za[[\"foo\", \"baz\"]]"
12471251
]
12481252
},
12491253
{
@@ -1437,14 +1441,14 @@
14371441
"metadata": {},
14381442
"outputs": [],
14391443
"source": [
1440-
"import tempfile\n",
1441-
"import cProfile\n",
14421444
"import pstats\n",
1445+
"import tempfile\n",
1446+
"\n",
14431447
"\n",
1444-
"def profile(statement, sort='time', restrictions=(7,)):\n",
1448+
"def profile(statement, sort=\"time\", restrictions=(7,)):\n",
14451449
" with tempfile.NamedTemporaryFile() as f:\n",
14461450
" cProfile.run(statement, filename=f.name)\n",
1447-
" pstats.Stats(f.name).sort_stats(sort).print_stats(*restrictions)\n"
1451+
" pstats.Stats(f.name).sort_stats(sort).print_stats(*restrictions)"
14481452
]
14491453
},
14501454
{
@@ -1477,7 +1481,7 @@
14771481
}
14781482
],
14791483
"source": [
1480-
"profile('zc.oindex[ix_dense_bool]')"
1484+
"profile(\"zc.oindex[ix_dense_bool]\")"
14811485
]
14821486
},
14831487
{
@@ -1517,7 +1521,7 @@
15171521
}
15181522
],
15191523
"source": [
1520-
"profile('zc.vindex[ix_dense_bool]')"
1524+
"profile(\"zc.vindex[ix_dense_bool]\")"
15211525
]
15221526
},
15231527
{
@@ -1551,7 +1555,7 @@
15511555
}
15521556
],
15531557
"source": [
1554-
"ix_dense_int = np.random.choice(c.shape[0], size=c.shape[0]//10, replace=True)\n",
1558+
"ix_dense_int = np.random.choice(c.shape[0], size=c.shape[0] // 10, replace=True)\n",
15551559
"ix_dense_int_sorted = ix_dense_int.copy()\n",
15561560
"ix_dense_int_sorted.sort()\n",
15571561
"len(ix_dense_int)"
@@ -1689,7 +1693,7 @@
16891693
}
16901694
],
16911695
"source": [
1692-
"profile('zc.oindex[ix_dense_int_sorted]')"
1696+
"profile(\"zc.oindex[ix_dense_int_sorted]\")"
16931697
]
16941698
},
16951699
{
@@ -1722,7 +1726,7 @@
17221726
}
17231727
],
17241728
"source": [
1725-
"profile('zc.vindex[ix_dense_int_sorted]')"
1729+
"profile(\"zc.vindex[ix_dense_int_sorted]\")"
17261730
]
17271731
},
17281732
{
@@ -1755,7 +1759,7 @@
17551759
}
17561760
],
17571761
"source": [
1758-
"profile('zc.oindex[ix_dense_int]')"
1762+
"profile(\"zc.oindex[ix_dense_int]\")"
17591763
]
17601764
},
17611765
{
@@ -1788,7 +1792,7 @@
17881792
}
17891793
],
17901794
"source": [
1791-
"profile('zc.vindex[ix_dense_int]')"
1795+
"profile(\"zc.vindex[ix_dense_int]\")"
17921796
]
17931797
},
17941798
{
@@ -1908,7 +1912,7 @@
19081912
}
19091913
],
19101914
"source": [
1911-
"profile('zc.oindex[ix_sparse_bool]')"
1915+
"profile(\"zc.oindex[ix_sparse_bool]\")"
19121916
]
19131917
},
19141918
{
@@ -1941,7 +1945,7 @@
19411945
}
19421946
],
19431947
"source": [
1944-
"profile('zc.vindex[ix_sparse_bool]')"
1948+
"profile(\"zc.vindex[ix_sparse_bool]\")"
19451949
]
19461950
},
19471951
{
@@ -1968,7 +1972,7 @@
19681972
}
19691973
],
19701974
"source": [
1971-
"ix_sparse_int = np.random.choice(c.shape[0], size=c.shape[0]//10000, replace=True)\n",
1975+
"ix_sparse_int = np.random.choice(c.shape[0], size=c.shape[0] // 10000, replace=True)\n",
19721976
"ix_sparse_int_sorted = ix_sparse_int.copy()\n",
19731977
"ix_sparse_int_sorted.sort()\n",
19741978
"len(ix_sparse_int)"
@@ -2106,7 +2110,7 @@
21062110
}
21072111
],
21082112
"source": [
2109-
"profile('zc.oindex[ix_sparse_int]')"
2113+
"profile(\"zc.oindex[ix_sparse_int]\")"
21102114
]
21112115
},
21122116
{
@@ -2139,7 +2143,7 @@
21392143
}
21402144
],
21412145
"source": [
2142-
"profile('zc.vindex[ix_sparse_int]')"
2146+
"profile(\"zc.vindex[ix_sparse_int]\")"
21432147
]
21442148
},
21452149
{
@@ -2330,7 +2334,7 @@
23302334
}
23312335
],
23322336
"source": [
2333-
"profile('zc[::2]')"
2337+
"profile(\"zc[::2]\")"
23342338
]
23352339
},
23362340
{
@@ -2480,8 +2484,8 @@
24802484
"metadata": {},
24812485
"outputs": [],
24822486
"source": [
2483-
"ix0 = np.random.choice(d.shape[0], size=int(d.shape[0] * .5), replace=True)\n",
2484-
"ix1 = np.random.choice(d.shape[1], size=int(d.shape[1] * .5), replace=True)"
2487+
"ix0 = np.random.choice(d.shape[0], size=int(d.shape[0] * 0.5), replace=True)\n",
2488+
"ix1 = np.random.choice(d.shape[1], size=int(d.shape[1] * 0.5), replace=True)"
24852489
]
24862490
},
24872491
{
@@ -2542,7 +2546,7 @@
25422546
}
25432547
],
25442548
"source": [
2545-
"n = int(d.size * .1)\n",
2549+
"n = int(d.size * 0.1)\n",
25462550
"ix0 = np.random.choice(d.shape[0], size=n, replace=True)\n",
25472551
"ix1 = np.random.choice(d.shape[1], size=n, replace=True)\n",
25482552
"n"
@@ -2612,7 +2616,7 @@
26122616
}
26132617
],
26142618
"source": [
2615-
"profile('zd.vindex[ix0, ix1]')"
2619+
"profile(\"zd.vindex[ix0, ix1]\")"
26162620
]
26172621
},
26182622
{
@@ -2637,8 +2641,7 @@
26372641
"metadata": {},
26382642
"outputs": [],
26392643
"source": [
2640-
"import h5py\n",
2641-
"import tempfile"
2644+
"import h5py"
26422645
]
26432646
},
26442647
{
@@ -2647,7 +2650,7 @@
26472650
"metadata": {},
26482651
"outputs": [],
26492652
"source": [
2650-
"h5f = h5py.File(tempfile.mktemp(), driver='core', backing_store=False)"
2653+
"h5f = h5py.File(tempfile.mktemp(), driver=\"core\", backing_store=False)"
26512654
]
26522655
},
26532656
{
@@ -2667,7 +2670,9 @@
26672670
}
26682671
],
26692672
"source": [
2670-
"hc = h5f.create_dataset('c', data=c, compression='gzip', compression_opts=1, chunks=zc.chunks, shuffle=True)\n",
2673+
"hc = h5f.create_dataset(\n",
2674+
" \"c\", data=c, compression=\"gzip\", compression_opts=1, chunks=zc.chunks, shuffle=True\n",
2675+
")\n",
26712676
"hc"
26722677
]
26732678
},
@@ -2733,7 +2738,7 @@
27332738
"metadata": {},
27342739
"outputs": [],
27352740
"source": [
2736-
"# # this is pathological, takes minutes \n",
2741+
"# # this is pathological, takes minutes\n",
27372742
"# %time hc[ix_dense_bool]"
27382743
]
27392744
},

0 commit comments

Comments
 (0)