# Path: abelfunctions/puiseux_series_ring.py
# def PuiseuxSeriesRing(base_ring, name=None, names=None, default_prec=None, sparse=False):
#     if names is not None:
#         name = names
#     if name is None:
#         raise TypeError('You must specify the name of the indeterminate of the Puiseux series ring.')
# 
#     if default_prec is None:
#         from sage.misc.defaults import series_precision
#         default_prec = series_precision()
# 
#     global puiseux_series
#     key = (base_ring, name, default_prec, sparse)
#     if key in puiseux_series:
#         x = puiseux_series[key]()
#         if x is not None: return x
# 
#     if isinstance(base_ring, Field):
#         R = PuiseuxSeriesRing_field(base_ring, name, default_prec, sparse)
#     elif isinstance(base_ring, IntegralDomain):
#         R = PuiseuxSeriesRing_domain(base_ring, name, default_prec, sparse)
#     elif isinstance(base_ring, CommutativeRing):
#         R = PuiseuxSeriesRing_generic(base_ring, name, default_prec, sparse)
#     else:
#         raise TypeError("base_ring must be a commutative ring")
#     puiseux_series[key] = weakref.ref(R)
#     return R


import numpy
import sympy
from abelfunctions.puiseux_series_ring import PuiseuxSeriesRing
from sage.all import xgcd
from sage.functions.log import log
from sage.functions.other import ceil
from sage.rings.big_oh import O
from sage.rings.infinity import infinity
from sage.rings.laurent_series_ring import LaurentSeriesRing
from sage.rings.qqbar import QQbar
from sage.rings.rational_field import QQ
from sympy import Point, Segment
--------

"""




def newton_polygon_exceptional(H):
    r"""Computes the exceptional Newton polygon of `H`."""
    R = H.parent()
    x,y = R.gens()
    d = H(0,y).degree(y)
    return [[(0,0),(d,0)]]

def newton_polygon(H, additional_points=[]):
    r"""Computes the Newton polygon of `H`.

    It's assumed that the first generator of `H` here is the "dependent
    variable". For example, if `H = H(x,y)` and we are aiming to compute
    a `y`-covering of the complex `x`-sphere then each monomial of `H`
    is of the form

    .. math::

        a_{ij} x^j y^i.

    Parameters
    ----------
    H : bivariate polynomial


# Path: abelfunctions/puiseux_series_ring.py
# def PuiseuxSeriesRing(base_ring, name=None, names=None, default_prec=None, sparse=False):
#     if names is not None:
#         name = names
#     if name is None:
#         raise TypeError('You must specify the name of the indeterminate of the Puiseux series ring.')
# 
#     if default_prec is None:
#         from sage.misc.defaults import series_precision
#         default_prec = series_precision()
# 
#     global puiseux_series
#     key = (base_ring, name, default_prec, sparse)
#     if key in puiseux_series:
#         x = puiseux_series[key]()
#         if x is not None: return x
# 
#     if isinstance(base_ring, Field):
#         R = PuiseuxSeriesRing_field(base_ring, name, default_prec, sparse)
#     elif isinstance(base_ring, IntegralDomain):
#         R = PuiseuxSeriesRing_domain(base_ring, name, default_prec, sparse)
#     elif isinstance(base_ring, CommutativeRing):
#         R = PuiseuxSeriesRing_generic(base_ring, name, default_prec, sparse)
#     else:
#         raise TypeError("base_ring must be a commutative ring")
#     puiseux_series[key] = weakref.ref(R)
#     return R


# Path: abelfunctions/puiseux.py
import numpy
import sympy
from abelfunctions.puiseux_series_ring import PuiseuxSeriesRing
from sage.all import xgcd
from sage.functions.log import log
from sage.functions.other import ceil
from sage.rings.big_oh import O
from sage.rings.infinity import infinity
from sage.rings.laurent_series_ring import LaurentSeriesRing
from sage.rings.qqbar import QQbar
from sage.rings.rational_field import QQ
from sympy import Point, Segment

--------

"""




def newton_polygon_exceptional(H):
    r"""Computes the exceptional Newton polygon of `H`."""
    R = H.parent()
    x,y = R.gens()
    d = H(0,y).degree(y)
    return [[(0,0),(d,0)]]

def newton_polygon(H, additional_points=[]):
    r"""Computes the Newton polygon of `H`.

    It's assumed that the first generator of `H` here is the "dependent
    variable". For example, if `H = H(x,y)` and we are aiming to compute
    a `y`-covering of the complex `x`-sphere then each monomial of `H`
    is of the form

    .. math::

        a_{ij} x^j y^i.

    Parameters
    ----------
    H : bivariate polynomial


    Returns