Skip to content

Commit

Permalink
More deprecation removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Jun 13, 2016
1 parent a49a125 commit d072329
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 113 deletions.
36 changes: 0 additions & 36 deletions pymatgen/serializers/json_coders.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import json
import functools

from monty.serialization import loadfn, dumpfn
from monty.dev import deprecated


def pmg_serialize(method):
"""
Expand All @@ -48,36 +45,3 @@ def json_pretty_dump(obj, filename):
with open(filename, "w") as fh:
json.dump(obj, fh, indent=4, sort_keys=4)


@deprecated(loadfn, "Will be removed in pmg 4.0.")
def pmg_load(filename, **kwargs):
"""
Loads a json file and deserialize it with MontyDecoder.
Args:
filename (str): Filename of file to open. Can be gzipped or bzipped.
\*\*kwargs: Any of the keyword arguments supported by the json.load
method.
Returns:
Deserialized pymatgen object. Note that these objects can be lists,
dicts or otherwise nested pymatgen objects that support the as_dict()
and from_dict MSONable protocol.
"""
return loadfn(filename, **kwargs)


@deprecated(dumpfn, "Will be removed in pmg 4.0.")
def pmg_dump(obj, filename, **kwargs):
"""
Dump an object to a json file using MontyEncoder. Note that these
objects can be lists, dicts or otherwise nested pymatgen objects that
support the as_dict() and from_dict MSONable protocol.
Args:
obj (object): Object to dump.
filename (str): Filename of file to open. Can be gzipped or bzipped.
\*\*kwargs: Any of the keyword arguments supported by the json.dump
method.
"""
return dumpfn(obj, filename, **kwargs)
77 changes: 0 additions & 77 deletions pymatgen/util/string_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
import re


from six.moves import zip

from tabulate import tabulate

from monty.dev import deprecated


__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2011, The Materials Project"
__version__ = "1.0"
Expand All @@ -24,38 +17,6 @@
__date__ = "$Sep 23, 2011M$"


@deprecated(tabulate, "In-house method has been deprecated in favor of using "
"the tabulate package. Please switch all usages. Will "
"be removed in pymagen v4.0.")
def generate_latex_table(results, header=None, caption=None, label=None):
"""
Generates a string latex table from a sequence of sequence.
Args:
result: 2d sequence of arbitrary types.
header: optional header
Returns:
String representation of Latex table with data.
"""
body = []
if header is not None:
body.append(" & ".join(header) + "\\\\")
body.append("\\hline")
maxlength = 0
for result in results:
maxlength = max(maxlength, len(result))
body.append(" & ".join([str(m) for m in result]) + "\\\\")
colstr = "c" * maxlength
output = ["\\begin{table}[H]",
"\\caption{{{}}}".format(caption if caption else
"Caption"), "\\label{{{}}}".format(label if label else "Label"),
"\\begin{tabular*}{\\textwidth}{@{\\extracolsep{\\fill}}" +
colstr + "}", "\\hline", "\n".join(body), "\\hline",
"\\end{tabular*}", "\\end{table}"]
return "\n".join(output)


def str_delimited(results, header=None, delimiter="\t"):
"""
Given a tuple of tuples, generate a delimited string form.
Expand All @@ -79,44 +40,6 @@ def str_delimited(results, header=None, delimiter="\t"):
for result in results])


@deprecated(tabulate, "In-house method has been deprecated in favor of using "
"the tabulate package. Please switch all usages. Will "
"be removed in pymagen v4.0.")
def str_aligned(results, header=None):
"""
Given a tuple, generate a nicely aligned string form.
>>> results = [["a","b","cz"],["d","ez","f"],[1,2,3]]
>>> print(str_aligned(results))
a b cz
d ez f
1 2 3
Args:
result: 2d sequence of arbitrary types.
header: optional header
Returns:
Aligned string output in a table-like format.
"""
k = list(zip(*results))
stringlengths = list()
count = 0
for i in k:
col_max_len = max([len(str(m)) for m in i])
if header is not None:
col_max_len = max([len(str(header[count])), col_max_len])
stringlengths.append(col_max_len)
count += 1
format_string = " ".join(["%" + str(d) + "s" for d in stringlengths])
returnstr = ""
if header is not None:
header_str = format_string % tuple(header)
returnstr += header_str + "\n"
returnstr += "-" * len(header_str) + "\n"
return returnstr + "\n".join([format_string % tuple(result)
for result in results])


def formula_double_format(afloat, ignore_ones=True, tol=1e-8):
"""
This function is used to make pretty formulas by formatting the amounts.
Expand Down

0 comments on commit d072329

Please sign in to comment.