Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove numpy dependency #97

Merged
merged 6 commits into from Jan 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions jupyterthemes/stylefx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os, sys
from jupyter_core.paths import jupyter_config_dir, jupyter_data_dir
from shutil import copyfile, rmtree
from numpy import unique
import lesscpy

# path to local site-packages/jupyterthemes
Expand Down Expand Up @@ -97,7 +96,7 @@ def delete_font_files():
abspath = os.path.join(jupyter_custom_fonts, fontfile)
os.remove(abspath)

def import_stored_fonts(fontcodes=['exosans', 'loraserif', 'droidmono']):
def import_stored_fonts(fontcodes=('exosans', 'loraserif', 'droidmono')):
""" collect fontnames and local pointers to fontfiles in custom dir
then pass information for each font to function for writing import statements
"""
Expand All @@ -106,7 +105,7 @@ def import_stored_fonts(fontcodes=['exosans', 'loraserif', 'droidmono']):
style_less = '\n'.join(['/*', s, s, doc, s, s, '*/'])
style_less += '\n\n\n'
style_less += '/* Import Notebook, Markdown, & Code Fonts */\n'
for fontcode in unique(fontcodes):
for fontcode in set(fontcodes):
fname, fpath, ffam = stored_font_dicts(fontcode)
style_less = import_fonts(style_less, fname, fpath)
style_less += '\n\n'
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
jupyter
jupyter_core
numpy
lesscpy>=0.12.0
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from glob import glob
from setuptools import setup
import numpy as np
from itertools import chain

major = 0
minor = 14
Expand All @@ -28,7 +28,10 @@
# recursively point to all included font directories
fontfams = ['monospace', 'sans-serif', 'serif']
fsubdirs = [os.path.join(pkgname, 'fonts', subdir) for subdir in fontfams]
fontsdata = np.hstack([['/'.join(f.split('/')[1:]) for f in glob(os.path.join(fsub, '*', '*'))] for fsub in fsubdirs]).tolist()
fontsdata = chain.from_iterable([['/'.join(f.split('/')[1:])
for f in glob(os.path.join(fsub, '*', '*'))]
for fsub in fsubdirs])

datafiles[pkgname].extend(fontsdata)

setup(
Expand Down Expand Up @@ -56,7 +59,7 @@
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
install_requires=['jupyter', 'jupyter_core', 'numpy', 'lesscpy>=0.12.0'],
install_requires=['jupyter', 'jupyter_core', 'lesscpy>=0.12.0'],
keywords=['jupyter', 'ipython', 'notebook', 'themes', 'css'],
entry_points={
'console_scripts': [
Expand Down
19 changes: 6 additions & 13 deletions tests/test_themes.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
from jupyterthemes import install_theme, get_themes
from jupyterthemes import stylefx

import numpy as np

def install_themes():
themes = get_themes()
pass_list = []
for t in themes:
try:
install_theme(theme=t, monofont=mf, nbfont=nf, tcfont=tc)
pass_list.append(True)
except Exception:
pass_list.append(False)
return np.all(pass_list)
return False
return True

def install_fonts():
fonts = stylefx.stored_font_dicts('', get_all=True)
fontvals = [list(fonts[ff]) for ff in ['mono', 'sans', 'serif']]
monotest, sanstest, seriftest = [np.array(fv)[:4] for fv in fontvals]
pass_list = []
monotest, sanstest, seriftest = [fv[:4] for fv in fontvals]
for i in range(4):
mono, sans, serif = monotest[i], sanstest[i], seriftest[i]
try:
install_theme(theme=t, monofont=mono, nbfont=sans, tcfont=serif)
pass_list.append(True)
except Exception:
pass_list.append(False)
return False
try:
install_theme(theme=t, monofont=mono, nbfont=serif, tcfont=sans)
pass_list.append(True)
except Exception:
pass_list.append(False)
return np.all(pass_list)
return False
return True

install_themes()
install_fonts()