Skip to content

Commit 5b68753

Browse files
committed
FIX: apply suggested changes from tox
1 parent 3cdd5e0 commit 5b68753

33 files changed

+274
-293
lines changed

.tox/.pkg/file.lock

Whitespace-only changes.

env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: fmriprep
1+
name: petprep
22
channels:
33
- https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/
44
- conda-forge

notebooks/01 - Figure 2 and Figure SF3.ipynb

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"outputs": [],
1010
"source": [
1111
"import warnings\n",
12-
"warnings.filterwarnings(\"ignore\")"
12+
"\n",
13+
"warnings.filterwarnings('ignore')"
1314
]
1415
},
1516
{
@@ -33,12 +34,12 @@
3334
"source": [
3435
"#%matplotlib inline\n",
3536
"import os\n",
36-
"import json\n",
37-
"import pandas as pd\n",
38-
"import glob\n",
39-
"import numpy as np\n",
4037
"from pathlib import Path\n",
38+
"\n",
4139
"import matplotlib as mpl\n",
40+
"import numpy as np\n",
41+
"import pandas as pd\n",
42+
"\n",
4243
"mpl.use('pgf')\n",
4344
"\n",
4445
"import matplotlib.pyplot as plt\n",
@@ -234,17 +235,17 @@
234235
],
235236
"source": [
236237
"from collections import Counter\n",
237-
"from matplotlib.colors import LinearSegmentedColormap, Normalize\n",
238+
"\n",
238239
"import seaborn as sns\n",
239-
"from scipy import stats\n",
240+
"from matplotlib.colors import LinearSegmentedColormap, Normalize\n",
240241
"\n",
241242
"plt.clf()\n",
242243
"\n",
243-
"sns.set_style(\"whitegrid\", {\n",
244+
"sns.set_style('whitegrid', {\n",
244245
" 'ytick.major.size': 5,\n",
245246
" 'xtick.major.size': 5,\n",
246247
"})\n",
247-
"sns.set_context(\"notebook\", font_scale=1)\n",
248+
"sns.set_context('notebook', font_scale=1)\n",
248249
"\n",
249250
"pgf_with_custom_preamble = {\n",
250251
"# 'font.sans-serif': ['Helvetica Light'],\n",
@@ -253,7 +254,7 @@
253254
" 'pgf.rcfonts': False, # don't setup fonts from rc parameters\n",
254255
" 'pgf.texsystem': 'xelatex',\n",
255256
" 'verbose.level': 'debug-annoying',\n",
256-
" \"pgf.preamble\": [\n",
257+
" 'pgf.preamble': [\n",
257258
"# r'\\renewcommand{\\sfdefault}{phv}',\n",
258259
"# r'\\usepackage[scaled=.92]{helvet}',\n",
259260
" r'\\usepackage{fontspec}',\n",
@@ -301,20 +302,20 @@
301302
"# Plot qc1\n",
302303
"df0 = df[df.version.str.contains('1.0.0')]\n",
303304
"unique, counts = np.unique(df0[['overall']].values.ravel(), return_counts=True)\n",
304-
"qc1_counts = dict(zip(unique, counts))\n",
305+
"qc1_counts = dict(zip(unique, counts, strict=False))\n",
305306
"ax.scatter([1] * len(unique), unique, c='w', s=counts * factor, zorder=2)\n",
306307
"qc1_scatter = ax.scatter([1] * len(unique), unique, c=cm(norm(unique)), alpha=0.7, s=counts * factor, zorder=3)\n",
307308
"\n",
308-
"print(dict(zip(unique, counts)))\n",
309+
"print(dict(zip(unique, counts, strict=False)))\n",
309310
"\n",
310311
"# Plot qc2\n",
311312
"df1 = df[df.version.str.contains('1.0.7')]\n",
312313
"unique, counts = np.unique(df1[['overall']].values.ravel(), return_counts=True)\n",
313-
"qc2_counts = dict(zip(unique, counts))\n",
314+
"qc2_counts = dict(zip(unique, counts, strict=False))\n",
314315
"ax.scatter([2] * len(unique), unique, c='w', s=counts * factor, zorder=2)\n",
315316
"qc2_scatter = ax.scatter([2] * len(unique), unique, c=cm(norm(unique)), alpha=0.7, s=counts * factor, zorder=3)\n",
316317
"\n",
317-
"print(dict(zip(unique, counts)))\n",
318+
"print(dict(zip(unique, counts, strict=False)))\n",
318319
"\n",
319320
"ax.set(yticks=[0.0, 1.0, 2.0, 3.0])\n",
320321
"ax.set(yticklabels=['Critical', 'Poor', 'Acceptable', 'Excellent'])\n",
@@ -329,14 +330,14 @@
329330
" plt.scatter([],[], s=factor * 30, color='gray', edgecolors='none', alpha=.3)\n",
330331
"]\n",
331332
"\n",
332-
"labels = [\"1 dataset\", \"4 datasets\", \"10 datasets\", \"30 datasets\"]\n",
333+
"labels = ['1 dataset', '4 datasets', '10 datasets', '30 datasets']\n",
333334
"\n",
334335
"leg = plt.legend(sc, labels, ncol=1, frameon=False, fontsize=12,\n",
335336
" handlelength=2, loc=1, borderpad = 1.2,\n",
336337
" handletextpad=1, scatterpoints = 1,\n",
337338
" bbox_to_anchor=(2.0, 1.0))\n",
338339
"\n",
339-
"sns.despine(offset=60, trim=True);\n",
340+
"sns.despine(offset=60, trim=True)\n",
340341
"sns.despine(bottom=True)\n",
341342
"\n",
342343
"\n",
@@ -360,7 +361,7 @@
360361
"DS000108 and DS000148 \\\\textbf{improved the most} after addressing particular \\\n",
361362
"issues\"\"\"\n",
362363
"\n",
363-
"annotfmt = r\"\\noindent\\parbox{{{0:.1f}cm}}{{\\raggedright \\textit{{{1}}}}}\".format\n",
364+
"annotfmt = r'\\noindent\\parbox{{{0:.1f}cm}}{{\\raggedright \\textit{{{1}}}}}'.format\n",
364365
"# ax.annotate(\n",
365366
"# annotfmt(5.0, annot1),\n",
366367
"# xy=(2.05, 2), xycoords='data', xytext=(2.5, 1.9),\n",
@@ -407,11 +408,8 @@
407408
},
408409
"outputs": [],
409410
"source": [
410-
"from scipy import stats\n",
411-
"from seaborn.categorical import _CategoricalScatterPlotter\n",
412-
"from seaborn.axisgrid import PairGrid, utils\n",
413411
"from matplotlib.colors import LinearSegmentedColormap, Normalize\n",
414-
"from matplotlib import gridspec\n",
412+
"from seaborn.axisgrid import PairGrid, utils\n",
415413
"\n",
416414
"# class PairGrid(Grid):\n",
417415
"# def __init__(self, data, hue=None, hue_order=None, palette=None,\n",
@@ -420,7 +418,7 @@
420418
"# despine=True, dropna=True, size=None):\n",
421419
"\n",
422420
"\n",
423-
" \n",
421+
"\n",
424422
"\n",
425423
"class MyPairGrid(PairGrid):\n",
426424
" def __init__(self, data, data0, hue=None, hue_order=None, palette=None,\n",
@@ -438,7 +436,7 @@
438436
" y_vars = list(vars)\n",
439437
" elif (x_vars is not None) or (y_vars is not None):\n",
440438
" if (x_vars is None) or (y_vars is None):\n",
441-
" raise ValueError(\"Must specify `x_vars` and `y_vars`\")\n",
439+
" raise ValueError('Must specify `x_vars` and `y_vars`')\n",
442440
" else:\n",
443441
" numeric_cols = self._find_numeric_cols(data)\n",
444442
" x_vars = numeric_cols\n",
@@ -464,9 +462,9 @@
464462
"\n",
465463
" fig, axes = plt.subplots(len(y_vars), len(x_vars),\n",
466464
" figsize=figsize,\n",
467-
" sharex=\"col\", sharey=\"row\",\n",
465+
" sharex='col', sharey='row',\n",
468466
" squeeze=False)\n",
469-
" \n",
467+
"\n",
470468
" self.fig = fig\n",
471469
" self.axes = axes\n",
472470
" self.data = data\n",
@@ -481,8 +479,8 @@
481479
" # Sort out the hue variable\n",
482480
" self._hue_var = hue\n",
483481
" if hue is None:\n",
484-
" self.hue_names = [\"_nolegend_\"]\n",
485-
" self.hue_vals = pd.Series([\"_nolegend_\"] * len(data),\n",
482+
" self.hue_names = ['_nolegend_']\n",
483+
" self.hue_vals = pd.Series(['_nolegend_'] * len(data),\n",
486484
" index=data.index)\n",
487485
" else:\n",
488486
" hue_names = utils.categorical_order(data[hue], hue_order)\n",
@@ -502,14 +500,14 @@
502500
" if despine:\n",
503501
" utils.despine(fig=fig)\n",
504502
" fig.tight_layout()\n",
505-
" \n",
506-
" \n",
503+
"\n",
504+
"\n",
507505
" data.index = data.dataset\n",
508506
" data0.index = data0.dataset\n",
509507
" self.data0 = data0.reindex(data.index)\n",
510508
" self.hue_names = None\n",
511509
" self.plots = None\n",
512-
" \n",
510+
"\n",
513511
" def map(self, func, **kwargs):\n",
514512
" \"\"\"Plot with the same function in every subplot.\n",
515513
" Parameters\n",
@@ -518,7 +516,7 @@
518516
" Must take x, y arrays as positional arguments and draw onto the\n",
519517
" \"currently active\" matplotlib Axes.\n",
520518
" \"\"\"\n",
521-
" kw_color = kwargs.pop(\"color\", None)\n",
519+
" kw_color = kwargs.pop('color', None)\n",
522520
"\n",
523521
" self.plots = []\n",
524522
" for j, x_var in enumerate(self.x_vars):\n",
@@ -531,21 +529,21 @@
531529
"\n",
532530
" self._clean_axis(ax)\n",
533531
" self._update_legend_data(ax)\n",
534-
" \n",
535-
" \n",
532+
"\n",
533+
"\n",
536534
"def stripplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None,\n",
537535
" jitter=False, dodge=False, orient=None, color=None, palette=None,\n",
538-
" size=5, edgecolor=\"gray\", linewidth=0, ax=None, **kwargs):\n",
536+
" size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs):\n",
539537
" plotter = _StripPlotter(x, y, hue, data, order, hue_order,\n",
540538
" jitter, dodge, orient, color, palette)\n",
541539
" if ax is None:\n",
542540
" ax = plt.gca()\n",
543541
"\n",
544-
" kwargs.setdefault(\"zorder\", 3)\n",
545-
" size = kwargs.get(\"s\", size)\n",
542+
" kwargs.setdefault('zorder', 3)\n",
543+
" size = kwargs.get('s', size)\n",
546544
" if linewidth is None:\n",
547545
" linewidth = size / 10\n",
548-
" if edgecolor == \"gray\":\n",
546+
" if edgecolor == 'gray':\n",
549547
" edgecolor = plotter.gray\n",
550548
" kwargs.update(dict(s=size ** 2,\n",
551549
" edgecolor=edgecolor,\n",
@@ -557,7 +555,7 @@
557555
"\n",
558556
"def mystripplot(x=None, x0=None, y=None, hue=None, data=None, order=None, hue_order=None,\n",
559557
" jitter=False, dodge=False, orient=None, color=None, palette=None,\n",
560-
" size=5, edgecolor=\"gray\", linewidth=0, ax=None, **kwargs):\n",
558+
" size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs):\n",
561559
"\n",
562560
" if ax is None:\n",
563561
" ax = plt.gca()\n",
@@ -566,7 +564,7 @@
566564
" colors = ['red', 'goldenrod', 'green']\n",
567565
" cm = LinearSegmentedColormap.from_list('ratings', colors, N=50)\n",
568566
" norm = Normalize(vmin=0.5, vmax=3.0)\n",
569-
" \n",
567+
"\n",
570568
" y = range(len(y))[::-1]\n",
571569
" ecs = [cm(norm(v)) for v in x0.values.ravel()]\n",
572570
" ax.scatter(x0, y, c='w', linewidth=2, edgecolors=ecs, s=120, zorder=2, clip_on=False)\n",
@@ -594,29 +592,30 @@
594592
"import matplotlib.patches as mpatches\n",
595593
"from matplotlib.collections import PatchCollection\n",
596594
"\n",
595+
"\n",
597596
"def gradient_patch(xy, width, height, cmap='viridis', colors=None, N=20, zorder=10):\n",
598597
" x0, y0 = xy\n",
599598
" if isinstance(colors, (list, tuple)):\n",
600599
" cmap = LinearSegmentedColormap.from_list('ratings', colors, N=50)\n",
601-
" \n",
600+
"\n",
602601
" patches = []\n",
603602
" levels = np.linspace(0.0, 1.0, N)\n",
604603
" elw = width / N\n",
605604
" for i, l in enumerate(levels):\n",
606-
" rect = mpatches.Rectangle((x0 + i * elw, y0), elw, height, ec=\"none\", fc=cm(l), clip_on=False)\n",
605+
" rect = mpatches.Rectangle((x0 + i * elw, y0), elw, height, ec='none', fc=cm(l), clip_on=False)\n",
607606
" patches.append(rect)\n",
608607
"\n",
609608
" return PatchCollection(patches, match_original=True, zorder=zorder, clip_on=False)\n",
610-
" \n",
611609
"\n",
612-
"class AnyObject(object):\n",
610+
"\n",
611+
"class AnyObject:\n",
613612
" def __init__(self, label):\n",
614613
" self.label = label\n",
615-
" \n",
614+
"\n",
616615
" def get_label(self):\n",
617616
" return self.label\n",
618617
"\n",
619-
"class AnyObjectHandler(object):\n",
618+
"class AnyObjectHandler:\n",
620619
" def legend_artist(self, legend, orig_handle, fontsize, handlebox):\n",
621620
" x0, y0 = handlebox.xdescent, handlebox.ydescent\n",
622621
" width, height = handlebox.width, handlebox.height\n",
@@ -642,7 +641,7 @@
642641
}
643642
],
644643
"source": [
645-
"sns.set_context(\"notebook\", font_scale=2)\n",
644+
"sns.set_context('notebook', font_scale=2)\n",
646645
"\n",
647646
"pgf_with_custom_preamble = {\n",
648647
" 'ytick.major.size': 0,\n",
@@ -663,11 +662,11 @@
663662
" height=25, aspect=.10)\n",
664663
"\n",
665664
"# Draw a dot plot using the stripplot function\n",
666-
"g.map(mystripplot, size=15, orient=\"h\")\n",
665+
"g.map(mystripplot, size=15, orient='h')\n",
667666
"\n",
668667
"# Use semantically meaningful titles for the columns\n",
669-
"titles = [\"Overall\", \"Surf. recon.\", \"T1w ROIs\", \n",
670-
" \"T1w to MNI\", \"BOLD ROIs\", \"BOLD to T1w\", \"SyN SDC\"]\n",
668+
"titles = ['Overall', 'Surf. recon.', 'T1w ROIs',\n",
669+
" 'T1w to MNI', 'BOLD ROIs', 'BOLD to T1w', 'SyN SDC']\n",
671670
"\n",
672671
"# Use the same x axis limits on all columns and add better labels\n",
673672
"g.set(xlim=(-0.2, 3.2), xlabel='', ylabel='')\n",
@@ -676,12 +675,12 @@
676675
"g.axes.flat[0].set(yticks=range(len(datasets))[::-1])\n",
677676
"g.axes.flat[0].set(yticklabels=datasets)\n",
678677
"g.axes.flat[0].tick_params(axis='y', which='major', pad=45)\n",
679-
"for ax, title in zip(g.axes.flat, titles):\n",
678+
"for ax, title in zip(g.axes.flat, titles, strict=False):\n",
680679
" # Set a different title for each axes\n",
681680
" ax.set(title=title)\n",
682681
"# ax.set(xlabel=title)\n",
683682
" ax.set(xticks=[])\n",
684-
" \n",
683+
"\n",
685684
" # Make the grid horizontal instead of vertical\n",
686685
" ax.xaxis.grid(False)\n",
687686
" ax.yaxis.grid(True)\n",

0 commit comments

Comments
 (0)