Skip to content
Open
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
2 changes: 0 additions & 2 deletions calmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"""


from __future__ import unicode_literals

import calendar
import datetime

Expand Down
12 changes: 5 additions & 7 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# Calmap documentation build configuration file, created by
# sphinx-quickstart on Thu Nov 26 16:51:51 2015.
#
Expand Down Expand Up @@ -59,8 +57,8 @@
master_doc = "index"

# General information about the project.
project = u"Calmap"
copyright = u"2015, %s" % calmap.__author__
project = "Calmap"
copyright = "2015, %s" % calmap.__author__
author = calmap.__author__

# The version info for the project you're documenting, acts as replacement for
Expand Down Expand Up @@ -236,7 +234,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "Calmap.tex", u"Calmap Documentation", u"Martijn Vermaat", "manual")
(master_doc, "Calmap.tex", "Calmap Documentation", "Martijn Vermaat", "manual")
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -264,7 +262,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "calmap", u"Calmap Documentation", [author], 1)]
man_pages = [(master_doc, "calmap", "Calmap Documentation", [author], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -279,7 +277,7 @@
(
master_doc,
"Calmap",
u"Calmap Documentation",
"Calmap Documentation",
author,
"Calmap",
"One line description of project.",
Expand Down
53 changes: 20 additions & 33 deletions doc/sphinxext/plot_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@
plot_template
Provide a customized template for preparing restructured text.
"""
from __future__ import absolute_import, division, print_function, unicode_literals

import six
from six.moves import xrange

import sys
import os
Expand All @@ -145,9 +141,6 @@
import traceback
import warnings

if not six.PY3:
import cStringIO

from docutils.parsers.rst import directives
from docutils.parsers.rst.directives.images import Image

Expand Down Expand Up @@ -247,7 +240,7 @@ def mark_plot_labels(app, document):
the "htmlonly" (or "latexonly") node to the actual figure node
itself.
"""
for name, explicit in six.iteritems(document.nametypes):
for name, explicit in document.nametypes.items():
if not explicit:
continue
labelid = document.nameids[name]
Expand Down Expand Up @@ -306,7 +299,7 @@ def setup(app):
app.add_config_value("plot_working_directory", None, True)
app.add_config_value("plot_template", None, True)

app.connect(str("doctree-read"), mark_plot_labels)
app.connect("doctree-read", mark_plot_labels)


# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -375,7 +368,7 @@ def remove_coding(text):
"""
Remove the coding comment, which six.exec_ doesn't like.
"""
sub_re = re.compile("^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE)
sub_re = re.compile(r"^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE)
return sub_re.sub("", text)


Expand Down Expand Up @@ -457,14 +450,14 @@ def remove_coding(text):
plot_context = dict()


class ImageFile(object):
class ImageFile:
def __init__(self, basename, dirname):
self.basename = basename
self.dirname = dirname
self.formats = []

def filename(self, format):
return os.path.join(self.dirname, "%s.%s" % (self.basename, format))
return os.path.join(self.dirname, "{}.{}".format(self.basename, format))

def filenames(self):
return [self.filename(fmt) for fmt in self.formats]
Expand Down Expand Up @@ -494,10 +487,7 @@ def run_code(code, code_path, ns=None, function_name=None):
# Change the working directory to the directory of the example, so
# it can get at its data files, if any. Add its path to sys.path
# so it can import any helper modules sitting beside it.
if six.PY2:
pwd = os.getcwdu()
else:
pwd = os.getcwd()
pwd = os.getcwd()
old_sys_path = list(sys.path)
if setup.config.plot_working_directory is not None:
try:
Expand Down Expand Up @@ -526,10 +516,7 @@ def run_code(code, code_path, ns=None, function_name=None):

# Redirect stdout
stdout = sys.stdout
if six.PY3:
sys.stdout = io.StringIO()
else:
sys.stdout = cStringIO.StringIO()
sys.stdout = io.StringIO()

# Assign a do-nothing print function to the namespace. There
# doesn't seem to be any other way to provide a way to (not) print
Expand All @@ -544,22 +531,22 @@ def _dummy_print(*arg, **kwarg):
ns = {}
if not ns:
if setup.config.plot_pre_code is None:
six.exec_(
six.text_type(
exec(
str(
"import numpy as np\n"
+ "from matplotlib import pyplot as plt\n"
),
ns,
)
else:
six.exec_(six.text_type(setup.config.plot_pre_code), ns)
exec(str(setup.config.plot_pre_code), ns)
ns["print"] = _dummy_print
if "__main__" in code:
six.exec_("__name__ = '__main__'", ns)
exec("__name__ = '__main__'", ns)
code = remove_coding(code)
six.exec_(code, ns)
exec(code, ns)
if function_name is not None:
six.exec_(function_name + "()", ns)
exec(function_name + "()", ns)
except (Exception, SystemExit) as err:
raise PlotError(traceback.format_exc())
finally:
Expand Down Expand Up @@ -599,13 +586,13 @@ def render_figures(
default_dpi = {"png": 80, "hires.png": 200, "pdf": 200}
formats = []
plot_formats = config.plot_formats
if isinstance(plot_formats, six.string_types):
if isinstance(plot_formats, str):
# String Sphinx < 1.3, Split on , to mimic
# Sphinx 1.3 and later. Sphinx 1.3 always
# returns a list.
plot_formats = plot_formats.split(",")
for fmt in plot_formats:
if isinstance(fmt, six.string_types):
if isinstance(fmt, str):
if ":" in fmt:
suffix, dpi = fmt.split(":")
formats.append((str(suffix), int(dpi)))
Expand Down Expand Up @@ -637,7 +624,7 @@ def render_figures(
all_exists = True
for i, code_piece in enumerate(code_pieces):
images = []
for j in xrange(1000):
for j in range(1000):
if len(code_pieces) > 1:
img = ImageFile("%s_%02d_%02d" % (output_base, i, j), output_dir)
else:
Expand Down Expand Up @@ -746,7 +733,7 @@ def run(arguments, content, options, state_machine, state, lineno):
else:
function_name = None

with io.open(source_file_name, "r", encoding="utf-8") as fd:
with open(source_file_name, encoding="utf-8") as fd:
code = fd.read()
output_base = os.path.basename(source_file_name)
else:
Expand Down Expand Up @@ -857,8 +844,8 @@ def run(arguments, content, options, state_machine, state, lineno):
images = []

opts = [
":%s: %s" % (key, val)
for key, val in six.iteritems(options)
":{}: {}".format(key, val)
for key, val in options.items()
if key in ("alt", "height", "width", "scale", "align", "class")
]

Expand Down Expand Up @@ -908,7 +895,7 @@ def run(arguments, content, options, state_machine, state, lineno):

# copy script (if necessary)
target_name = os.path.join(dest_dir, output_base + source_ext)
with io.open(target_name, "w", encoding="utf-8") as f:
with open(target_name, "w", encoding="utf-8") as f:
if source_file_name == rst_file:
code_escaped = unescape_doctest(code)
else:
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
from setuptools import setup

install_requires = ["matplotlib", "numpy", "pandas"]

try:
with open("README.md") as readme:
long_description = readme.read()
except IOError:
except OSError:
long_description = "See https://pypi.python.org/pypi/calmap"

# This is quite the hack, but we don't want to import our package from here
Expand Down Expand Up @@ -36,17 +34,19 @@
license="MIT License",
platforms=["any"],
packages=["calmap"],
install_requires=install_requires,
install_requires=["matplotlib", "numpy", "pandas"],
python_requires=">=3.8",
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
],
)
1 change: 0 additions & 1 deletion tests/test_calmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""


from __future__ import unicode_literals

import numpy as np

Expand Down