Skip to content

Commit

Permalink
Merge branch 'master' into pydy
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Jul 23, 2016
2 parents 3520fab + 92f71c9 commit 8787d84
Show file tree
Hide file tree
Showing 87 changed files with 3,660 additions and 547 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,4 @@ Nitin Chaudhary <[email protected]> Nitin <[email protected]>
Alex Argunov <[email protected]> alex argunov <[email protected]>
Abhishek Garg <[email protected]> abhishek garg <[email protected]>
Gaurav Dhingra <[email protected]> Gaurav Dhingra <[email protected]>
Krit Karan <[email protected]> Krit Karan <[email protected]>
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: python
sudo: false
env:
matrix:
- TEST_DOCTESTS="true" FASTCACHE="false"
- TEST_DOCTESTS="true" FASTCACHE="false" TEST_SETUP="true"
- SPLIT="1/4" TEST_SYMPY="true"
- SPLIT="2/4" TEST_SYMPY="true"
- SPLIT="3/4" TEST_SYMPY="true"
Expand Down Expand Up @@ -140,6 +140,7 @@ matrix:
env:
- TEST_DOCTESTS="true"
- FASTCACHE="false"
- TEST_SETUP="true"
addons:
apt:
sources:
Expand Down Expand Up @@ -220,6 +221,7 @@ matrix:
env:
- TEST_DOCTESTS="true"
- FASTCACHE="false"
- TEST_SETUP="true"
addons:
apt:
sources:
Expand Down
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,5 @@ Nathan Musoke <[email protected]>
Abhishek Garg <[email protected]>
Dana Jacobsen <[email protected]>
Vasiliy Dommes <[email protected]>
Krit Karan <[email protected]>
Rahul Dandwate <[email protected]>
71 changes: 71 additions & 0 deletions bin/generate_module_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""
Execute like this:
$ python bin/generate_module_list.py
modules = [
'sympy.assumptions',
'sympy.assumptions.handlers',
'sympy.benchmarks',
'sympy.calculus',
'sympy.categories',
'sympy.codegen',
'sympy.combinatorics',
'sympy.concrete',
'sympy.core',
'sympy.core.benchmarks',
'sympy.crypto',
'sympy.deprecated',
'sympy.diffgeom',
'sympy.external',
'sympy.functions',
'sympy.functions.combinatorial',
'sympy.functions.elementary',
'sympy.functions.elementary.benchmarks',
...
]
"""

from __future__ import print_function

from glob import glob


def get_paths(level=15):
"""
Generates a set of paths for modules searching.
Examples
========
>>> get_paths(2)
['sympy/__init__.py', 'sympy/*/__init__.py', 'sympy/*/*/__init__.py']
>>> get_paths(6)
['sympy/__init__.py', 'sympy/*/__init__.py', 'sympy/*/*/__init__.py',
'sympy/*/*/*/__init__.py', 'sympy/*/*/*/*/__init__.py',
'sympy/*/*/*/*/*/__init__.py', 'sympy/*/*/*/*/*/*/__init__.py']
"""
wildcards = ["/"]
for i in range(level):
wildcards.append(wildcards[-1] + "*/")
p = ["sympy" + x + "__init__.py" for x in wildcards]
return p

def generate_module_list():
g = []
for x in get_paths():
g.extend(glob(x))
g = [".".join(x.split("/")[:-1]) for x in g]
g = [i for i in g if not i.endswith('.tests')]
g.remove('sympy')
g = list(set(g))
g.sort()
return g

if __name__ == '__main__':
g = generate_module_list()
print("modules = [")
for x in g:
print(" '%s'," % x)
print("]")
25 changes: 15 additions & 10 deletions bin/generate_test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ def get_paths(level=15):
p = ["sympy" + x + "test_*.py" for x in wildcards]
return p

g = []
for x in get_paths():
g.extend(glob(x))
g = [".".join(x.split("/")[:-1]) for x in g]
g = list(set(g))
g.sort()
print("tests = [")
for x in g:
print(" '%s'," % x)
print(" ]")
def generate_test_list():
g = []
for x in get_paths():
g.extend(glob(x))
g = [".".join(x.split("/")[:-1]) for x in g]
g = list(set(g))
g.sort()
return g

if __name__ == '__main__':
g = generate_test_list()
print("tests = [")
for x in g:
print(" '%s'," % x)
print("]")
28 changes: 28 additions & 0 deletions bin/test_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Test that the installed modules in setup.py are up-to-date.
If this test fails, run
python bin/generate_test_list.py
and
python bin/generate_module_list.py
to generate the up-to-date test and modules list to put in setup.py.
"""
import generate_test_list
import generate_module_list

from get_sympy import path_hack
path_hack()

import setup

module_list = generate_module_list.generate_module_list()
test_list = generate_test_list.generate_test_list()

assert setup.modules == module_list, set(setup.modules).symmetric_difference(set(module_list))
assert setup.tests == test_list, set(setup.tests).symmetric_difference(set(test_list))
print("setup.py modules and tests are OK")
4 changes: 4 additions & 0 deletions bin/test_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ set -e
# Echo each command
set -x

if [[ "${TEST_SETUP}" == "true" ]]; then
python bin/test_setup.py
fi

if [[ "${TEST_SPHINX}" == "true" ]]; then
echo "Testing SPHINX"
cd doc
Expand Down
7 changes: 7 additions & 0 deletions doc/src/modules/functions/special.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ Heaviside
.. autoclass:: sympy.functions.special.delta_functions.Heaviside
:members:

Singularity Function
--------------------
.. module:: sympy.functions.special.singularity_functions

.. autoclass:: sympy.functions.special.singularity_functions.SingularityFunction
:members:

Gamma, Beta and related Functions
---------------------------------
.. module:: sympy.functions.special.gamma_functions
Expand Down
4 changes: 4 additions & 0 deletions doc/src/modules/ntheory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ Ntheory Functions Reference

.. autofunction:: digits

.. autofunction:: primenu

.. autofunction:: primeomega

.. module:: sympy.ntheory.modular

.. autofunction:: symmetric_residue
Expand Down
83 changes: 42 additions & 41 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
sys.exit(-1)

# Check that this list is uptodate against the result of the command:
# for i in `find sympy -name __init__.py | rev | cut -f 2- -d '/' | rev | egrep -v "^sympy$" | egrep -v "tests$" `; do echo "'${i//\//.}',"; done | sort
# python bin/generate_module_list.py
modules = [
'sympy.assumptions',
'sympy.assumptions.handlers',
Expand Down Expand Up @@ -254,7 +254,7 @@ def run(self):
benchmarking.main(['sympy'])

# Check that this list is uptodate against the result of the command:
# $ python bin/generate_test_list.py
# python bin/generate_test_list.py
tests = [
'sympy.assumptions.tests',
'sympy.calculus.tests',
Expand Down Expand Up @@ -322,42 +322,43 @@ def run(self):
with open(os.path.join(dir_setup, 'sympy', '__init__.py')) as f:
long_description = f.read().split('"""')[1]

setup(name='sympy',
version=__version__,
description='Computer algebra system (CAS) in Python',
long_description=long_description,
author='SymPy development team',
author_email='[email protected]',
license='BSD',
keywords="Math CAS",
url='http://sympy.org',
packages=['sympy'] + modules + tests,
scripts=['bin/isympy'],
ext_modules=[],
package_data={
'sympy.utilities.mathml': ['data/*.xsl'],
'sympy.logic.benchmarks': ['input/*.cnf'],
},
data_files=[('share/man/man1', ['doc/man/isympy.1'])],
cmdclass={'test': test_sympy,
'bench': run_benchmarks,
'clean': clean,
'audit': audit},
classifiers=[
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Physics',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
install_requires=['mpmath>=%s' % mpmath_version]
)
if __name__ == '__main__':
setup(name='sympy',
version=__version__,
description='Computer algebra system (CAS) in Python',
long_description=long_description,
author='SymPy development team',
author_email='[email protected]',
license='BSD',
keywords="Math CAS",
url='http://sympy.org',
packages=['sympy'] + modules + tests,
scripts=['bin/isympy'],
ext_modules=[],
package_data={
'sympy.utilities.mathml': ['data/*.xsl'],
'sympy.logic.benchmarks': ['input/*.cnf'],
},
data_files=[('share/man/man1', ['doc/man/isympy.1'])],
cmdclass={'test': test_sympy,
'bench': run_benchmarks,
'clean': clean,
'audit': audit},
classifiers=[
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Physics',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
install_requires=['mpmath>=%s' % mpmath_version]
)
9 changes: 9 additions & 0 deletions sympy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@

from sympy.release import __version__

if 'dev' in __version__:
def enable_warnings():
import warnings
warnings.filterwarnings('default', '.*', DeprecationWarning, module='sympy.*')
del warnings
enable_warnings()
del enable_warnings


import sys
if sys.version_info[0] == 2 and sys.version_info[1] < 6:
raise ImportError("Python Version 2.6 or above is required for SymPy.")
Expand Down
2 changes: 1 addition & 1 deletion sympy/calculus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
is_strictly_increasing, is_decreasing,
is_strictly_decreasing, is_monotonic)
from .finite_diff import finite_diff_weights, apply_finite_diff, as_finite_diff
from .util import not_empty_in, AccumBounds
from .util import periodicity, not_empty_in, AccumBounds
58 changes: 55 additions & 3 deletions sympy/calculus/tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sympy import (Symbol, S, exp, log, sqrt, oo, E, zoo, tan,
sin, pi)
from sympy import (Symbol, S, exp, log, sqrt, oo, E, zoo, pi, tan, sin, cos,
cot, sec, csc)
from sympy.calculus.util import (function_range, continuous_domain, not_empty_in,
AccumBounds)
periodicity, lcim, AccumBounds)
from sympy.core import Add, Mul, Pow
from sympy.sets.sets import Interval, FiniteSet, Complement, Union
from sympy.utilities.pytest import raises
Expand Down Expand Up @@ -63,6 +63,58 @@ def test_not_empty_in():
Union(Interval(-2, -1, True, False), Interval(2, oo))


def test_periodicity():
x = Symbol('x')
y = Symbol('y')

assert periodicity(sin(2*x), x) == pi
assert periodicity((-2)*tan(4*x), x) == pi/4
assert periodicity(sin(x)**2, x) == 2*pi
assert periodicity(3**tan(3*x), x) == pi/3
assert periodicity(tan(x)*cos(x), x) == 2*pi
assert periodicity(sin(x)**(tan(x)), x) == 2*pi
assert periodicity(tan(x)*sec(x), x) == 2*pi
assert periodicity(sin(2*x)*cos(2*x) - y, x) == pi/2
assert periodicity(tan(x) + cot(x), x) == pi
assert periodicity(sin(x) - cos(2*x), x) == 2*pi
assert periodicity(sin(x) - 1, x) == 2*pi
assert periodicity(sin(4*x) + sin(x)*cos(x), x) == pi
assert periodicity(exp(sin(x)), x) == 2*pi
assert periodicity(log(cot(2*x)) - sin(cos(2*x)), x) == pi
assert periodicity(sin(2*x)*exp(tan(x) - csc(2*x)), x) == pi
assert periodicity(cos(sec(x) - csc(2*x)), x) == 2*pi
assert periodicity(tan(sin(2*x)), x) == pi
assert periodicity(2*tan(x)**2, x) == pi

assert periodicity(sin(x)**2 + cos(x)**2, x) == S.Zero
assert periodicity(tan(x), y) == S.Zero

assert periodicity(exp(x), x) is None
assert periodicity(log(x), x) is None
assert periodicity(exp(x)**sin(x), x) is None
assert periodicity(sin(x)**y, y) is None


def test_periodicity_check():
x = Symbol('x')
y = Symbol('y')

assert periodicity(tan(x), x, check=True) == pi
assert periodicity(sin(x) + cos(x), x, check=True) == 2*pi
raises(NotImplementedError, lambda: periodicity(sec(x), x, check=True))
raises(NotImplementedError, lambda: periodicity(sin(x*y), x, check=True))


def test_lcim():
from sympy import pi

assert lcim([S(1)/2, S(2), S(3)]) == 6
assert lcim([pi/2, pi/4, pi]) == pi
assert lcim([2*pi, pi/2]) == 2*pi
assert lcim([S(1), 2*pi]) is None
assert lcim([S(2) + 2*E, E/3 + S(1)/3, S(1) + E]) == S(2) + 2*E


def test_AccumBounds():
assert AccumBounds(1, 2).args == (1, 2)
assert AccumBounds(1, 2).delta == S(1)
Expand Down
Loading

0 comments on commit 8787d84

Please sign in to comment.