from __future__ import print_function, division
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline

import numpy as np
import pandas as pd
import textwrap
import os
import sys
import warnings
warnings.filterwarnings('ignore')

# special things
from pivottablejs import pivot_ui
from ipywidgets import FloatSlider, interactive, IntSlider
from scipy import interpolate

# sql
%load_ext sql_magic
import sqlalchemy
import sqlite3
from sqlalchemy import create_engine
sqlite_engine = create_engine('sqlite://')

# autoreload
%load_ext autoreload
%autoreload 1
# %aimport module_to_reload

# ehh...
# import bqplot.pyplot as plt
import ipyvolume as ipv
import altair as alt
from vega_datasets import data

import seaborn as sns
sns.set_context('poster', font_scale=1.3)

a = "hi"
b  = np.array([1, 2, 4, 6])

"""
Explanation: <h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Notebook-Extensions" data-toc-modified-id="Notebook-Extensions-1">Notebook Extensions</a></span><ul class="toc-item"><li><span><a href="#Check-out-nbdime" data-toc-modified-id="Check-out-nbdime-1.1">Check out nbdime</a></span></li><li><span><a href="#ToC(2)" data-toc-modified-id="ToC(2)-1.2">ToC(2)</a></span></li><li><span><a href="#ExecuteTime" data-toc-modified-id="ExecuteTime-1.3">ExecuteTime</a></span></li><li><span><a href="#Snippets-Menu" data-toc-modified-id="Snippets-Menu-1.4">Snippets Menu</a></span></li><li><span><a href="#Python-Markdown----Maybe-doesn't-work-right-now-for-some-reason?" data-toc-modified-id="Python-Markdown----Maybe-doesn't-work-right-now-for-some-reason?-1.5">Python Markdown -- Maybe doesn't work right now for some reason?</a></span></li><li><span><a href="#Code-prettify" data-toc-modified-id="Code-prettify-1.6">Code prettify</a></span></li><li><span><a href="#Collapsible-Headings" data-toc-modified-id="Collapsible-Headings-1.7">Collapsible Headings</a></span></li><li><span><a href="#Notify----disappointing-:(" data-toc-modified-id="Notify----disappointing-:(-1.8">Notify -- disappointing :(</a></span></li></ul></li><li><span><a href="#Outside-Notebooks" data-toc-modified-id="Outside-Notebooks-2">Outside Notebooks</a></span><ul class="toc-item"><li><span><a href="#Tree-Filter" data-toc-modified-id="Tree-Filter-2.1">Tree Filter</a></span></li></ul></li></ul></div>
End of explanation
"""


print("hello world")

"""
Explanation: Notebook Extensions
Check out nbdime
https://github.com/jupyter/nbdime
and the documentation about adding the nbdime  https://nbdime.readthedocs.io/en/latest/extensions.html 
ToC(2)
ExecuteTime
End of explanation
"""


a = 4
report = "FAIL"

"""
Explanation: Snippets Menu
End of explanation
"""


weight_categories = [    "vlow_weight",    "low_weight",
    "mid_weight",    "high_weight",
    "vhigh_weight",]

players['weightclass'] = pd.qcut(players['weight'],
     len(weight_categories), weight_categories)


weight_categories = [
    "vlow_weight",
    "low_weight",
    "mid_weight",
    "high_weight",
    "vhigh_weight",
]

players["weightclass"] = pd.qcut(
    players["weight"], len(weight_categories), weight_categories
)

"""
Explanation: Python Markdown -- Maybe doesn't work right now for some reason?
The value of a is {{a}}. Useful for anything you want to report, this: {{report}}.
Code prettify
Copy/paste the following into the "json defining library calls required to load the kernel-specific prettifying modules, and the prefix & postfix for the json-format string required to make the prettifying call." box.
{
  "python": {
    "library": "import json\ndef black_reformat(cell_text):\n    import black\n    import re\n    cell_text = re.sub('^%', '#%#', cell_text, flags=re.M)\n    try:\n        reformated_text = black.format_str(cell_text, 88)\n    except TypeError:\n        reformated_text = black.format_str(cell_text, mode=black.FileMode(line_length=88))\n    return re.sub('^#%#', '%', reformated_text, flags=re.M)",
    "prefix": "print(json.dumps(black_reformat(u",
    "postfix": ")))"
  },
  "r": {
    "library": "library(formatR)\nlibrary(jsonlite)",
    "prefix": "cat(toJSON(paste(tidy_source(text=",
    "postfix": ", output=FALSE)[['text.tidy']], collapse='\n')))"
  },
  "javascript": {
    "library": "jsbeautify = require('js-beautify')",
    "prefix": "console.log(JSON.stringify(jsbeautify.js_beautify(",
    "postfix": ")));"
  }
}
From: https://neuralcoder.science/Black-Jupyter/
End of explanation
"""


import time
time.sleep(10)

"""
Explanation: Collapsible Headings
Notify -- disappointing :(
In theory, this will give you a browser notification if your kernel has been busy for at least N seconds (after you give permission).
End of explanation
"""


