Skip to content
Snippets Groups Projects
Commit bfc0c5ac authored by Christopher Pappas's avatar Christopher Pappas Committed by Chris Pappas
Browse files

INCR-24 | Run python-modernize on common/lib/calc

parent 4aa64465
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,5 @@ Ideally, we wouldn't need to pull in all the calc symbols here,
but courses were using 'import calc', so we need this for
backwards compatibility
"""
from calc import *
from __future__ import absolute_import
from .calc import *
......@@ -4,6 +4,7 @@ Parser and evaluator for FormulaResponse and NumericalResponse
Uses pyparsing to parse. Main function as of now is evaluator().
"""
from __future__ import absolute_import
import math
import numbers
import operator
......@@ -27,7 +28,9 @@ from pyparsing import (
stringEnd
)
import functions
from . import functions
import six
from functools import reduce
# Functions available by default
# We use scimath variants which give complex results when needed. For example:
......@@ -103,7 +106,7 @@ def lower_dict(input_dict):
variables that have the same lowercase representation. It would be hard to
tell which is used in the final dict and which isn't.
"""
return {k.lower(): v for k, v in input_dict.iteritems()}
return {k.lower(): v for k, v in six.iteritems(input_dict)}
# The following few functions define evaluation actions, which are run on lists
......
......@@ -4,6 +4,7 @@ Provide the mathematical functions that numpy doesn't.
Specifically, the secant/cosecant/cotangents and their inverses and
hyperbolic counterparts
"""
from __future__ import absolute_import
import numpy
......
......@@ -8,7 +8,9 @@ Because intermediate values of the render contain more data than simply the
string of latex, store it in a custom class `LatexRendered`.
"""
from calc import DEFAULT_FUNCTIONS, DEFAULT_VARIABLES, SUFFIXES, ParseAugmenter
from __future__ import absolute_import
from .calc import DEFAULT_FUNCTIONS, DEFAULT_VARIABLES, SUFFIXES, ParseAugmenter
from functools import reduce
class LatexRendered(object):
......
......@@ -2,10 +2,12 @@
Unit tests for calc.py
"""
from __future__ import absolute_import
import unittest
import numpy
import calc
from pyparsing import ParseException
from six.moves import zip
# numpy's default behavior when it evaluates a function outside its domain
# is to raise a warning (not an exception) which is then printed to STDOUT.
......
......@@ -3,6 +3,7 @@
Unit tests for preview.py
"""
from __future__ import absolute_import
import unittest
from calc import preview
import pyparsing
......
from __future__ import absolute_import
from setuptools import setup
setup(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment