INCR-24 | Run python-modernize on common/lib/calc
This commit is contained in:
committed by
Chris Pappas
parent
4aa6446533
commit
bfc0c5acf5
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
|
||||
Reference in New Issue
Block a user