Skip to content
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

Replace print with logging #133

Merged
merged 34 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c879769
Log instead of print
rparini Jan 4, 2020
2a7b2d4
Add progress bar
rparini Jan 4, 2020
46a7435
Removed unexpected verbose
rparini Jan 4, 2020
44cba9e
Black
rparini Mar 7, 2022
bb090e5
Revert "Black"
rparini Mar 9, 2022
0c1a2c0
run black
rparini Apr 8, 2022
44dd859
merge
rparini Apr 8, 2022
588c059
Merge branch 'master' of https://github.com/RParini/cxroots into feat…
rparini Apr 8, 2022
70e6fd0
Fix docstring
rparini Apr 8, 2022
41f57e3
Fix find_roots verbose
rparini Apr 8, 2022
7e1d2fc
Fix multiplicity tests
rparini Apr 8, 2022
a2225c0
Replace tqdm
rparini Apr 11, 2022
bdc8860
Replace progress with rich
rparini Apr 15, 2022
51c6274
fix rich version
rparini Apr 15, 2022
fa22553
Update docs
rparini Apr 24, 2022
4ac25ca
Unpin rich for python2
rparini Apr 26, 2022
7458cef
Merge remote-tracking branch 'origin/master' into feat/logging
rparini May 3, 2022
a9355eb
Merge branch 'master' into feat/logging
rparini May 3, 2022
1d6a0e9
Merge branch 'master' into feat/logging
rparini Jul 10, 2022
937c38d
Changelog
rparini Jul 10, 2022
d866292
Remove docs changes
rparini Jul 11, 2022
fb3bcb7
Changelog
rparini Jul 11, 2022
f014c1f
Changelog
rparini Jul 11, 2022
5392a82
Spelling
rparini Jul 11, 2022
ef63544
Add rich to changelog
rparini Jul 11, 2022
575c96a
Remove more verbose
rparini Jul 11, 2022
19c528f
Fix whitespace
rparini Jul 11, 2022
5a254fe
Update .gitignore
rparini Jul 11, 2022
97cadb2
Update changelog.md
rparini Jul 11, 2022
6afb5af
Update changelog.md
rparini Jul 11, 2022
84b9c2b
Update docs_src/docex_logging.py
rparini Jul 11, 2022
ec1efd2
Update docs_src/logging.rst
rparini Jul 11, 2022
c8540ba
Whitespace
rparini Jul 11, 2022
cefa07b
Merge branch 'feat/logging' of https://github.com/rparini/cxroots int…
rparini Jul 11, 2022
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
Prev Previous commit
Next Next commit
merge
  • Loading branch information
rparini committed Apr 8, 2022
commit 44dd85997c8945b46ab9c3bc8948fa57275cbe48
80 changes: 40 additions & 40 deletions cxroots/ApproximateRoots.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,68 +31,68 @@ def approximate_roots(
Parameters
----------
C : :class:`~<cxroots.Contour.Contour>`
The contour which encloses the roots of f the user wishes to find.
The contour which encloses the roots of f the user wishes to find.
N : int
The number of roots (counting multiplicties) of f within C.
This is the result of calling :meth:`~cxroots.Contour.Contour.count_roots`.
The number of roots (counting multiplicties) of f within C.
This is the result of calling :meth:`~cxroots.Contour.Contour.count_roots`.
f : function
The function for which the roots are sought. Must be a function
of a single complex variable, z, which is analytic within C and
has no poles or roots on the C.
The function for which the roots are sought. Must be a function
of a single complex variable, z, which is analytic within C and
has no poles or roots on the C.
df : function, optional
A function of a single complex variable which is the derivative
of the function f(z). If df is not given then it will be
approximated with a finite difference formula.
A function of a single complex variable which is the derivative
of the function f(z). If df is not given then it will be
approximated with a finite difference formula.
absTol : float, optional
Absolute error tolerance for integration.
Absolute error tolerance for integration.
relTol : float, optional
Relative error tolerance for integration.
Relative error tolerance for integration.
errStop : float, optional
The number of distinct roots within a contour, n, is determined
by checking if all the elements of a list of contour integrals
involving formal orthogonal polynomials are sufficently close to
zero, ie. that the absolute value of each element is < errStop.
If errStop is too large/small then n may be smaller/larger than
it actually is.
The number of distinct roots within a contour, n, is determined
by checking if all the elements of a list of contour integrals
involving formal orthogonal polynomials are sufficently close to
zero, ie. that the absolute value of each element is < errStop.
If errStop is too large/small then n may be smaller/larger than
it actually is.
divMin : int, optional
If the Romberg integration method is used then divMin is the
minimum number of divisions before the Romberg integration
routine is allowed to exit.
If the Romberg integration method is used then divMin is the
minimum number of divisions before the Romberg integration
routine is allowed to exit.
divMax : int, optional
If the Romberg integration method is used then divMax is the
maximum number of divisions before the Romberg integration
routine exits.
If the Romberg integration method is used then divMax is the
maximum number of divisions before the Romberg integration
routine exits.
m : int, optional
Only used if df=None and method='quad'. The argument order=m is
passed to numdifftools.Derivative and is the order of the error
term in the Taylor approximation. m must be even.
Only used if df=None and method='quad'. The argument order=m is
passed to numdifftools.Derivative and is the order of the error
term in the Taylor approximation. m must be even.
rootTol : float, optional
If any roots are within rootTol of one another then they will be
treated as duplicates and removed. This helps to alleviate the
problem of errStop being too small.
If any roots are within rootTol of one another then they will be
treated as duplicates and removed. This helps to alleviate the
problem of errStop being too small.
intMethod : {'quad', 'romb'}, optional
If 'quad' then :func:`scipy.integrate.quad` is used to perform
integration. If 'romb' then Romberg integraion is performed
instead.
If 'quad' then :func:`scipy.integrate.quad` is used to perform
integration. If 'romb' then Romberg integraion is performed
instead.
callback : function, optional
Only used if intMethod is 'romb'. Passed to :func:`~<cxroots.CountRoots.prod>`.
Only used if intMethod is 'romb'. Passed to :func:`~<cxroots.CountRoots.prod>`.

Returns
-------
tuple of complex
The distinct roots of f within the contour C.
The distinct roots of f within the contour C.
tuple of float
The corresponding multiplicites of the roots within C. Should
be integers but will not be automatically rounded here.
The corresponding multiplicites of the roots within C. Should
be integers but will not be automatically rounded here.

References
----------
.. [KB] P. Kravanja and M. Van Barel. "Computing the Zeros of
Anayltic Functions". Springer (2000)
Anayltic Functions". Springer (2000)
.. [SLV] E. Strakova, D. Lukas, P. Vodstrcil. "Finding Zeros of
Analytic Functions and Local Eigenvalue Analysis Using Contour
Integral Method in Examples". Mathematical Analysis and Numerical
Mathematics, Vol. 15, 2, (2017)
Analytic Functions and Local Eigenvalue Analysis Using Contour
Integral Method in Examples". Mathematical Analysis and Numerical
Mathematics, Vol. 15, 2, (2017)
"""
logger = logging.getLogger(__name__)
logger.info("Approximating the " + str(N) + " roots in: " + str(C))
Expand Down
44 changes: 22 additions & 22 deletions cxroots/Contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class Contour(object):
Attributes
----------
centralPoint : complex
The point at the center of the contour.
The point at the center of the contour.
area : float
The surface area of the contour.
The surface area of the contour.
"""

def __init__(self, segments):
Expand All @@ -34,19 +34,19 @@ def __call__(self, t):
Parameters
----------
t : float
A real number :math:`0\leq t \leq 1` which parameterises
the contour.
A real number :math:`0\leq t \leq 1` which parameterises
the contour.

Returns
-------
complex
A point on the contour.
A point on the contour.

Example
-------

>>> from cxroots.Paths import Circle
>>> c = Circle(0,1) # Circle |z|=1 parameterised by e^{it}
>>> c = Circle(0,1) # Circle |z|=1 parameterised by e^{it}
>>> c(0.25)
(6.123233995736766e-17+1j)
>>> c(0) == c(1)
Expand Down Expand Up @@ -85,7 +85,7 @@ def contains(self, z):
Returns
-------
bool
True if z lies within the contour and false otherwise.
True if z lies within the contour and false otherwise.
"""
raise NotImplementedError("contains() needs to be implemented in the subclass.")

Expand Down Expand Up @@ -118,10 +118,10 @@ def show(self, saveFile=None, **plotKwargs):
Parameters
----------
saveFile : str (optional)
If given then the plot will be saved to disk with name
'saveFile'. If saveFile=None the plot is shown on-screen.
If given then the plot will be saved to disk with name
'saveFile'. If saveFile=None the plot is shown on-screen.
**plotKwargs
Key word arguments are as in :meth:`~cxroots.Contour.Contour.plot`.
Key word arguments are as in :meth:`~cxroots.Contour.Contour.plot`.
"""
import matplotlib.pyplot as plt

Expand All @@ -140,18 +140,18 @@ def subdivisions(self, axis="alternating"):
Parameters
----------
axis : str, 'alternating' or any element of self.axisName.
The axis along which the line subdividing the contour is a
constant (eg. subdividing a circle along the radial axis
will give an outer annulus and an inner circle). If
alternating then the dividing axis will always be different
to the dividing axis used to create the contour which is now
being divided.
The axis along which the line subdividing the contour is a
constant (eg. subdividing a circle along the radial axis
will give an outer annulus and an inner circle). If
alternating then the dividing axis will always be different
to the dividing axis used to create the contour which is now
being divided.

Yields
------
tuple
A tuple with two contours which subdivide the original
contour.
A tuple with two contours which subdivide the original
contour.
"""
if axis == "alternating":
if hasattr(self, "_createdBySubdivisionAxis"):
Expand All @@ -170,14 +170,14 @@ def distance(self, z):
Parameters
----------
z : complex
The point from which to measure the distance to the closest
point on the contour to z.
The point from which to measure the distance to the closest
point on the contour to z.

Returns
-------
float
The distance from z to the point on the contour which is
closest to z.
The distance from z to the point on the contour which is
closest to z.
"""
return min(segment.distance(z) for segment in self.segments)

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.