Skip to content

Commit

Permalink
start testing io.core.utils
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Nov 1, 2018
1 parent d67b255 commit 7275caf
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[run]
branch = True
source = mpcontribs, mpweb_core
source = mpcontribs, webtzite
[report]
exclude_lines =
# Ignore coverage of code that requires the module to be executed.
Expand Down
7 changes: 1 addition & 6 deletions mpcontribs/io/core/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mpcontribs.config import mp_level01_titles, mp_id_pattern, object_id_pattern
from mpcontribs.io.core.utils import nest_dict
from recdict import RecursiveDict
from utils import disable_ipython_scrollbar, clean_value
from utils import clean_value
from IPython.display import display_html, display, HTML, Image

class HierarchicalData(RecursiveDict):
Expand Down Expand Up @@ -285,7 +285,6 @@ def from_items(cls, rdct, **kwargs):
return super(Table, cls).from_dict(RecursiveDict(rdct), **kwargs)

def _ipython_display_(self):
disable_ipython_scrollbar()
display(HTML(render_dataframe(self)))

class Tables(RecursiveDict):
Expand Down Expand Up @@ -327,7 +326,6 @@ def __str__(self):
return 'mp-ids: {}'.format(' '.join(self.keys()))

def _ipython_display_(self):
disable_ipython_scrollbar()
for identifier, tables in self.iteritems():
if isinstance(tables, dict) and tables:
display_html('<h2>Tabular Data for {}</h2>'.format(identifier), raw=True)
Expand Down Expand Up @@ -413,7 +411,6 @@ def __init__(self, config, table):
self.table = table

def _ipython_display_(self):
disable_ipython_scrollbar()
display(HTML(render_plot(self)))

class Plots(RecursiveDict):
Expand All @@ -429,7 +426,6 @@ def __str__(self):
return 'plots: {}'.format(' '.join(self.keys()))

def _ipython_display_(self):
disable_ipython_scrollbar()
for name, plot in self.iteritems():
if plot:
display_html('<h3>{}</h3>'.format(name), raw=True)
Expand All @@ -450,7 +446,6 @@ def __str__(self):
return 'mp-ids: {}'.format(' '.join(self.keys()))

def _ipython_display_(self):
disable_ipython_scrollbar()
for identifier, plots in self.iteritems():
if identifier != mp_level01_titles[0] and plots:
display_html('<h2>Interactive Plots for {}</h2>'.format(identifier), raw=True)
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions mpcontribs/io/core/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from nose.tools import *
from mpcontribs.io.core.utils import *

def test_get_short_object_id():
cid = '5a8638add4f144413451852a'
short_cid = get_short_object_id(cid)
assert_equal(short_cid, '451852a')

def test_make_pair():
assert_equal(make_pair('Phase', 'Hollandite'), 'Phase: Hollandite')
assert_equal(make_pair('ΔH', '0.066 eV/mol'), 'ΔH: 0.066 eV/mol')

19 changes: 0 additions & 19 deletions mpcontribs/io/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@
from decimal import Decimal
from mpcontribs.config import mp_level01_titles, mp_id_pattern, csv_comment_char

def flatten_dict(dd, separator='.', prefix=''):
"""http://stackoverflow.com/a/19647596"""
return { prefix + separator + k if prefix else k : v
for kk, vv in dd.items()
for k, v in flatten_dict(vv, separator, kk).items()
} if isinstance(dd, dict) else { prefix : dd }

def unflatten_dict(d):
for k in d:
value, keys = d.pop(k), k.split('.')
d.rec_update(nest_dict({keys[-1]: value}, keys[:-1]))

def get_short_object_id(cid):
length = 7
cid_short = str(cid)[-length:]
Expand Down Expand Up @@ -125,13 +113,6 @@ def read_csv(body, is_data_section=True, **kwargs):
**options
).dropna(how='all'))

def disable_ipython_scrollbar():
pass
#from IPython.display import display, Javascript
#display(Javascript("""
# require("notebook/js/outputarea").OutputArea.prototype._should_scroll=function(){return false;};
#"""))

def nested_dict_iter(nested, scope=''):
for key, value in nested.iteritems():
if isinstance(value, collections.Mapping):
Expand Down
2 changes: 1 addition & 1 deletion mpcontribs/users
Submodule users updated 1 files
+31 −29 martin_lab/martin_lab.py
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'unidecode', 'psutil', 'nbformat', 'xlrd', 'django-nopassword', 'mod_wsgi',
'django-require', 'pympler', 'django_cas_ng', 'django-extensions', 'selenium',
'dash', 'dash-html-components', 'dash-core-components', 'dash-table-experiments',
'ase', 'igor', 'xrdtools', 'xrayutilities'
'ase', 'igor', 'xrdtools', 'xrayutilities', 'h5py', 'python-coveralls'
],
license = 'MIT',
keywords = ['materials', 'contribution', 'framework', 'data', 'interactive', 'jupyter'],
Expand Down

0 comments on commit 7275caf

Please sign in to comment.