-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Hotfix/calc refactor #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hotfix/calc refactor #832
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 * | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| import numbers | ||
| import numpy | ||
| import scipy.constants | ||
| import calcfunctions | ||
| import functions | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to prefer full imports:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Or: 'import calc.functions' -> 'from calc import *' -> 'import calc.functions'
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
|
@@ -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, | ||
|
|
@@ -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), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| """ | ||
|
|
||
| import unittest | ||
| import preview | ||
| from calc import preview | ||
| import pyparsing | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,8 @@ | |
|
|
||
| setup( | ||
| name="calc", | ||
| version="0.1.1", | ||
| py_modules=["calc"], | ||
| version="0.2", | ||
| packages=["calc"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| install_requires=[ | ||
| "pyparsing==1.5.6", | ||
| "numpy", | ||
|
|
||
There was a problem hiding this comment.
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.pytocalc/__init__.py. I think @nedbat would disagree, though.There was a problem hiding this comment.
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."