Skip to content
Closed
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
6 changes: 6 additions & 0 deletions common/lib/calc/calc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
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 *

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it were me, I would have just moved calc.py to calc/__init__.py. I think @nedbat would disagree, though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was my suggestion. As a compromise, I'd add a comment here explaining why: "Ideally, we wouldn't need to pull all the calc symbols up here, but courses were using 'import calc', so this is here to keep them working."

26 changes: 13 additions & 13 deletions common/lib/calc/calc.py → common/lib/calc/calc/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numbers
import numpy
import scipy.constants
import calcfunctions
import functions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to prefer full imports: import calc.functions, just for clarity

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this seems to add some sort of circular import error. If I am a course author, and I run
'import' calc, it invokes 'from calc import *' which calls import 'calc.functions'.

Or: 'import calc.functions' -> 'from calc import *' -> 'import calc.functions'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Hrm. Ok, let's just leave it like this for now, then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll rebase, and then good to go?


from pyparsing import (
Word, Literal, CaselessLiteral, ZeroOrMore, MatchFirst, Optional, Forward,
Expand All @@ -20,9 +20,9 @@
'sin': numpy.sin,
'cos': numpy.cos,
'tan': numpy.tan,
'sec': calcfunctions.sec,
'csc': calcfunctions.csc,
'cot': calcfunctions.cot,
'sec': functions.sec,
'csc': functions.csc,
'cot': functions.cot,
'sqrt': numpy.sqrt,
'log10': numpy.log10,
'log2': numpy.log2,
Expand All @@ -31,24 +31,24 @@
'arccos': numpy.arccos,
'arcsin': numpy.arcsin,
'arctan': numpy.arctan,
'arcsec': calcfunctions.arcsec,
'arccsc': calcfunctions.arccsc,
'arccot': calcfunctions.arccot,
'arcsec': functions.arcsec,
'arccsc': functions.arccsc,
'arccot': functions.arccot,
'abs': numpy.abs,
'fact': math.factorial,
'factorial': math.factorial,
'sinh': numpy.sinh,
'cosh': numpy.cosh,
'tanh': numpy.tanh,
'sech': calcfunctions.sech,
'csch': calcfunctions.csch,
'coth': calcfunctions.coth,
'sech': functions.sech,
'csch': functions.csch,
'coth': functions.coth,
'arcsinh': numpy.arcsinh,
'arccosh': numpy.arccosh,
'arctanh': numpy.arctanh,
'arcsech': calcfunctions.arcsech,
'arccsch': calcfunctions.arccsch,
'arccoth': calcfunctions.arccoth
'arcsech': functions.arcsech,
'arccsch': functions.arccsch,
'arccoth': functions.arccoth
}
DEFAULT_VARIABLES = {
'i': numpy.complex(0, 1),
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

import unittest
import preview
from calc import preview
import pyparsing


Expand Down
4 changes: 2 additions & 2 deletions common/lib/calc/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

setup(
name="calc",
version="0.1.1",
py_modules=["calc"],
version="0.2",
packages=["calc"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably, this is a backwards incompatible change, and so should probably bump to at least 0.2

install_requires=[
"pyparsing==1.5.6",
"numpy",
Expand Down
2 changes: 1 addition & 1 deletion common/lib/capa/capa/inputtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

from .registry import TagRegistry
from chem import chemcalc
from preview import latex_preview
from calc.preview import latex_preview
import xqueue_interface
from datetime import datetime

Expand Down