repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
dhermes/bezier | src/bezier/_algebraic_intersection.py | _to_power_basis_degree8 | def _to_power_basis_degree8(nodes1, nodes2):
r"""Compute the coefficients of an **intersection polynomial**.
Helper for :func:`to_power_basis` in the case that B |eacute| zout's
`theorem`_ tells us the **intersection polynomial** is degree
:math:`8`. This happens if the two curves have degrees one and ... | python | def _to_power_basis_degree8(nodes1, nodes2):
r"""Compute the coefficients of an **intersection polynomial**.
Helper for :func:`to_power_basis` in the case that B |eacute| zout's
`theorem`_ tells us the **intersection polynomial** is degree
:math:`8`. This happens if the two curves have degrees one and ... | [
"def",
"_to_power_basis_degree8",
"(",
"nodes1",
",",
"nodes2",
")",
":",
"evaluated",
"=",
"[",
"eval_intersection_polynomial",
"(",
"nodes1",
",",
"nodes2",
",",
"t_val",
")",
"for",
"t_val",
"in",
"_CHEB9",
"]",
"return",
"polynomial",
".",
"polyfit",
"(",
... | r"""Compute the coefficients of an **intersection polynomial**.
Helper for :func:`to_power_basis` in the case that B |eacute| zout's
`theorem`_ tells us the **intersection polynomial** is degree
:math:`8`. This happens if the two curves have degrees one and eight
or have degrees two and four.
.. n... | [
"r",
"Compute",
"the",
"coefficients",
"of",
"an",
"**",
"intersection",
"polynomial",
"**",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L432-L457 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | _to_power_basis33 | def _to_power_basis33(nodes1, nodes2):
r"""Compute the coefficients of an **intersection polynomial**.
Helper for :func:`to_power_basis` in the case that each curve is
degree three. In this case, B |eacute| zout's `theorem`_ tells us
that the **intersection polynomial** is degree :math:`3 \cdot 3`
... | python | def _to_power_basis33(nodes1, nodes2):
r"""Compute the coefficients of an **intersection polynomial**.
Helper for :func:`to_power_basis` in the case that each curve is
degree three. In this case, B |eacute| zout's `theorem`_ tells us
that the **intersection polynomial** is degree :math:`3 \cdot 3`
... | [
"def",
"_to_power_basis33",
"(",
"nodes1",
",",
"nodes2",
")",
":",
"evaluated",
"=",
"[",
"eval_intersection_polynomial",
"(",
"nodes1",
",",
"nodes2",
",",
"t_val",
")",
"for",
"t_val",
"in",
"_CHEB10",
"]",
"return",
"polynomial",
".",
"polyfit",
"(",
"_C... | r"""Compute the coefficients of an **intersection polynomial**.
Helper for :func:`to_power_basis` in the case that each curve is
degree three. In this case, B |eacute| zout's `theorem`_ tells us
that the **intersection polynomial** is degree :math:`3 \cdot 3`
hence we return ten coefficients.
.. n... | [
"r",
"Compute",
"the",
"coefficients",
"of",
"an",
"**",
"intersection",
"polynomial",
"**",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L460-L486 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | to_power_basis | def to_power_basis(nodes1, nodes2):
"""Compute the coefficients of an **intersection polynomial**.
.. note::
This assumes that the degree of the curve given by ``nodes1`` is
less than or equal to the degree of that given by ``nodes2``.
Args:
nodes1 (numpy.ndarray): The nodes in the ... | python | def to_power_basis(nodes1, nodes2):
"""Compute the coefficients of an **intersection polynomial**.
.. note::
This assumes that the degree of the curve given by ``nodes1`` is
less than or equal to the degree of that given by ``nodes2``.
Args:
nodes1 (numpy.ndarray): The nodes in the ... | [
"def",
"to_power_basis",
"(",
"nodes1",
",",
"nodes2",
")",
":",
"# NOTE: There is no corresponding \"enable\", but the disable only applies",
"# in this lexical scope.",
"# pylint: disable=too-many-return-statements",
"_",
",",
"num_nodes1",
"=",
"nodes1",
".",
"shape",
"_... | Compute the coefficients of an **intersection polynomial**.
.. note::
This assumes that the degree of the curve given by ``nodes1`` is
less than or equal to the degree of that given by ``nodes2``.
Args:
nodes1 (numpy.ndarray): The nodes in the first curve.
nodes2 (numpy.ndarray)... | [
"Compute",
"the",
"coefficients",
"of",
"an",
"**",
"intersection",
"polynomial",
"**",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L489-L546 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | polynomial_norm | def polynomial_norm(coeffs):
r"""Computes :math:`L_2` norm of polynomial on :math:`\left[0, 1\right]`.
We have
.. math::
\left\langle f, f \right\rangle = \sum_{i, j}
\int_0^1 c_i c_j x^{i + j} \, dx = \sum_{i, j}
\frac{c_i c_j}{i + j + 1} = \sum_{i} \frac{c_i^2}{2 i + 1}
... | python | def polynomial_norm(coeffs):
r"""Computes :math:`L_2` norm of polynomial on :math:`\left[0, 1\right]`.
We have
.. math::
\left\langle f, f \right\rangle = \sum_{i, j}
\int_0^1 c_i c_j x^{i + j} \, dx = \sum_{i, j}
\frac{c_i c_j}{i + j + 1} = \sum_{i} \frac{c_i^2}{2 i + 1}
... | [
"def",
"polynomial_norm",
"(",
"coeffs",
")",
":",
"num_coeffs",
",",
"=",
"coeffs",
".",
"shape",
"result",
"=",
"0.0",
"for",
"i",
"in",
"six",
".",
"moves",
".",
"xrange",
"(",
"num_coeffs",
")",
":",
"coeff_i",
"=",
"coeffs",
"[",
"i",
"]",
"resu... | r"""Computes :math:`L_2` norm of polynomial on :math:`\left[0, 1\right]`.
We have
.. math::
\left\langle f, f \right\rangle = \sum_{i, j}
\int_0^1 c_i c_j x^{i + j} \, dx = \sum_{i, j}
\frac{c_i c_j}{i + j + 1} = \sum_{i} \frac{c_i^2}{2 i + 1}
+ 2 \sum_{j > i} \frac{c_... | [
"r",
"Computes",
":",
"math",
":",
"L_2",
"norm",
"of",
"polynomial",
"on",
":",
"math",
":",
"\\",
"left",
"[",
"0",
"1",
"\\",
"right",
"]",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L549-L576 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | normalize_polynomial | def normalize_polynomial(coeffs, threshold=_L2_THRESHOLD):
r"""Normalizes a polynomial in the :math:`L_2` sense.
Does so on the interval :math:\left[0, 1\right]` via
:func:`polynomial_norm`.
Args:
coeffs (numpy.ndarray): ``d + 1``-array of coefficients in monomial /
power basis.
... | python | def normalize_polynomial(coeffs, threshold=_L2_THRESHOLD):
r"""Normalizes a polynomial in the :math:`L_2` sense.
Does so on the interval :math:\left[0, 1\right]` via
:func:`polynomial_norm`.
Args:
coeffs (numpy.ndarray): ``d + 1``-array of coefficients in monomial /
power basis.
... | [
"def",
"normalize_polynomial",
"(",
"coeffs",
",",
"threshold",
"=",
"_L2_THRESHOLD",
")",
":",
"l2_norm",
"=",
"polynomial_norm",
"(",
"coeffs",
")",
"if",
"l2_norm",
"<",
"threshold",
":",
"return",
"np",
".",
"zeros",
"(",
"coeffs",
".",
"shape",
",",
"... | r"""Normalizes a polynomial in the :math:`L_2` sense.
Does so on the interval :math:\left[0, 1\right]` via
:func:`polynomial_norm`.
Args:
coeffs (numpy.ndarray): ``d + 1``-array of coefficients in monomial /
power basis.
threshold (Optional[float]): The point :math:`\tau` below... | [
"r",
"Normalizes",
"a",
"polynomial",
"in",
"the",
":",
"math",
":",
"L_2",
"sense",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L579-L601 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | _get_sigma_coeffs | def _get_sigma_coeffs(coeffs):
r"""Compute "transformed" form of polynomial in Bernstein form.
Makes sure the "transformed" polynomial is monic (i.e. by dividing by the
lead coefficient) and just returns the coefficients of the non-lead terms.
For example, the polynomial
.. math::
f(s) = ... | python | def _get_sigma_coeffs(coeffs):
r"""Compute "transformed" form of polynomial in Bernstein form.
Makes sure the "transformed" polynomial is monic (i.e. by dividing by the
lead coefficient) and just returns the coefficients of the non-lead terms.
For example, the polynomial
.. math::
f(s) = ... | [
"def",
"_get_sigma_coeffs",
"(",
"coeffs",
")",
":",
"num_nodes",
",",
"=",
"coeffs",
".",
"shape",
"degree",
"=",
"num_nodes",
"-",
"1",
"effective_degree",
"=",
"None",
"for",
"index",
"in",
"six",
".",
"moves",
".",
"range",
"(",
"degree",
",",
"-",
... | r"""Compute "transformed" form of polynomial in Bernstein form.
Makes sure the "transformed" polynomial is monic (i.e. by dividing by the
lead coefficient) and just returns the coefficients of the non-lead terms.
For example, the polynomial
.. math::
f(s) = 4 (1 - s)^2 + 3 \cdot 2 s(1 - s) + ... | [
"r",
"Compute",
"transformed",
"form",
"of",
"polynomial",
"in",
"Bernstein",
"form",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L604-L679 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | bernstein_companion | def bernstein_companion(coeffs):
r"""Compute a companion matrix for a polynomial in Bernstein basis.
.. note::
This assumes the caller passes in a 1D array but does not check.
This takes the polynomial
.. math::
f(s) = \sum_{j = 0}^n b_{j, n} \cdot C_j.
and uses the variable :mat... | python | def bernstein_companion(coeffs):
r"""Compute a companion matrix for a polynomial in Bernstein basis.
.. note::
This assumes the caller passes in a 1D array but does not check.
This takes the polynomial
.. math::
f(s) = \sum_{j = 0}^n b_{j, n} \cdot C_j.
and uses the variable :mat... | [
"def",
"bernstein_companion",
"(",
"coeffs",
")",
":",
"sigma_coeffs",
",",
"degree",
",",
"effective_degree",
"=",
"_get_sigma_coeffs",
"(",
"coeffs",
")",
"if",
"effective_degree",
"==",
"0",
":",
"return",
"np",
".",
"empty",
"(",
"(",
"0",
",",
"0",
")... | r"""Compute a companion matrix for a polynomial in Bernstein basis.
.. note::
This assumes the caller passes in a 1D array but does not check.
This takes the polynomial
.. math::
f(s) = \sum_{j = 0}^n b_{j, n} \cdot C_j.
and uses the variable :math:`\sigma = \frac{s}{1 - s}` to rewri... | [
"r",
"Compute",
"a",
"companion",
"matrix",
"for",
"a",
"polynomial",
"in",
"Bernstein",
"basis",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L682-L724 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | bezier_roots | def bezier_roots(coeffs):
r"""Compute polynomial roots from a polynomial in the Bernstein basis.
.. note::
This assumes the caller passes in a 1D array but does not check.
This takes the polynomial
.. math::
f(s) = \sum_{j = 0}^n b_{j, n} \cdot C_j.
and uses the variable :math:`\... | python | def bezier_roots(coeffs):
r"""Compute polynomial roots from a polynomial in the Bernstein basis.
.. note::
This assumes the caller passes in a 1D array but does not check.
This takes the polynomial
.. math::
f(s) = \sum_{j = 0}^n b_{j, n} \cdot C_j.
and uses the variable :math:`\... | [
"def",
"bezier_roots",
"(",
"coeffs",
")",
":",
"companion",
",",
"degree",
",",
"effective_degree",
"=",
"bernstein_companion",
"(",
"coeffs",
")",
"if",
"effective_degree",
":",
"sigma_roots",
"=",
"np",
".",
"linalg",
".",
"eigvals",
"(",
"companion",
")",
... | r"""Compute polynomial roots from a polynomial in the Bernstein basis.
.. note::
This assumes the caller passes in a 1D array but does not check.
This takes the polynomial
.. math::
f(s) = \sum_{j = 0}^n b_{j, n} \cdot C_j.
and uses the variable :math:`\sigma = \frac{s}{1 - s}` to re... | [
"r",
"Compute",
"polynomial",
"roots",
"from",
"a",
"polynomial",
"in",
"the",
"Bernstein",
"basis",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L727-L896 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | lu_companion | def lu_companion(top_row, value):
r"""Compute an LU-factored :math:`C - t I` and its 1-norm.
.. _dgecon:
http://www.netlib.org/lapack/explore-html/dd/d9a/group__double_g_ecomputational_ga188b8d30443d14b1a3f7f8331d87ae60.html#ga188b8d30443d14b1a3f7f8331d87ae60
.. _dgetrf:
http://www.netlib.o... | python | def lu_companion(top_row, value):
r"""Compute an LU-factored :math:`C - t I` and its 1-norm.
.. _dgecon:
http://www.netlib.org/lapack/explore-html/dd/d9a/group__double_g_ecomputational_ga188b8d30443d14b1a3f7f8331d87ae60.html#ga188b8d30443d14b1a3f7f8331d87ae60
.. _dgetrf:
http://www.netlib.o... | [
"def",
"lu_companion",
"(",
"top_row",
",",
"value",
")",
":",
"degree",
",",
"=",
"top_row",
".",
"shape",
"lu_mat",
"=",
"np",
".",
"zeros",
"(",
"(",
"degree",
",",
"degree",
")",
",",
"order",
"=",
"\"F\"",
")",
"if",
"degree",
"==",
"1",
":",
... | r"""Compute an LU-factored :math:`C - t I` and its 1-norm.
.. _dgecon:
http://www.netlib.org/lapack/explore-html/dd/d9a/group__double_g_ecomputational_ga188b8d30443d14b1a3f7f8331d87ae60.html#ga188b8d30443d14b1a3f7f8331d87ae60
.. _dgetrf:
http://www.netlib.org/lapack/explore-html/dd/d9a/group__d... | [
"r",
"Compute",
"an",
"LU",
"-",
"factored",
":",
"math",
":",
"C",
"-",
"t",
"I",
"and",
"its",
"1",
"-",
"norm",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L899-L1023 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | _reciprocal_condition_number | def _reciprocal_condition_number(lu_mat, one_norm):
r"""Compute reciprocal condition number of a matrix.
Args:
lu_mat (numpy.ndarray): A 2D array of a matrix :math:`A` that has been
LU-factored, with the non-diagonal part of :math:`L` stored in the
strictly lower triangle and :m... | python | def _reciprocal_condition_number(lu_mat, one_norm):
r"""Compute reciprocal condition number of a matrix.
Args:
lu_mat (numpy.ndarray): A 2D array of a matrix :math:`A` that has been
LU-factored, with the non-diagonal part of :math:`L` stored in the
strictly lower triangle and :m... | [
"def",
"_reciprocal_condition_number",
"(",
"lu_mat",
",",
"one_norm",
")",
":",
"if",
"_scipy_lapack",
"is",
"None",
":",
"raise",
"OSError",
"(",
"\"This function requires SciPy for calling into LAPACK.\"",
")",
"# pylint: disable=no-member",
"rcond",
",",
"info",
"=",
... | r"""Compute reciprocal condition number of a matrix.
Args:
lu_mat (numpy.ndarray): A 2D array of a matrix :math:`A` that has been
LU-factored, with the non-diagonal part of :math:`L` stored in the
strictly lower triangle and :math:`U` stored in the upper triangle.
one_norm (... | [
"r",
"Compute",
"reciprocal",
"condition",
"number",
"of",
"a",
"matrix",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1026-L1054 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | bezier_value_check | def bezier_value_check(coeffs, s_val, rhs_val=0.0):
r"""Check if a polynomial in the Bernstein basis evaluates to a value.
This is intended to be used for root checking, i.e. for a polynomial
:math:`f(s)` and a particular value :math:`s_{\ast}`:
Is it true that :math:`f\left(s_{\ast}\right) = 0`?
... | python | def bezier_value_check(coeffs, s_val, rhs_val=0.0):
r"""Check if a polynomial in the Bernstein basis evaluates to a value.
This is intended to be used for root checking, i.e. for a polynomial
:math:`f(s)` and a particular value :math:`s_{\ast}`:
Is it true that :math:`f\left(s_{\ast}\right) = 0`?
... | [
"def",
"bezier_value_check",
"(",
"coeffs",
",",
"s_val",
",",
"rhs_val",
"=",
"0.0",
")",
":",
"if",
"s_val",
"==",
"1.0",
":",
"return",
"coeffs",
"[",
"-",
"1",
"]",
"==",
"rhs_val",
"shifted_coeffs",
"=",
"coeffs",
"-",
"rhs_val",
"sigma_coeffs",
","... | r"""Check if a polynomial in the Bernstein basis evaluates to a value.
This is intended to be used for root checking, i.e. for a polynomial
:math:`f(s)` and a particular value :math:`s_{\ast}`:
Is it true that :math:`f\left(s_{\ast}\right) = 0`?
Does so by re-stating as a matrix rank problem. As i... | [
"r",
"Check",
"if",
"a",
"polynomial",
"in",
"the",
"Bernstein",
"basis",
"evaluates",
"to",
"a",
"value",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1057-L1127 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | roots_in_unit_interval | def roots_in_unit_interval(coeffs):
r"""Compute roots of a polynomial in the unit interval.
Args:
coeffs (numpy.ndarray): A 1D array (size ``d + 1``) of coefficients in
monomial / power basis.
Returns:
numpy.ndarray: ``N``-array of real values in :math:`\left[0, 1\right]`.
... | python | def roots_in_unit_interval(coeffs):
r"""Compute roots of a polynomial in the unit interval.
Args:
coeffs (numpy.ndarray): A 1D array (size ``d + 1``) of coefficients in
monomial / power basis.
Returns:
numpy.ndarray: ``N``-array of real values in :math:`\left[0, 1\right]`.
... | [
"def",
"roots_in_unit_interval",
"(",
"coeffs",
")",
":",
"all_roots",
"=",
"polynomial",
".",
"polyroots",
"(",
"coeffs",
")",
"# Only keep roots inside or very near to the unit interval.",
"all_roots",
"=",
"all_roots",
"[",
"(",
"_UNIT_INTERVAL_WIGGLE_START",
"<",
"all... | r"""Compute roots of a polynomial in the unit interval.
Args:
coeffs (numpy.ndarray): A 1D array (size ``d + 1``) of coefficients in
monomial / power basis.
Returns:
numpy.ndarray: ``N``-array of real values in :math:`\left[0, 1\right]`. | [
"r",
"Compute",
"roots",
"of",
"a",
"polynomial",
"in",
"the",
"unit",
"interval",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1130-L1149 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | _strip_leading_zeros | def _strip_leading_zeros(coeffs, threshold=_COEFFICIENT_THRESHOLD):
r"""Strip leading zero coefficients from a polynomial.
.. note::
This assumes the polynomial :math:`f` defined by ``coeffs``
has been normalized (via :func:`.normalize_polynomial`).
Args:
coeffs (numpy.ndarray): ``d... | python | def _strip_leading_zeros(coeffs, threshold=_COEFFICIENT_THRESHOLD):
r"""Strip leading zero coefficients from a polynomial.
.. note::
This assumes the polynomial :math:`f` defined by ``coeffs``
has been normalized (via :func:`.normalize_polynomial`).
Args:
coeffs (numpy.ndarray): ``d... | [
"def",
"_strip_leading_zeros",
"(",
"coeffs",
",",
"threshold",
"=",
"_COEFFICIENT_THRESHOLD",
")",
":",
"while",
"np",
".",
"abs",
"(",
"coeffs",
"[",
"-",
"1",
"]",
")",
"<",
"threshold",
":",
"coeffs",
"=",
"coeffs",
"[",
":",
"-",
"1",
"]",
"return... | r"""Strip leading zero coefficients from a polynomial.
.. note::
This assumes the polynomial :math:`f` defined by ``coeffs``
has been normalized (via :func:`.normalize_polynomial`).
Args:
coeffs (numpy.ndarray): ``d + 1``-array of coefficients in monomial /
power basis.
... | [
"r",
"Strip",
"leading",
"zero",
"coefficients",
"from",
"a",
"polynomial",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1152-L1172 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | _check_non_simple | def _check_non_simple(coeffs):
r"""Checks that a polynomial has no non-simple roots.
Does so by computing the companion matrix :math:`A` of :math:`f'`
and then evaluating the rank of :math:`B = f(A)`. If :math:`B` is not
full rank, then :math:`f` and :math:`f'` have a shared factor.
See: https://d... | python | def _check_non_simple(coeffs):
r"""Checks that a polynomial has no non-simple roots.
Does so by computing the companion matrix :math:`A` of :math:`f'`
and then evaluating the rank of :math:`B = f(A)`. If :math:`B` is not
full rank, then :math:`f` and :math:`f'` have a shared factor.
See: https://d... | [
"def",
"_check_non_simple",
"(",
"coeffs",
")",
":",
"coeffs",
"=",
"_strip_leading_zeros",
"(",
"coeffs",
")",
"num_coeffs",
",",
"=",
"coeffs",
".",
"shape",
"if",
"num_coeffs",
"<",
"3",
":",
"return",
"deriv_poly",
"=",
"polynomial",
".",
"polyder",
"(",... | r"""Checks that a polynomial has no non-simple roots.
Does so by computing the companion matrix :math:`A` of :math:`f'`
and then evaluating the rank of :math:`B = f(A)`. If :math:`B` is not
full rank, then :math:`f` and :math:`f'` have a shared factor.
See: https://dx.doi.org/10.1016/0024-3795(70)9002... | [
"r",
"Checks",
"that",
"a",
"polynomial",
"has",
"no",
"non",
"-",
"simple",
"roots",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1175-L1222 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | _resolve_and_add | def _resolve_and_add(nodes1, s_val, final_s, nodes2, t_val, final_t):
"""Resolve a computed intersection and add to lists.
We perform one Newton step to deal with any residual issues of
high-degree polynomial solves (one of which depends on the already
approximate ``x_val, y_val``).
Args:
... | python | def _resolve_and_add(nodes1, s_val, final_s, nodes2, t_val, final_t):
"""Resolve a computed intersection and add to lists.
We perform one Newton step to deal with any residual issues of
high-degree polynomial solves (one of which depends on the already
approximate ``x_val, y_val``).
Args:
... | [
"def",
"_resolve_and_add",
"(",
"nodes1",
",",
"s_val",
",",
"final_s",
",",
"nodes2",
",",
"t_val",
",",
"final_t",
")",
":",
"s_val",
",",
"t_val",
"=",
"_intersection_helpers",
".",
"newton_refine",
"(",
"s_val",
",",
"nodes1",
",",
"t_val",
",",
"nodes... | Resolve a computed intersection and add to lists.
We perform one Newton step to deal with any residual issues of
high-degree polynomial solves (one of which depends on the already
approximate ``x_val, y_val``).
Args:
nodes1 (numpy.ndarray): The nodes in the first curve.
s_val (float): ... | [
"Resolve",
"a",
"computed",
"intersection",
"and",
"add",
"to",
"lists",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1225-L1253 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | intersect_curves | def intersect_curves(nodes1, nodes2):
r"""Intersect two parametric B |eacute| zier curves.
Args:
nodes1 (numpy.ndarray): The nodes in the first curve.
nodes2 (numpy.ndarray): The nodes in the second curve.
Returns:
numpy.ndarray: ``2 x N`` array of intersection parameters.
... | python | def intersect_curves(nodes1, nodes2):
r"""Intersect two parametric B |eacute| zier curves.
Args:
nodes1 (numpy.ndarray): The nodes in the first curve.
nodes2 (numpy.ndarray): The nodes in the second curve.
Returns:
numpy.ndarray: ``2 x N`` array of intersection parameters.
... | [
"def",
"intersect_curves",
"(",
"nodes1",
",",
"nodes2",
")",
":",
"nodes1",
"=",
"_curve_helpers",
".",
"full_reduce",
"(",
"nodes1",
")",
"nodes2",
"=",
"_curve_helpers",
".",
"full_reduce",
"(",
"nodes2",
")",
"_",
",",
"num_nodes1",
"=",
"nodes1",
".",
... | r"""Intersect two parametric B |eacute| zier curves.
Args:
nodes1 (numpy.ndarray): The nodes in the first curve.
nodes2 (numpy.ndarray): The nodes in the second curve.
Returns:
numpy.ndarray: ``2 x N`` array of intersection parameters.
Each row contains a pair of values :math:`... | [
"r",
"Intersect",
"two",
"parametric",
"B",
"|eacute|",
"zier",
"curves",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1256-L1301 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | poly_to_power_basis | def poly_to_power_basis(bezier_coeffs):
"""Convert a B |eacute| zier curve to polynomial in power basis.
.. note::
This assumes, but does not verify, that the "B |eacute| zier
degree" matches the true degree of the curve. Callers can
guarantee this by calling :func:`.full_reduce`.
Ar... | python | def poly_to_power_basis(bezier_coeffs):
"""Convert a B |eacute| zier curve to polynomial in power basis.
.. note::
This assumes, but does not verify, that the "B |eacute| zier
degree" matches the true degree of the curve. Callers can
guarantee this by calling :func:`.full_reduce`.
Ar... | [
"def",
"poly_to_power_basis",
"(",
"bezier_coeffs",
")",
":",
"num_coeffs",
",",
"=",
"bezier_coeffs",
".",
"shape",
"if",
"num_coeffs",
"==",
"1",
":",
"return",
"bezier_coeffs",
"elif",
"num_coeffs",
"==",
"2",
":",
"# C0 (1 - s) + C1 s = C0 + (C1 - C0) s",
"coeff... | Convert a B |eacute| zier curve to polynomial in power basis.
.. note::
This assumes, but does not verify, that the "B |eacute| zier
degree" matches the true degree of the curve. Callers can
guarantee this by calling :func:`.full_reduce`.
Args:
bezier_coeffs (numpy.ndarray): A 1D... | [
"Convert",
"a",
"B",
"|eacute|",
"zier",
"curve",
"to",
"polynomial",
"in",
"power",
"basis",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1304-L1358 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | locate_point | def locate_point(nodes, x_val, y_val):
r"""Find the parameter corresponding to a point on a curve.
.. note::
This assumes that the curve :math:`B(s, t)` defined by ``nodes``
lives in :math:`\mathbf{R}^2`.
Args:
nodes (numpy.ndarray): The nodes defining a B |eacute| zier curve.
... | python | def locate_point(nodes, x_val, y_val):
r"""Find the parameter corresponding to a point on a curve.
.. note::
This assumes that the curve :math:`B(s, t)` defined by ``nodes``
lives in :math:`\mathbf{R}^2`.
Args:
nodes (numpy.ndarray): The nodes defining a B |eacute| zier curve.
... | [
"def",
"locate_point",
"(",
"nodes",
",",
"x_val",
",",
"y_val",
")",
":",
"# First, reduce to the true degree of x(s) and y(s).",
"zero1",
"=",
"_curve_helpers",
".",
"full_reduce",
"(",
"nodes",
"[",
"[",
"0",
"]",
",",
":",
"]",
")",
"-",
"x_val",
"zero2",
... | r"""Find the parameter corresponding to a point on a curve.
.. note::
This assumes that the curve :math:`B(s, t)` defined by ``nodes``
lives in :math:`\mathbf{R}^2`.
Args:
nodes (numpy.ndarray): The nodes defining a B |eacute| zier curve.
x_val (float): The :math:`x`-coordinate ... | [
"r",
"Find",
"the",
"parameter",
"corresponding",
"to",
"a",
"point",
"on",
"a",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1361-L1402 |
dhermes/bezier | src/bezier/_algebraic_intersection.py | all_intersections | def all_intersections(nodes_first, nodes_second):
r"""Find the points of intersection among a pair of curves.
.. note::
This assumes both curves are :math:`\mathbf{R}^2`, but does not
**explicitly** check this. However, functions used here will fail if
that assumption fails.
Args:
... | python | def all_intersections(nodes_first, nodes_second):
r"""Find the points of intersection among a pair of curves.
.. note::
This assumes both curves are :math:`\mathbf{R}^2`, but does not
**explicitly** check this. However, functions used here will fail if
that assumption fails.
Args:
... | [
"def",
"all_intersections",
"(",
"nodes_first",
",",
"nodes_second",
")",
":",
"# Only attempt this if the bounding boxes intersect.",
"bbox_int",
"=",
"_geometric_intersection",
".",
"bbox_intersect",
"(",
"nodes_first",
",",
"nodes_second",
")",
"if",
"bbox_int",
"==",
... | r"""Find the points of intersection among a pair of curves.
.. note::
This assumes both curves are :math:`\mathbf{R}^2`, but does not
**explicitly** check this. However, functions used here will fail if
that assumption fails.
Args:
nodes_first (numpy.ndarray): Control points of a... | [
"r",
"Find",
"the",
"points",
"of",
"intersection",
"among",
"a",
"pair",
"of",
"curves",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_algebraic_intersection.py#L1405-L1438 |
dhermes/bezier | src/bezier/_helpers.py | _vector_close | def _vector_close(vec1, vec2, eps=_EPS):
r"""Checks that two vectors are equal to some threshold.
Does so by computing :math:`s_1 = \|v_1\|_2` and
:math:`s_2 = \|v_2\|_2` and then checking if
.. math::
\|v_1 - v_2\|_2 \leq \varepsilon \min(s_1, s_2)
where :math:`\varepsilon = 2^{-40} \app... | python | def _vector_close(vec1, vec2, eps=_EPS):
r"""Checks that two vectors are equal to some threshold.
Does so by computing :math:`s_1 = \|v_1\|_2` and
:math:`s_2 = \|v_2\|_2` and then checking if
.. math::
\|v_1 - v_2\|_2 \leq \varepsilon \min(s_1, s_2)
where :math:`\varepsilon = 2^{-40} \app... | [
"def",
"_vector_close",
"(",
"vec1",
",",
"vec2",
",",
"eps",
"=",
"_EPS",
")",
":",
"# NOTE: This relies on ``vec1`` and ``vec2`` being one-dimensional",
"# vectors so NumPy doesn't try to use a matrix norm.",
"size1",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"v... | r"""Checks that two vectors are equal to some threshold.
Does so by computing :math:`s_1 = \|v_1\|_2` and
:math:`s_2 = \|v_2\|_2` and then checking if
.. math::
\|v_1 - v_2\|_2 \leq \varepsilon \min(s_1, s_2)
where :math:`\varepsilon = 2^{-40} \approx 10^{-12}` is a fixed
threshold. In th... | [
"r",
"Checks",
"that",
"two",
"vectors",
"are",
"equal",
"to",
"some",
"threshold",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L36-L86 |
dhermes/bezier | src/bezier/_helpers.py | _bbox | def _bbox(nodes):
"""Get the bounding box for set of points.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): A set of points.
Returns:
Tuple[float, float, float, float]: The left, righ... | python | def _bbox(nodes):
"""Get the bounding box for set of points.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): A set of points.
Returns:
Tuple[float, float, float, float]: The left, righ... | [
"def",
"_bbox",
"(",
"nodes",
")",
":",
"left",
",",
"bottom",
"=",
"np",
".",
"min",
"(",
"nodes",
",",
"axis",
"=",
"1",
")",
"right",
",",
"top",
"=",
"np",
".",
"max",
"(",
"nodes",
",",
"axis",
"=",
"1",
")",
"return",
"left",
",",
"righ... | Get the bounding box for set of points.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): A set of points.
Returns:
Tuple[float, float, float, float]: The left, right,
bottom and top... | [
"Get",
"the",
"bounding",
"box",
"for",
"set",
"of",
"points",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L115-L132 |
dhermes/bezier | src/bezier/_helpers.py | _contains_nd | def _contains_nd(nodes, point):
r"""Predicate indicating if a point is within a bounding box.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): A set of points.
point (numpy.ndarray): A 1D Num... | python | def _contains_nd(nodes, point):
r"""Predicate indicating if a point is within a bounding box.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): A set of points.
point (numpy.ndarray): A 1D Num... | [
"def",
"_contains_nd",
"(",
"nodes",
",",
"point",
")",
":",
"min_vals",
"=",
"np",
".",
"min",
"(",
"nodes",
",",
"axis",
"=",
"1",
")",
"if",
"not",
"np",
".",
"all",
"(",
"min_vals",
"<=",
"point",
")",
":",
"return",
"False",
"max_vals",
"=",
... | r"""Predicate indicating if a point is within a bounding box.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): A set of points.
point (numpy.ndarray): A 1D NumPy array representing a point
... | [
"r",
"Predicate",
"indicating",
"if",
"a",
"point",
"is",
"within",
"a",
"bounding",
"box",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L135-L159 |
dhermes/bezier | src/bezier/_helpers.py | matrix_product | def matrix_product(mat1, mat2):
"""Compute the product of two Fortran contiguous matrices.
This is to avoid the overhead of NumPy converting to C-contiguous
before computing a matrix product.
Does so via ``A B = (B^T A^T)^T`` since ``B^T`` and ``A^T`` will be
C-contiguous without a copy, then the ... | python | def matrix_product(mat1, mat2):
"""Compute the product of two Fortran contiguous matrices.
This is to avoid the overhead of NumPy converting to C-contiguous
before computing a matrix product.
Does so via ``A B = (B^T A^T)^T`` since ``B^T`` and ``A^T`` will be
C-contiguous without a copy, then the ... | [
"def",
"matrix_product",
"(",
"mat1",
",",
"mat2",
")",
":",
"return",
"np",
".",
"dot",
"(",
"mat2",
".",
"T",
",",
"mat1",
".",
"T",
")",
".",
"T"
] | Compute the product of two Fortran contiguous matrices.
This is to avoid the overhead of NumPy converting to C-contiguous
before computing a matrix product.
Does so via ``A B = (B^T A^T)^T`` since ``B^T`` and ``A^T`` will be
C-contiguous without a copy, then the product ``P = B^T A^T`` will
be C-c... | [
"Compute",
"the",
"product",
"of",
"two",
"Fortran",
"contiguous",
"matrices",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L190-L207 |
dhermes/bezier | src/bezier/_helpers.py | _wiggle_interval | def _wiggle_interval(value, wiggle=0.5 ** 44):
r"""Check if ``value`` is in :math:`\left[0, 1\right]`.
Allows a little bit of wiggle room outside the interval. Any value
within ``wiggle`` of ``0.0` will be converted to ``0.0` and similar
for ``1.0``.
.. note::
There is also a Fortran imple... | python | def _wiggle_interval(value, wiggle=0.5 ** 44):
r"""Check if ``value`` is in :math:`\left[0, 1\right]`.
Allows a little bit of wiggle room outside the interval. Any value
within ``wiggle`` of ``0.0` will be converted to ``0.0` and similar
for ``1.0``.
.. note::
There is also a Fortran imple... | [
"def",
"_wiggle_interval",
"(",
"value",
",",
"wiggle",
"=",
"0.5",
"**",
"44",
")",
":",
"if",
"-",
"wiggle",
"<",
"value",
"<",
"wiggle",
":",
"return",
"0.0",
",",
"True",
"elif",
"wiggle",
"<=",
"value",
"<=",
"1.0",
"-",
"wiggle",
":",
"return",... | r"""Check if ``value`` is in :math:`\left[0, 1\right]`.
Allows a little bit of wiggle room outside the interval. Any value
within ``wiggle`` of ``0.0` will be converted to ``0.0` and similar
for ``1.0``.
.. note::
There is also a Fortran implementation of this function, which
will be us... | [
"r",
"Check",
"if",
"value",
"is",
"in",
":",
"math",
":",
"\\",
"left",
"[",
"0",
"1",
"\\",
"right",
"]",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L210-L245 |
dhermes/bezier | src/bezier/_helpers.py | cross_product_compare | def cross_product_compare(start, candidate1, candidate2):
"""Compare two relative changes by their cross-product.
This is meant to be a way to determine which vector is more "inside"
relative to ``start``.
.. note::
This is a helper for :func:`_simple_convex_hull`.
Args:
start (nu... | python | def cross_product_compare(start, candidate1, candidate2):
"""Compare two relative changes by their cross-product.
This is meant to be a way to determine which vector is more "inside"
relative to ``start``.
.. note::
This is a helper for :func:`_simple_convex_hull`.
Args:
start (nu... | [
"def",
"cross_product_compare",
"(",
"start",
",",
"candidate1",
",",
"candidate2",
")",
":",
"delta1",
"=",
"candidate1",
"-",
"start",
"delta2",
"=",
"candidate2",
"-",
"start",
"return",
"cross_product",
"(",
"delta1",
",",
"delta2",
")"
] | Compare two relative changes by their cross-product.
This is meant to be a way to determine which vector is more "inside"
relative to ``start``.
.. note::
This is a helper for :func:`_simple_convex_hull`.
Args:
start (numpy.ndarray): The start vector (as 1D NumPy array with
... | [
"Compare",
"two",
"relative",
"changes",
"by",
"their",
"cross",
"-",
"product",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L248-L271 |
dhermes/bezier | src/bezier/_helpers.py | in_sorted | def in_sorted(values, value):
"""Checks if a value is in a sorted list.
Uses the :mod:`bisect` builtin to find the insertion point for
``value``.
Args:
values (List[int]): Integers sorted in ascending order.
value (int): Value to check if contained in ``values``.
Returns:
... | python | def in_sorted(values, value):
"""Checks if a value is in a sorted list.
Uses the :mod:`bisect` builtin to find the insertion point for
``value``.
Args:
values (List[int]): Integers sorted in ascending order.
value (int): Value to check if contained in ``values``.
Returns:
... | [
"def",
"in_sorted",
"(",
"values",
",",
"value",
")",
":",
"index",
"=",
"bisect",
".",
"bisect_left",
"(",
"values",
",",
"value",
")",
"if",
"index",
">=",
"len",
"(",
"values",
")",
":",
"return",
"False",
"return",
"values",
"[",
"index",
"]",
"=... | Checks if a value is in a sorted list.
Uses the :mod:`bisect` builtin to find the insertion point for
``value``.
Args:
values (List[int]): Integers sorted in ascending order.
value (int): Value to check if contained in ``values``.
Returns:
bool: Indicating if the value is cont... | [
"Checks",
"if",
"a",
"value",
"is",
"in",
"a",
"sorted",
"list",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L274-L291 |
dhermes/bezier | src/bezier/_helpers.py | _simple_convex_hull | def _simple_convex_hull(points):
r"""Compute the convex hull for a set of points.
.. _wikibooks: https://en.wikibooks.org/wiki/Algorithm_Implementation/\
Geometry/Convex_hull/Monotone_chain
This uses Andrew's monotone chain convex hull algorithm and this code
used a `wikibooks`_ imp... | python | def _simple_convex_hull(points):
r"""Compute the convex hull for a set of points.
.. _wikibooks: https://en.wikibooks.org/wiki/Algorithm_Implementation/\
Geometry/Convex_hull/Monotone_chain
This uses Andrew's monotone chain convex hull algorithm and this code
used a `wikibooks`_ imp... | [
"def",
"_simple_convex_hull",
"(",
"points",
")",
":",
"# NOTE: There is no corresponding \"enable\", but the disable only applies",
"# in this lexical scope.",
"# pylint: disable=too-many-branches",
"if",
"points",
".",
"size",
"==",
"0",
":",
"return",
"points",
"# First,... | r"""Compute the convex hull for a set of points.
.. _wikibooks: https://en.wikibooks.org/wiki/Algorithm_Implementation/\
Geometry/Convex_hull/Monotone_chain
This uses Andrew's monotone chain convex hull algorithm and this code
used a `wikibooks`_ implementation as motivation. tion. The ... | [
"r",
"Compute",
"the",
"convex",
"hull",
"for",
"a",
"set",
"of",
"points",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L294-L384 |
dhermes/bezier | src/bezier/_helpers.py | is_separating | def is_separating(direction, polygon1, polygon2):
"""Checks if a given ``direction`` is a separating line for two polygons.
.. note::
This is a helper for :func:`_polygon_collide`.
Args:
direction (numpy.ndarray): A 1D ``2``-array (``float64``) of a
potential separating line fo... | python | def is_separating(direction, polygon1, polygon2):
"""Checks if a given ``direction`` is a separating line for two polygons.
.. note::
This is a helper for :func:`_polygon_collide`.
Args:
direction (numpy.ndarray): A 1D ``2``-array (``float64``) of a
potential separating line fo... | [
"def",
"is_separating",
"(",
"direction",
",",
"polygon1",
",",
"polygon2",
")",
":",
"# NOTE: We assume throughout that ``norm_squared != 0``. If it **were**",
"# zero that would mean the ``direction`` corresponds to an",
"# invalid edge.",
"norm_squared",
"=",
"direction"... | Checks if a given ``direction`` is a separating line for two polygons.
.. note::
This is a helper for :func:`_polygon_collide`.
Args:
direction (numpy.ndarray): A 1D ``2``-array (``float64``) of a
potential separating line for the two polygons.
polygon1 (numpy.ndarray): A `... | [
"Checks",
"if",
"a",
"given",
"direction",
"is",
"a",
"separating",
"line",
"for",
"two",
"polygons",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L387-L424 |
dhermes/bezier | src/bezier/_helpers.py | _polygon_collide | def _polygon_collide(polygon1, polygon2):
"""Determines if two **convex** polygons collide.
.. _SAT: https://en.wikipedia.org/wiki/Hyperplane_separation_theorem
.. _see also: https://hackmd.io/s/ryFmIZrsl
This code uses the Separating axis theorem (`SAT`_) to quickly
determine if the polygons inte... | python | def _polygon_collide(polygon1, polygon2):
"""Determines if two **convex** polygons collide.
.. _SAT: https://en.wikipedia.org/wiki/Hyperplane_separation_theorem
.. _see also: https://hackmd.io/s/ryFmIZrsl
This code uses the Separating axis theorem (`SAT`_) to quickly
determine if the polygons inte... | [
"def",
"_polygon_collide",
"(",
"polygon1",
",",
"polygon2",
")",
":",
"direction",
"=",
"np",
".",
"empty",
"(",
"(",
"2",
",",
")",
",",
"order",
"=",
"\"F\"",
")",
"for",
"polygon",
"in",
"(",
"polygon1",
",",
"polygon2",
")",
":",
"_",
",",
"po... | Determines if two **convex** polygons collide.
.. _SAT: https://en.wikipedia.org/wiki/Hyperplane_separation_theorem
.. _see also: https://hackmd.io/s/ryFmIZrsl
This code uses the Separating axis theorem (`SAT`_) to quickly
determine if the polygons intersect. `See also`_.
.. note::
There ... | [
"Determines",
"if",
"two",
"**",
"convex",
"**",
"polygons",
"collide",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L427-L460 |
dhermes/bezier | src/bezier/_helpers.py | solve2x2 | def solve2x2(lhs, rhs):
"""Solve a square 2 x 2 system via LU factorization.
This is meant to be a stand-in for LAPACK's ``dgesv``, which just wraps
two calls to ``dgetrf`` and ``dgetrs``. We wrap for two reasons:
* We seek to avoid exceptions as part of the control flow (which is
what :func`num... | python | def solve2x2(lhs, rhs):
"""Solve a square 2 x 2 system via LU factorization.
This is meant to be a stand-in for LAPACK's ``dgesv``, which just wraps
two calls to ``dgetrf`` and ``dgetrs``. We wrap for two reasons:
* We seek to avoid exceptions as part of the control flow (which is
what :func`num... | [
"def",
"solve2x2",
"(",
"lhs",
",",
"rhs",
")",
":",
"# A <--> lhs[0, 0]",
"# B <--> lhs[0, 1]",
"# C <--> lhs[1, 0]",
"# D <--> lhs[1, 1]",
"# E <--> rhs[0]",
"# F <--> rhs[1]",
"if",
"np",
".",
"abs",
"(",
"lhs",
"[",
"1",
",",
"0",
"]",
")",
">",
"np",
".",... | Solve a square 2 x 2 system via LU factorization.
This is meant to be a stand-in for LAPACK's ``dgesv``, which just wraps
two calls to ``dgetrf`` and ``dgetrs``. We wrap for two reasons:
* We seek to avoid exceptions as part of the control flow (which is
what :func`numpy.linalg.solve` does).
* W... | [
"Solve",
"a",
"square",
"2",
"x",
"2",
"system",
"via",
"LU",
"factorization",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L463-L528 |
dhermes/bezier | src/bezier/_plot_helpers.py | add_plot_boundary | def add_plot_boundary(ax, padding=0.125):
"""Add a buffer of empty space around a plot boundary.
.. note::
This only uses ``line`` data from the axis. It **could**
use ``patch`` data, but doesn't at this time.
Args:
ax (matplotlib.artist.Artist): A matplotlib axis.
padding (... | python | def add_plot_boundary(ax, padding=0.125):
"""Add a buffer of empty space around a plot boundary.
.. note::
This only uses ``line`` data from the axis. It **could**
use ``patch`` data, but doesn't at this time.
Args:
ax (matplotlib.artist.Artist): A matplotlib axis.
padding (... | [
"def",
"add_plot_boundary",
"(",
"ax",
",",
"padding",
"=",
"0.125",
")",
":",
"nodes",
"=",
"np",
".",
"asfortranarray",
"(",
"np",
".",
"vstack",
"(",
"[",
"line",
".",
"get_xydata",
"(",
")",
"for",
"line",
"in",
"ax",
".",
"lines",
"]",
")",
".... | Add a buffer of empty space around a plot boundary.
.. note::
This only uses ``line`` data from the axis. It **could**
use ``patch`` data, but doesn't at this time.
Args:
ax (matplotlib.artist.Artist): A matplotlib axis.
padding (Optional[float]): Amount (as a fraction of width ... | [
"Add",
"a",
"buffer",
"of",
"empty",
"space",
"around",
"a",
"plot",
"boundary",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_plot_helpers.py#L34-L61 |
dhermes/bezier | src/bezier/_plot_helpers.py | add_patch | def add_patch(ax, color, pts_per_edge, *edges):
"""Add a polygonal surface patch to a plot.
Args:
ax (matplotlib.artist.Artist): A matplotlib axis.
color (Tuple[float, float, float]): Color as RGB profile.
pts_per_edge (int): Number of points to use in polygonal
approximatio... | python | def add_patch(ax, color, pts_per_edge, *edges):
"""Add a polygonal surface patch to a plot.
Args:
ax (matplotlib.artist.Artist): A matplotlib axis.
color (Tuple[float, float, float]): Color as RGB profile.
pts_per_edge (int): Number of points to use in polygonal
approximatio... | [
"def",
"add_patch",
"(",
"ax",
",",
"color",
",",
"pts_per_edge",
",",
"*",
"edges",
")",
":",
"from",
"matplotlib",
"import",
"patches",
"from",
"matplotlib",
"import",
"path",
"as",
"_path_mod",
"s_vals",
"=",
"np",
".",
"linspace",
"(",
"0.0",
",",
"1... | Add a polygonal surface patch to a plot.
Args:
ax (matplotlib.artist.Artist): A matplotlib axis.
color (Tuple[float, float, float]): Color as RGB profile.
pts_per_edge (int): Number of points to use in polygonal
approximation of edge.
edges (Tuple[~bezier.curve.Curve, ..... | [
"Add",
"a",
"polygonal",
"surface",
"patch",
"to",
"a",
"plot",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_plot_helpers.py#L64-L98 |
dhermes/bezier | docs/custom_html_writer.py | CustomHTMLWriter.visit_literal_block | def visit_literal_block(self, node):
"""Visit a ``literal_block`` node.
This verifies the state of each literal / code block.
"""
language = node.attributes.get("language", "")
test_type = node.attributes.get("testnodetype", "")
if test_type != "doctest":
if ... | python | def visit_literal_block(self, node):
"""Visit a ``literal_block`` node.
This verifies the state of each literal / code block.
"""
language = node.attributes.get("language", "")
test_type = node.attributes.get("testnodetype", "")
if test_type != "doctest":
if ... | [
"def",
"visit_literal_block",
"(",
"self",
",",
"node",
")",
":",
"language",
"=",
"node",
".",
"attributes",
".",
"get",
"(",
"\"language\"",
",",
"\"\"",
")",
"test_type",
"=",
"node",
".",
"attributes",
".",
"get",
"(",
"\"testnodetype\"",
",",
"\"\"",
... | Visit a ``literal_block`` node.
This verifies the state of each literal / code block. | [
"Visit",
"a",
"literal_block",
"node",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/docs/custom_html_writer.py#L42-L57 |
dhermes/bezier | src/bezier/_geometric_intersection.py | _bbox_intersect | def _bbox_intersect(nodes1, nodes2):
r"""Bounding box intersection predicate.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Determines if the bounding box of two sets of control points
intersects in :math:`\mathbf{R}^2` with no... | python | def _bbox_intersect(nodes1, nodes2):
r"""Bounding box intersection predicate.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Determines if the bounding box of two sets of control points
intersects in :math:`\mathbf{R}^2` with no... | [
"def",
"_bbox_intersect",
"(",
"nodes1",
",",
"nodes2",
")",
":",
"left1",
",",
"right1",
",",
"bottom1",
",",
"top1",
"=",
"_helpers",
".",
"bbox",
"(",
"nodes1",
")",
"left2",
",",
"right2",
",",
"bottom2",
",",
"top2",
"=",
"_helpers",
".",
"bbox",
... | r"""Bounding box intersection predicate.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Determines if the bounding box of two sets of control points
intersects in :math:`\mathbf{R}^2` with non-trivial
intersection (i.e. tangent ... | [
"r",
"Bounding",
"box",
"intersection",
"predicate",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L63-L104 |
dhermes/bezier | src/bezier/_geometric_intersection.py | linearization_error | def linearization_error(nodes):
r"""Compute the maximum error of a linear approximation.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
.. note::
This is a helper for :class:`.Linearization`, which is used during the
... | python | def linearization_error(nodes):
r"""Compute the maximum error of a linear approximation.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
.. note::
This is a helper for :class:`.Linearization`, which is used during the
... | [
"def",
"linearization_error",
"(",
"nodes",
")",
":",
"_",
",",
"num_nodes",
"=",
"nodes",
".",
"shape",
"degree",
"=",
"num_nodes",
"-",
"1",
"if",
"degree",
"==",
"1",
":",
"return",
"0.0",
"second_deriv",
"=",
"nodes",
"[",
":",
",",
":",
"-",
"2"... | r"""Compute the maximum error of a linear approximation.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
.. note::
This is a helper for :class:`.Linearization`, which is used during the
curve-curve intersection process.
... | [
"r",
"Compute",
"the",
"maximum",
"error",
"of",
"a",
"linear",
"approximation",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L107-L254 |
dhermes/bezier | src/bezier/_geometric_intersection.py | segment_intersection | def segment_intersection(start0, end0, start1, end1):
r"""Determine the intersection of two line segments.
Assumes each line is parametric
.. math::
\begin{alignat*}{2}
L_0(s) &= S_0 (1 - s) + E_0 s &&= S_0 + s \Delta_0 \\
L_1(t) &= S_1 (1 - t) + E_1 t &&= S_1 + t \Delta_1.
... | python | def segment_intersection(start0, end0, start1, end1):
r"""Determine the intersection of two line segments.
Assumes each line is parametric
.. math::
\begin{alignat*}{2}
L_0(s) &= S_0 (1 - s) + E_0 s &&= S_0 + s \Delta_0 \\
L_1(t) &= S_1 (1 - t) + E_1 t &&= S_1 + t \Delta_1.
... | [
"def",
"segment_intersection",
"(",
"start0",
",",
"end0",
",",
"start1",
",",
"end1",
")",
":",
"delta0",
"=",
"end0",
"-",
"start0",
"delta1",
"=",
"end1",
"-",
"start1",
"cross_d0_d1",
"=",
"_helpers",
".",
"cross_product",
"(",
"delta0",
",",
"delta1",... | r"""Determine the intersection of two line segments.
Assumes each line is parametric
.. math::
\begin{alignat*}{2}
L_0(s) &= S_0 (1 - s) + E_0 s &&= S_0 + s \Delta_0 \\
L_1(t) &= S_1 (1 - t) + E_1 t &&= S_1 + t \Delta_1.
\end{alignat*}
To solve :math:`S_0 + s \Delta_0 = S_1... | [
"r",
"Determine",
"the",
"intersection",
"of",
"two",
"line",
"segments",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L257-L420 |
dhermes/bezier | src/bezier/_geometric_intersection.py | parallel_lines_parameters | def parallel_lines_parameters(start0, end0, start1, end1):
r"""Checks if two parallel lines ever meet.
Meant as a back-up when :func:`segment_intersection` fails.
.. note::
This function assumes but never verifies that the lines
are parallel.
In the case that the segments are parallel ... | python | def parallel_lines_parameters(start0, end0, start1, end1):
r"""Checks if two parallel lines ever meet.
Meant as a back-up when :func:`segment_intersection` fails.
.. note::
This function assumes but never verifies that the lines
are parallel.
In the case that the segments are parallel ... | [
"def",
"parallel_lines_parameters",
"(",
"start0",
",",
"end0",
",",
"start1",
",",
"end1",
")",
":",
"# NOTE: There is no corresponding \"enable\", but the disable only applies",
"# in this lexical scope.",
"# pylint: disable=too-many-branches",
"delta0",
"=",
"end0",
"-",... | r"""Checks if two parallel lines ever meet.
Meant as a back-up when :func:`segment_intersection` fails.
.. note::
This function assumes but never verifies that the lines
are parallel.
In the case that the segments are parallel and lie on **different**
lines, then there is a **guarantee... | [
"r",
"Checks",
"if",
"two",
"parallel",
"lines",
"ever",
"meet",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L423-L676 |
dhermes/bezier | src/bezier/_geometric_intersection.py | line_line_collide | def line_line_collide(line1, line2):
"""Determine if two line segments meet.
This is a helper for :func:`convex_hull_collide` in the
special case that the two convex hulls are actually
just line segments. (Even in this case, this is only
problematic if both segments are on a single line.)
Args... | python | def line_line_collide(line1, line2):
"""Determine if two line segments meet.
This is a helper for :func:`convex_hull_collide` in the
special case that the two convex hulls are actually
just line segments. (Even in this case, this is only
problematic if both segments are on a single line.)
Args... | [
"def",
"line_line_collide",
"(",
"line1",
",",
"line2",
")",
":",
"s",
",",
"t",
",",
"success",
"=",
"segment_intersection",
"(",
"line1",
"[",
":",
",",
"0",
"]",
",",
"line1",
"[",
":",
",",
"1",
"]",
",",
"line2",
"[",
":",
",",
"0",
"]",
"... | Determine if two line segments meet.
This is a helper for :func:`convex_hull_collide` in the
special case that the two convex hulls are actually
just line segments. (Even in this case, this is only
problematic if both segments are on a single line.)
Args:
line1 (numpy.ndarray): ``2 x 2`` a... | [
"Determine",
"if",
"two",
"line",
"segments",
"meet",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L679-L706 |
dhermes/bezier | src/bezier/_geometric_intersection.py | convex_hull_collide | def convex_hull_collide(nodes1, nodes2):
"""Determine if the convex hulls of two curves collide.
.. note::
This is a helper for :func:`from_linearized`.
Args:
nodes1 (numpy.ndarray): Control points of a first curve.
nodes2 (numpy.ndarray): Control points of a second curve.
Ret... | python | def convex_hull_collide(nodes1, nodes2):
"""Determine if the convex hulls of two curves collide.
.. note::
This is a helper for :func:`from_linearized`.
Args:
nodes1 (numpy.ndarray): Control points of a first curve.
nodes2 (numpy.ndarray): Control points of a second curve.
Ret... | [
"def",
"convex_hull_collide",
"(",
"nodes1",
",",
"nodes2",
")",
":",
"polygon1",
"=",
"_helpers",
".",
"simple_convex_hull",
"(",
"nodes1",
")",
"_",
",",
"polygon_size1",
"=",
"polygon1",
".",
"shape",
"polygon2",
"=",
"_helpers",
".",
"simple_convex_hull",
... | Determine if the convex hulls of two curves collide.
.. note::
This is a helper for :func:`from_linearized`.
Args:
nodes1 (numpy.ndarray): Control points of a first curve.
nodes2 (numpy.ndarray): Control points of a second curve.
Returns:
bool: Indicating if the convex hul... | [
"Determine",
"if",
"the",
"convex",
"hulls",
"of",
"two",
"curves",
"collide",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L709-L731 |
dhermes/bezier | src/bezier/_geometric_intersection.py | from_linearized | def from_linearized(first, second, intersections):
"""Determine curve-curve intersection from pair of linearizations.
.. note::
This assumes that at least one of ``first`` and ``second`` is
not a line. The line-line case should be handled "early"
by :func:`check_lines`.
.. note::
... | python | def from_linearized(first, second, intersections):
"""Determine curve-curve intersection from pair of linearizations.
.. note::
This assumes that at least one of ``first`` and ``second`` is
not a line. The line-line case should be handled "early"
by :func:`check_lines`.
.. note::
... | [
"def",
"from_linearized",
"(",
"first",
",",
"second",
",",
"intersections",
")",
":",
"# NOTE: There is no corresponding \"enable\", but the disable only applies",
"# in this lexical scope.",
"# pylint: disable=too-many-return-statements",
"s",
",",
"t",
",",
"success",
"=... | Determine curve-curve intersection from pair of linearizations.
.. note::
This assumes that at least one of ``first`` and ``second`` is
not a line. The line-line case should be handled "early"
by :func:`check_lines`.
.. note::
This assumes the caller has verified that the boundin... | [
"Determine",
"curve",
"-",
"curve",
"intersection",
"from",
"pair",
"of",
"linearizations",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L734-L805 |
dhermes/bezier | src/bezier/_geometric_intersection.py | add_intersection | def add_intersection(s, t, intersections):
r"""Adds an intersection to list of ``intersections``.
.. note::
This is a helper for :func:`from_linearized` and :func:`endpoint_check`.
These functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively, and that functi... | python | def add_intersection(s, t, intersections):
r"""Adds an intersection to list of ``intersections``.
.. note::
This is a helper for :func:`from_linearized` and :func:`endpoint_check`.
These functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively, and that functi... | [
"def",
"add_intersection",
"(",
"s",
",",
"t",
",",
"intersections",
")",
":",
"if",
"not",
"intersections",
":",
"intersections",
".",
"append",
"(",
"(",
"s",
",",
"t",
")",
")",
"return",
"if",
"s",
"<",
"_intersection_helpers",
".",
"ZERO_THRESHOLD",
... | r"""Adds an intersection to list of ``intersections``.
.. note::
This is a helper for :func:`from_linearized` and :func:`endpoint_check`.
These functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively, and that function has a
Fortran equivalent.
Accoun... | [
"r",
"Adds",
"an",
"intersection",
"to",
"list",
"of",
"intersections",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L808-L868 |
dhermes/bezier | src/bezier/_geometric_intersection.py | endpoint_check | def endpoint_check(
first, node_first, s, second, node_second, t, intersections
):
r"""Check if curve endpoints are identical.
.. note::
This is a helper for :func:`tangent_bbox_intersection`. These
functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively,... | python | def endpoint_check(
first, node_first, s, second, node_second, t, intersections
):
r"""Check if curve endpoints are identical.
.. note::
This is a helper for :func:`tangent_bbox_intersection`. These
functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively,... | [
"def",
"endpoint_check",
"(",
"first",
",",
"node_first",
",",
"s",
",",
"second",
",",
"node_second",
",",
"t",
",",
"intersections",
")",
":",
"if",
"_helpers",
".",
"vector_close",
"(",
"node_first",
",",
"node_second",
")",
":",
"orig_s",
"=",
"(",
"... | r"""Check if curve endpoints are identical.
.. note::
This is a helper for :func:`tangent_bbox_intersection`. These
functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively, and that function has a
Fortran equivalent.
Args:
first (SubdividedCur... | [
"r",
"Check",
"if",
"curve",
"endpoints",
"are",
"identical",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L871-L903 |
dhermes/bezier | src/bezier/_geometric_intersection.py | tangent_bbox_intersection | def tangent_bbox_intersection(first, second, intersections):
r"""Check if two curves with tangent bounding boxes intersect.
.. note::
This is a helper for :func:`intersect_one_round`. These
functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively, and that fun... | python | def tangent_bbox_intersection(first, second, intersections):
r"""Check if two curves with tangent bounding boxes intersect.
.. note::
This is a helper for :func:`intersect_one_round`. These
functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively, and that fun... | [
"def",
"tangent_bbox_intersection",
"(",
"first",
",",
"second",
",",
"intersections",
")",
":",
"node_first1",
"=",
"first",
".",
"nodes",
"[",
":",
",",
"0",
"]",
"node_first2",
"=",
"first",
".",
"nodes",
"[",
":",
",",
"-",
"1",
"]",
"node_second1",
... | r"""Check if two curves with tangent bounding boxes intersect.
.. note::
This is a helper for :func:`intersect_one_round`. These
functions are used (directly or indirectly) by
:func:`_all_intersections` exclusively, and that function has a
Fortran equivalent.
If the bounding boxes... | [
"r",
"Check",
"if",
"two",
"curves",
"with",
"tangent",
"bounding",
"boxes",
"intersect",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L906-L970 |
dhermes/bezier | src/bezier/_geometric_intersection.py | bbox_line_intersect | def bbox_line_intersect(nodes, line_start, line_end):
r"""Determine intersection of a bounding box and a line.
We do this by first checking if either the start or end node of the
segment are contained in the bounding box. If they aren't, then
checks if the line segment intersects any of the four sides ... | python | def bbox_line_intersect(nodes, line_start, line_end):
r"""Determine intersection of a bounding box and a line.
We do this by first checking if either the start or end node of the
segment are contained in the bounding box. If they aren't, then
checks if the line segment intersects any of the four sides ... | [
"def",
"bbox_line_intersect",
"(",
"nodes",
",",
"line_start",
",",
"line_end",
")",
":",
"left",
",",
"right",
",",
"bottom",
",",
"top",
"=",
"_helpers",
".",
"bbox",
"(",
"nodes",
")",
"if",
"_helpers",
".",
"in_interval",
"(",
"line_start",
"[",
"0",... | r"""Determine intersection of a bounding box and a line.
We do this by first checking if either the start or end node of the
segment are contained in the bounding box. If they aren't, then
checks if the line segment intersects any of the four sides of the
bounding box.
.. note::
This funct... | [
"r",
"Determine",
"intersection",
"of",
"a",
"bounding",
"box",
"and",
"a",
"line",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L973-L1066 |
dhermes/bezier | src/bezier/_geometric_intersection.py | intersect_one_round | def intersect_one_round(candidates, intersections):
"""Perform one step of the intersection process.
.. note::
This is a helper for :func:`_all_intersections` and that function
has a Fortran equivalent.
Checks if the bounding boxes of each pair in ``candidates``
intersect. If the boundi... | python | def intersect_one_round(candidates, intersections):
"""Perform one step of the intersection process.
.. note::
This is a helper for :func:`_all_intersections` and that function
has a Fortran equivalent.
Checks if the bounding boxes of each pair in ``candidates``
intersect. If the boundi... | [
"def",
"intersect_one_round",
"(",
"candidates",
",",
"intersections",
")",
":",
"next_candidates",
"=",
"[",
"]",
"# NOTE: In the below we replace ``isinstance(a, B)`` with",
"# ``a.__class__ is B``, which is a 3-3.5x speedup.",
"for",
"first",
",",
"second",
"in",
"cand... | Perform one step of the intersection process.
.. note::
This is a helper for :func:`_all_intersections` and that function
has a Fortran equivalent.
Checks if the bounding boxes of each pair in ``candidates``
intersect. If the bounding boxes do not intersect, the pair
is discarded. Other... | [
"Perform",
"one",
"step",
"of",
"the",
"intersection",
"process",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L1069-L1142 |
dhermes/bezier | src/bezier/_geometric_intersection.py | prune_candidates | def prune_candidates(candidates):
"""Reduce number of candidate intersection pairs.
.. note::
This is a helper for :func:`_all_intersections`.
Uses more strict bounding box intersection predicate by forming the
actual convex hull of each candidate curve segment and then checking
if those c... | python | def prune_candidates(candidates):
"""Reduce number of candidate intersection pairs.
.. note::
This is a helper for :func:`_all_intersections`.
Uses more strict bounding box intersection predicate by forming the
actual convex hull of each candidate curve segment and then checking
if those c... | [
"def",
"prune_candidates",
"(",
"candidates",
")",
":",
"pruned",
"=",
"[",
"]",
"# NOTE: In the below we replace ``isinstance(a, B)`` with",
"# ``a.__class__ is B``, which is a 3-3.5x speedup.",
"for",
"first",
",",
"second",
"in",
"candidates",
":",
"if",
"first",
"... | Reduce number of candidate intersection pairs.
.. note::
This is a helper for :func:`_all_intersections`.
Uses more strict bounding box intersection predicate by forming the
actual convex hull of each candidate curve segment and then checking
if those convex hulls collide.
Args:
c... | [
"Reduce",
"number",
"of",
"candidate",
"intersection",
"pairs",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L1145-L1177 |
dhermes/bezier | src/bezier/_geometric_intersection.py | make_same_degree | def make_same_degree(nodes1, nodes2):
"""Degree-elevate a curve so two curves have matching degree.
Args:
nodes1 (numpy.ndarray): Set of control points for a
B |eacute| zier curve.
nodes2 (numpy.ndarray): Set of control points for a
B |eacute| zier curve.
Returns:
... | python | def make_same_degree(nodes1, nodes2):
"""Degree-elevate a curve so two curves have matching degree.
Args:
nodes1 (numpy.ndarray): Set of control points for a
B |eacute| zier curve.
nodes2 (numpy.ndarray): Set of control points for a
B |eacute| zier curve.
Returns:
... | [
"def",
"make_same_degree",
"(",
"nodes1",
",",
"nodes2",
")",
":",
"_",
",",
"num_nodes1",
"=",
"nodes1",
".",
"shape",
"_",
",",
"num_nodes2",
"=",
"nodes2",
".",
"shape",
"for",
"_",
"in",
"six",
".",
"moves",
".",
"xrange",
"(",
"num_nodes2",
"-",
... | Degree-elevate a curve so two curves have matching degree.
Args:
nodes1 (numpy.ndarray): Set of control points for a
B |eacute| zier curve.
nodes2 (numpy.ndarray): Set of control points for a
B |eacute| zier curve.
Returns:
Tuple[numpy.ndarray, numpy.ndarray]: T... | [
"Degree",
"-",
"elevate",
"a",
"curve",
"so",
"two",
"curves",
"have",
"matching",
"degree",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L1180-L1199 |
dhermes/bezier | src/bezier/_geometric_intersection.py | coincident_parameters | def coincident_parameters(nodes1, nodes2):
r"""Check if two B |eacute| zier curves are coincident.
Does so by projecting each segment endpoint onto the other curve
.. math::
B_1(s_0) = B_2(0)
B_1(s_m) = B_2(1)
B_1(0) = B_2(t_0)
B_1(1) = B_2(t_n)
and then finding the "shar... | python | def coincident_parameters(nodes1, nodes2):
r"""Check if two B |eacute| zier curves are coincident.
Does so by projecting each segment endpoint onto the other curve
.. math::
B_1(s_0) = B_2(0)
B_1(s_m) = B_2(1)
B_1(0) = B_2(t_0)
B_1(1) = B_2(t_n)
and then finding the "shar... | [
"def",
"coincident_parameters",
"(",
"nodes1",
",",
"nodes2",
")",
":",
"# NOTE: There is no corresponding \"enable\", but the disable only applies",
"# in this lexical scope.",
"# pylint: disable=too-many-return-statements,too-many-branches",
"nodes1",
",",
"nodes2",
"=",
"make_... | r"""Check if two B |eacute| zier curves are coincident.
Does so by projecting each segment endpoint onto the other curve
.. math::
B_1(s_0) = B_2(0)
B_1(s_m) = B_2(1)
B_1(0) = B_2(t_0)
B_1(1) = B_2(t_n)
and then finding the "shared interval" where both curves are defined.
... | [
"r",
"Check",
"if",
"two",
"B",
"|eacute|",
"zier",
"curves",
"are",
"coincident",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L1202-L1334 |
dhermes/bezier | src/bezier/_geometric_intersection.py | check_lines | def check_lines(first, second):
"""Checks if two curves are lines and tries to intersect them.
.. note::
This is a helper for :func:`._all_intersections`.
If they are not lines / not linearized, immediately returns :data:`False`
with no "return value".
If they are lines, attempts to inter... | python | def check_lines(first, second):
"""Checks if two curves are lines and tries to intersect them.
.. note::
This is a helper for :func:`._all_intersections`.
If they are not lines / not linearized, immediately returns :data:`False`
with no "return value".
If they are lines, attempts to inter... | [
"def",
"check_lines",
"(",
"first",
",",
"second",
")",
":",
"# NOTE: In the below we replace ``isinstance(a, B)`` with",
"# ``a.__class__ is B``, which is a 3-3.5x speedup.",
"if",
"not",
"(",
"first",
".",
"__class__",
"is",
"Linearization",
"and",
"second",
".",
"_... | Checks if two curves are lines and tries to intersect them.
.. note::
This is a helper for :func:`._all_intersections`.
If they are not lines / not linearized, immediately returns :data:`False`
with no "return value".
If they are lines, attempts to intersect them (even if they are parallel
... | [
"Checks",
"if",
"two",
"curves",
"are",
"lines",
"and",
"tries",
"to",
"intersect",
"them",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L1337-L1398 |
dhermes/bezier | src/bezier/_geometric_intersection.py | _all_intersections | def _all_intersections(nodes_first, nodes_second):
r"""Find the points of intersection among a pair of curves.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
.. note::
This assumes both curves are in :math:`\mathbf{R}^2`, bu... | python | def _all_intersections(nodes_first, nodes_second):
r"""Find the points of intersection among a pair of curves.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
.. note::
This assumes both curves are in :math:`\mathbf{R}^2`, bu... | [
"def",
"_all_intersections",
"(",
"nodes_first",
",",
"nodes_second",
")",
":",
"curve_first",
"=",
"SubdividedCurve",
"(",
"nodes_first",
",",
"nodes_first",
")",
"curve_second",
"=",
"SubdividedCurve",
"(",
"nodes_second",
",",
"nodes_second",
")",
"candidate1",
"... | r"""Find the points of intersection among a pair of curves.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
.. note::
This assumes both curves are in :math:`\mathbf{R}^2`, but does not
**explicitly** check this. However, f... | [
"r",
"Find",
"the",
"points",
"of",
"intersection",
"among",
"a",
"pair",
"of",
"curves",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L1401-L1482 |
dhermes/bezier | src/bezier/_geometric_intersection.py | SubdividedCurve.subdivide | def subdivide(self):
"""Split the curve into a left and right half.
See :meth:`.Curve.subdivide` for more information.
Returns:
Tuple[SubdividedCurve, SubdividedCurve]: The left and right
sub-curves.
"""
left_nodes, right_nodes = _curve_helpers.subdivide... | python | def subdivide(self):
"""Split the curve into a left and right half.
See :meth:`.Curve.subdivide` for more information.
Returns:
Tuple[SubdividedCurve, SubdividedCurve]: The left and right
sub-curves.
"""
left_nodes, right_nodes = _curve_helpers.subdivide... | [
"def",
"subdivide",
"(",
"self",
")",
":",
"left_nodes",
",",
"right_nodes",
"=",
"_curve_helpers",
".",
"subdivide_nodes",
"(",
"self",
".",
"nodes",
")",
"midpoint",
"=",
"0.5",
"*",
"(",
"self",
".",
"start",
"+",
"self",
".",
"end",
")",
"left",
"=... | Split the curve into a left and right half.
See :meth:`.Curve.subdivide` for more information.
Returns:
Tuple[SubdividedCurve, SubdividedCurve]: The left and right
sub-curves. | [
"Split",
"the",
"curve",
"into",
"a",
"left",
"and",
"right",
"half",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L1543-L1560 |
dhermes/bezier | src/bezier/_geometric_intersection.py | Linearization.from_shape | def from_shape(cls, shape):
"""Try to linearize a curve (or an already linearized curve).
Args:
shape (Union[SubdividedCurve, \
~bezier._geometric_intersection.Linearization]): A curve or an
already linearized curve.
Returns:
Union[Subdivided... | python | def from_shape(cls, shape):
"""Try to linearize a curve (or an already linearized curve).
Args:
shape (Union[SubdividedCurve, \
~bezier._geometric_intersection.Linearization]): A curve or an
already linearized curve.
Returns:
Union[Subdivided... | [
"def",
"from_shape",
"(",
"cls",
",",
"shape",
")",
":",
"# NOTE: In the below we replace ``isinstance(a, B)`` with",
"# ``a.__class__ is B``, which is a 3-3.5x speedup.",
"if",
"shape",
".",
"__class__",
"is",
"cls",
":",
"return",
"shape",
"else",
":",
"error",
"=... | Try to linearize a curve (or an already linearized curve).
Args:
shape (Union[SubdividedCurve, \
~bezier._geometric_intersection.Linearization]): A curve or an
already linearized curve.
Returns:
Union[SubdividedCurve, \
~bezier._geometric... | [
"Try",
"to",
"linearize",
"a",
"curve",
"(",
"or",
"an",
"already",
"linearized",
"curve",
")",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_geometric_intersection.py#L1615-L1640 |
dhermes/bezier | src/bezier/curve.py | Curve.evaluate | def evaluate(self, s):
r"""Evaluate :math:`B(s)` along the curve.
This method acts as a (partial) inverse to :meth:`locate`.
See :meth:`evaluate_multi` for more details.
.. image:: ../../images/curve_evaluate.png
:align: center
.. doctest:: curve-eval
:o... | python | def evaluate(self, s):
r"""Evaluate :math:`B(s)` along the curve.
This method acts as a (partial) inverse to :meth:`locate`.
See :meth:`evaluate_multi` for more details.
.. image:: ../../images/curve_evaluate.png
:align: center
.. doctest:: curve-eval
:o... | [
"def",
"evaluate",
"(",
"self",
",",
"s",
")",
":",
"return",
"_curve_helpers",
".",
"evaluate_multi",
"(",
"self",
".",
"_nodes",
",",
"np",
".",
"asfortranarray",
"(",
"[",
"s",
"]",
")",
")"
] | r"""Evaluate :math:`B(s)` along the curve.
This method acts as a (partial) inverse to :meth:`locate`.
See :meth:`evaluate_multi` for more details.
.. image:: ../../images/curve_evaluate.png
:align: center
.. doctest:: curve-eval
:options: +NORMALIZE_WHITESPACE
... | [
"r",
"Evaluate",
":",
"math",
":",
"B",
"(",
"s",
")",
"along",
"the",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L173-L209 |
dhermes/bezier | src/bezier/curve.py | Curve.plot | def plot(self, num_pts, color=None, alpha=None, ax=None):
"""Plot the current curve.
Args:
num_pts (int): Number of points to plot.
color (Optional[Tuple[float, float, float]]): Color as RGB profile.
alpha (Optional[float]): The alpha channel for the color.
... | python | def plot(self, num_pts, color=None, alpha=None, ax=None):
"""Plot the current curve.
Args:
num_pts (int): Number of points to plot.
color (Optional[Tuple[float, float, float]]): Color as RGB profile.
alpha (Optional[float]): The alpha channel for the color.
... | [
"def",
"plot",
"(",
"self",
",",
"num_pts",
",",
"color",
"=",
"None",
",",
"alpha",
"=",
"None",
",",
"ax",
"=",
"None",
")",
":",
"if",
"self",
".",
"_dimension",
"!=",
"2",
":",
"raise",
"NotImplementedError",
"(",
"\"2D is the only supported dimension\... | Plot the current curve.
Args:
num_pts (int): Number of points to plot.
color (Optional[Tuple[float, float, float]]): Color as RGB profile.
alpha (Optional[float]): The alpha channel for the color.
ax (Optional[matplotlib.artist.Artist]): matplotlib axis object
... | [
"Plot",
"the",
"current",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L245-L274 |
dhermes/bezier | src/bezier/curve.py | Curve.subdivide | def subdivide(self):
r"""Split the curve :math:`B(s)` into a left and right half.
Takes the interval :math:`\left[0, 1\right]` and splits the curve into
:math:`B_1 = B\left(\left[0, \frac{1}{2}\right]\right)` and
:math:`B_2 = B\left(\left[\frac{1}{2}, 1\right]\right)`. In
order ... | python | def subdivide(self):
r"""Split the curve :math:`B(s)` into a left and right half.
Takes the interval :math:`\left[0, 1\right]` and splits the curve into
:math:`B_1 = B\left(\left[0, \frac{1}{2}\right]\right)` and
:math:`B_2 = B\left(\left[\frac{1}{2}, 1\right]\right)`. In
order ... | [
"def",
"subdivide",
"(",
"self",
")",
":",
"left_nodes",
",",
"right_nodes",
"=",
"_curve_helpers",
".",
"subdivide_nodes",
"(",
"self",
".",
"_nodes",
")",
"left",
"=",
"Curve",
"(",
"left_nodes",
",",
"self",
".",
"_degree",
",",
"_copy",
"=",
"False",
... | r"""Split the curve :math:`B(s)` into a left and right half.
Takes the interval :math:`\left[0, 1\right]` and splits the curve into
:math:`B_1 = B\left(\left[0, \frac{1}{2}\right]\right)` and
:math:`B_2 = B\left(\left[\frac{1}{2}, 1\right]\right)`. In
order to do this, also reparameteri... | [
"r",
"Split",
"the",
"curve",
":",
"math",
":",
"B",
"(",
"s",
")",
"into",
"a",
"left",
"and",
"right",
"half",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L276-L315 |
dhermes/bezier | src/bezier/curve.py | Curve.intersect | def intersect(
self, other, strategy=IntersectionStrategy.GEOMETRIC, _verify=True
):
"""Find the points of intersection with another curve.
See :doc:`../../algorithms/curve-curve-intersection` for more details.
.. image:: ../../images/curve_intersect.png
:align: center
... | python | def intersect(
self, other, strategy=IntersectionStrategy.GEOMETRIC, _verify=True
):
"""Find the points of intersection with another curve.
See :doc:`../../algorithms/curve-curve-intersection` for more details.
.. image:: ../../images/curve_intersect.png
:align: center
... | [
"def",
"intersect",
"(",
"self",
",",
"other",
",",
"strategy",
"=",
"IntersectionStrategy",
".",
"GEOMETRIC",
",",
"_verify",
"=",
"True",
")",
":",
"if",
"_verify",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Curve",
")",
":",
"raise",
"TypeErr... | Find the points of intersection with another curve.
See :doc:`../../algorithms/curve-curve-intersection` for more details.
.. image:: ../../images/curve_intersect.png
:align: center
.. doctest:: curve-intersect
:options: +NORMALIZE_WHITESPACE
>>> nodes1 = np.... | [
"Find",
"the",
"points",
"of",
"intersection",
"with",
"another",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L317-L393 |
dhermes/bezier | src/bezier/curve.py | Curve.elevate | def elevate(self):
r"""Return a degree-elevated version of the current curve.
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n + 1}` where
.. math::
\begin{align*}
w_0 &= v_0 \\
w_j &= \frac{j}{n ... | python | def elevate(self):
r"""Return a degree-elevated version of the current curve.
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n + 1}` where
.. math::
\begin{align*}
w_0 &= v_0 \\
w_j &= \frac{j}{n ... | [
"def",
"elevate",
"(",
"self",
")",
":",
"new_nodes",
"=",
"_curve_helpers",
".",
"elevate_nodes",
"(",
"self",
".",
"_nodes",
")",
"return",
"Curve",
"(",
"new_nodes",
",",
"self",
".",
"_degree",
"+",
"1",
",",
"_copy",
"=",
"False",
")"
] | r"""Return a degree-elevated version of the current curve.
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n + 1}` where
.. math::
\begin{align*}
w_0 &= v_0 \\
w_j &= \frac{j}{n + 1} v_{j - 1} + \frac{n + ... | [
"r",
"Return",
"a",
"degree",
"-",
"elevated",
"version",
"of",
"the",
"current",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L395-L441 |
dhermes/bezier | src/bezier/curve.py | Curve.reduce_ | def reduce_(self):
r"""Return a degree-reduced version of the current curve.
.. _pseudo-inverse:
https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_pseudoinverse
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n - 1}` ... | python | def reduce_(self):
r"""Return a degree-reduced version of the current curve.
.. _pseudo-inverse:
https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_pseudoinverse
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n - 1}` ... | [
"def",
"reduce_",
"(",
"self",
")",
":",
"new_nodes",
"=",
"_curve_helpers",
".",
"reduce_pseudo_inverse",
"(",
"self",
".",
"_nodes",
")",
"return",
"Curve",
"(",
"new_nodes",
",",
"self",
".",
"_degree",
"-",
"1",
",",
"_copy",
"=",
"False",
")"
] | r"""Return a degree-reduced version of the current curve.
.. _pseudo-inverse:
https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_pseudoinverse
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n - 1}` that correspond to
... | [
"r",
"Return",
"a",
"degree",
"-",
"reduced",
"version",
"of",
"the",
"current",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L443-L538 |
dhermes/bezier | src/bezier/curve.py | Curve.specialize | def specialize(self, start, end):
"""Specialize the curve to a given sub-interval.
.. image:: ../../images/curve_specialize.png
:align: center
.. doctest:: curve-specialize
>>> nodes = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, ... | python | def specialize(self, start, end):
"""Specialize the curve to a given sub-interval.
.. image:: ../../images/curve_specialize.png
:align: center
.. doctest:: curve-specialize
>>> nodes = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, ... | [
"def",
"specialize",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"new_nodes",
"=",
"_curve_helpers",
".",
"specialize_curve",
"(",
"self",
".",
"_nodes",
",",
"start",
",",
"end",
")",
"return",
"Curve",
"(",
"new_nodes",
",",
"self",
".",
"_degree"... | Specialize the curve to a given sub-interval.
.. image:: ../../images/curve_specialize.png
:align: center
.. doctest:: curve-specialize
>>> nodes = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, 0.0],
... ])
>>> curve ... | [
"Specialize",
"the",
"curve",
"to",
"a",
"given",
"sub",
"-",
"interval",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L540-L597 |
dhermes/bezier | src/bezier/curve.py | Curve.locate | def locate(self, point):
r"""Find a point on the current curve.
Solves for :math:`s` in :math:`B(s) = p`.
This method acts as a (partial) inverse to :meth:`evaluate`.
.. note::
A unique solution is only guaranteed if the current curve has no
self-intersections. ... | python | def locate(self, point):
r"""Find a point on the current curve.
Solves for :math:`s` in :math:`B(s) = p`.
This method acts as a (partial) inverse to :meth:`evaluate`.
.. note::
A unique solution is only guaranteed if the current curve has no
self-intersections. ... | [
"def",
"locate",
"(",
"self",
",",
"point",
")",
":",
"if",
"point",
".",
"shape",
"!=",
"(",
"self",
".",
"_dimension",
",",
"1",
")",
":",
"point_dimensions",
"=",
"\" x \"",
".",
"join",
"(",
"str",
"(",
"dimension",
")",
"for",
"dimension",
"in",... | r"""Find a point on the current curve.
Solves for :math:`s` in :math:`B(s) = p`.
This method acts as a (partial) inverse to :meth:`evaluate`.
.. note::
A unique solution is only guaranteed if the current curve has no
self-intersections. This code assumes, but doesn't ch... | [
"r",
"Find",
"a",
"point",
"on",
"the",
"current",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/curve.py#L599-L670 |
dhermes/bezier | scripts/clean_cython.py | clean_file | def clean_file(c_source, virtualenv_dirname):
"""Strip trailing whitespace and clean up "local" names in C source.
These source files are autogenerated from the ``cython`` CLI.
Args:
c_source (str): Path to a ``.c`` source file.
virtualenv_dirname (str): The name of the ``virtualenv``
... | python | def clean_file(c_source, virtualenv_dirname):
"""Strip trailing whitespace and clean up "local" names in C source.
These source files are autogenerated from the ``cython`` CLI.
Args:
c_source (str): Path to a ``.c`` source file.
virtualenv_dirname (str): The name of the ``virtualenv``
... | [
"def",
"clean_file",
"(",
"c_source",
",",
"virtualenv_dirname",
")",
":",
"with",
"open",
"(",
"c_source",
",",
"\"r\"",
")",
"as",
"file_obj",
":",
"contents",
"=",
"file_obj",
".",
"read",
"(",
")",
".",
"rstrip",
"(",
")",
"# Replace the path to the Cyth... | Strip trailing whitespace and clean up "local" names in C source.
These source files are autogenerated from the ``cython`` CLI.
Args:
c_source (str): Path to a ``.c`` source file.
virtualenv_dirname (str): The name of the ``virtualenv``
directory where Cython is installed (this is ... | [
"Strip",
"trailing",
"whitespace",
"and",
"clean",
"up",
"local",
"names",
"in",
"C",
"source",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/clean_cython.py#L17-L40 |
dhermes/bezier | scripts/doc_template_release.py | get_version | def get_version():
"""Get the current version from ``setup.py``.
Assumes that importing ``setup.py`` will have no side-effects (i.e.
assumes the behavior is guarded by ``if __name__ == "__main__"``).
Returns:
str: The current version in ``setup.py``.
"""
# "Spoof" the ``setup.py`` help... | python | def get_version():
"""Get the current version from ``setup.py``.
Assumes that importing ``setup.py`` will have no side-effects (i.e.
assumes the behavior is guarded by ``if __name__ == "__main__"``).
Returns:
str: The current version in ``setup.py``.
"""
# "Spoof" the ``setup.py`` help... | [
"def",
"get_version",
"(",
")",
":",
"# \"Spoof\" the ``setup.py`` helper modules.",
"sys",
".",
"modules",
"[",
"\"setup_helpers\"",
"]",
"=",
"object",
"(",
")",
"sys",
".",
"modules",
"[",
"\"setup_helpers_macos\"",
"]",
"=",
"object",
"(",
")",
"sys",
".",
... | Get the current version from ``setup.py``.
Assumes that importing ``setup.py`` will have no side-effects (i.e.
assumes the behavior is guarded by ``if __name__ == "__main__"``).
Returns:
str: The current version in ``setup.py``. | [
"Get",
"the",
"current",
"version",
"from",
"setup",
".",
"py",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/doc_template_release.py#L54-L70 |
dhermes/bezier | scripts/doc_template_release.py | populate_readme | def populate_readme(
version, circleci_build, appveyor_build, coveralls_build, travis_build
):
"""Populates ``README.rst`` with release-specific data.
This is because ``README.rst`` is used on PyPI.
Args:
version (str): The current version.
circleci_build (Union[str, int]): The CircleC... | python | def populate_readme(
version, circleci_build, appveyor_build, coveralls_build, travis_build
):
"""Populates ``README.rst`` with release-specific data.
This is because ``README.rst`` is used on PyPI.
Args:
version (str): The current version.
circleci_build (Union[str, int]): The CircleC... | [
"def",
"populate_readme",
"(",
"version",
",",
"circleci_build",
",",
"appveyor_build",
",",
"coveralls_build",
",",
"travis_build",
")",
":",
"with",
"open",
"(",
"RELEASE_README_FILE",
",",
"\"r\"",
")",
"as",
"file_obj",
":",
"template",
"=",
"file_obj",
".",... | Populates ``README.rst`` with release-specific data.
This is because ``README.rst`` is used on PyPI.
Args:
version (str): The current version.
circleci_build (Union[str, int]): The CircleCI build ID corresponding
to the release.
appveyor_build (str): The AppVeyor build ID c... | [
"Populates",
"README",
".",
"rst",
"with",
"release",
"-",
"specific",
"data",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/doc_template_release.py#L73-L101 |
dhermes/bezier | scripts/doc_template_release.py | populate_index | def populate_index(
version, circleci_build, appveyor_build, coveralls_build, travis_build
):
"""Populates ``docs/index.rst`` with release-specific data.
Args:
version (str): The current version.
circleci_build (Union[str, int]): The CircleCI build ID corresponding
to the releas... | python | def populate_index(
version, circleci_build, appveyor_build, coveralls_build, travis_build
):
"""Populates ``docs/index.rst`` with release-specific data.
Args:
version (str): The current version.
circleci_build (Union[str, int]): The CircleCI build ID corresponding
to the releas... | [
"def",
"populate_index",
"(",
"version",
",",
"circleci_build",
",",
"appveyor_build",
",",
"coveralls_build",
",",
"travis_build",
")",
":",
"with",
"open",
"(",
"RELEASE_INDEX_FILE",
",",
"\"r\"",
")",
"as",
"file_obj",
":",
"template",
"=",
"file_obj",
".",
... | Populates ``docs/index.rst`` with release-specific data.
Args:
version (str): The current version.
circleci_build (Union[str, int]): The CircleCI build ID corresponding
to the release.
appveyor_build (str): The AppVeyor build ID corresponding to the
release.
... | [
"Populates",
"docs",
"/",
"index",
".",
"rst",
"with",
"release",
"-",
"specific",
"data",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/doc_template_release.py#L104-L130 |
dhermes/bezier | scripts/doc_template_release.py | populate_native_libraries | def populate_native_libraries(version):
"""Populates ``binary-extension.rst`` with release-specific data.
Args:
version (str): The current version.
"""
with open(BINARY_EXT_TEMPLATE, "r") as file_obj:
template = file_obj.read()
contents = template.format(revision=version)
with o... | python | def populate_native_libraries(version):
"""Populates ``binary-extension.rst`` with release-specific data.
Args:
version (str): The current version.
"""
with open(BINARY_EXT_TEMPLATE, "r") as file_obj:
template = file_obj.read()
contents = template.format(revision=version)
with o... | [
"def",
"populate_native_libraries",
"(",
"version",
")",
":",
"with",
"open",
"(",
"BINARY_EXT_TEMPLATE",
",",
"\"r\"",
")",
"as",
"file_obj",
":",
"template",
"=",
"file_obj",
".",
"read",
"(",
")",
"contents",
"=",
"template",
".",
"format",
"(",
"revision... | Populates ``binary-extension.rst`` with release-specific data.
Args:
version (str): The current version. | [
"Populates",
"binary",
"-",
"extension",
".",
"rst",
"with",
"release",
"-",
"specific",
"data",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/doc_template_release.py#L133-L143 |
dhermes/bezier | scripts/doc_template_release.py | populate_development | def populate_development(version):
"""Populates ``DEVELOPMENT.rst`` with release-specific data.
This is because ``DEVELOPMENT.rst`` is used in the Sphinx documentation.
Args:
version (str): The current version.
"""
with open(DEVELOPMENT_TEMPLATE, "r") as file_obj:
template = file_o... | python | def populate_development(version):
"""Populates ``DEVELOPMENT.rst`` with release-specific data.
This is because ``DEVELOPMENT.rst`` is used in the Sphinx documentation.
Args:
version (str): The current version.
"""
with open(DEVELOPMENT_TEMPLATE, "r") as file_obj:
template = file_o... | [
"def",
"populate_development",
"(",
"version",
")",
":",
"with",
"open",
"(",
"DEVELOPMENT_TEMPLATE",
",",
"\"r\"",
")",
"as",
"file_obj",
":",
"template",
"=",
"file_obj",
".",
"read",
"(",
")",
"contents",
"=",
"template",
".",
"format",
"(",
"revision",
... | Populates ``DEVELOPMENT.rst`` with release-specific data.
This is because ``DEVELOPMENT.rst`` is used in the Sphinx documentation.
Args:
version (str): The current version. | [
"Populates",
"DEVELOPMENT",
".",
"rst",
"with",
"release",
"-",
"specific",
"data",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/doc_template_release.py#L146-L158 |
dhermes/bezier | scripts/doc_template_release.py | main | def main():
"""Populate the templates with release-specific fields.
Requires user input for the CircleCI, AppVeyor, Coveralls.io and Travis
build IDs.
"""
version = get_version()
circleci_build = six.moves.input("CircleCI Build ID: ")
appveyor_build = six.moves.input("AppVeyor Build ID: ")
... | python | def main():
"""Populate the templates with release-specific fields.
Requires user input for the CircleCI, AppVeyor, Coveralls.io and Travis
build IDs.
"""
version = get_version()
circleci_build = six.moves.input("CircleCI Build ID: ")
appveyor_build = six.moves.input("AppVeyor Build ID: ")
... | [
"def",
"main",
"(",
")",
":",
"version",
"=",
"get_version",
"(",
")",
"circleci_build",
"=",
"six",
".",
"moves",
".",
"input",
"(",
"\"CircleCI Build ID: \"",
")",
"appveyor_build",
"=",
"six",
".",
"moves",
".",
"input",
"(",
"\"AppVeyor Build ID: \"",
")... | Populate the templates with release-specific fields.
Requires user input for the CircleCI, AppVeyor, Coveralls.io and Travis
build IDs. | [
"Populate",
"the",
"templates",
"with",
"release",
"-",
"specific",
"fields",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/doc_template_release.py#L161-L179 |
dhermes/bezier | src/bezier/_curve_helpers.py | make_subdivision_matrices | def make_subdivision_matrices(degree):
"""Make the matrix used to subdivide a curve.
.. note::
This is a helper for :func:`_subdivide_nodes`. It does not have a
Fortran speedup because it is **only** used by a function which has
a Fortran speedup.
Args:
degree (int): The d... | python | def make_subdivision_matrices(degree):
"""Make the matrix used to subdivide a curve.
.. note::
This is a helper for :func:`_subdivide_nodes`. It does not have a
Fortran speedup because it is **only** used by a function which has
a Fortran speedup.
Args:
degree (int): The d... | [
"def",
"make_subdivision_matrices",
"(",
"degree",
")",
":",
"left",
"=",
"np",
".",
"zeros",
"(",
"(",
"degree",
"+",
"1",
",",
"degree",
"+",
"1",
")",
",",
"order",
"=",
"\"F\"",
")",
"right",
"=",
"np",
".",
"zeros",
"(",
"(",
"degree",
"+",
... | Make the matrix used to subdivide a curve.
.. note::
This is a helper for :func:`_subdivide_nodes`. It does not have a
Fortran speedup because it is **only** used by a function which has
a Fortran speedup.
Args:
degree (int): The degree of the curve.
Returns:
Tupl... | [
"Make",
"the",
"matrix",
"used",
"to",
"subdivide",
"a",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L128-L158 |
dhermes/bezier | src/bezier/_curve_helpers.py | _subdivide_nodes | def _subdivide_nodes(nodes):
"""Subdivide a curve into two sub-curves.
Does so by taking the unit interval (i.e. the domain of the surface) and
splitting it into two sub-intervals by splitting down the middle.
.. note::
There is also a Fortran implementation of this function, which
will... | python | def _subdivide_nodes(nodes):
"""Subdivide a curve into two sub-curves.
Does so by taking the unit interval (i.e. the domain of the surface) and
splitting it into two sub-intervals by splitting down the middle.
.. note::
There is also a Fortran implementation of this function, which
will... | [
"def",
"_subdivide_nodes",
"(",
"nodes",
")",
":",
"_",
",",
"num_nodes",
"=",
"np",
".",
"shape",
"(",
"nodes",
")",
"if",
"num_nodes",
"==",
"2",
":",
"left_nodes",
"=",
"_helpers",
".",
"matrix_product",
"(",
"nodes",
",",
"_LINEAR_SUBDIVIDE_LEFT",
")",... | Subdivide a curve into two sub-curves.
Does so by taking the unit interval (i.e. the domain of the surface) and
splitting it into two sub-intervals by splitting down the middle.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Ar... | [
"Subdivide",
"a",
"curve",
"into",
"two",
"sub",
"-",
"curves",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L161-L194 |
dhermes/bezier | src/bezier/_curve_helpers.py | _evaluate_multi_barycentric | def _evaluate_multi_barycentric(nodes, lambda1, lambda2):
r"""Evaluates a B |eacute| zier type-function.
Of the form
.. math::
B(\lambda_1, \lambda_2) = \sum_j \binom{n}{j}
\lambda_1^{n - j} \lambda_2^j \cdot v_j
for some set of vectors :math:`v_j` given by ``nodes``.
Does so ... | python | def _evaluate_multi_barycentric(nodes, lambda1, lambda2):
r"""Evaluates a B |eacute| zier type-function.
Of the form
.. math::
B(\lambda_1, \lambda_2) = \sum_j \binom{n}{j}
\lambda_1^{n - j} \lambda_2^j \cdot v_j
for some set of vectors :math:`v_j` given by ``nodes``.
Does so ... | [
"def",
"_evaluate_multi_barycentric",
"(",
"nodes",
",",
"lambda1",
",",
"lambda2",
")",
":",
"# NOTE: We assume but don't check that lambda2 has the same shape.",
"num_vals",
",",
"=",
"lambda1",
".",
"shape",
"dimension",
",",
"num_nodes",
"=",
"nodes",
".",
"shape",
... | r"""Evaluates a B |eacute| zier type-function.
Of the form
.. math::
B(\lambda_1, \lambda_2) = \sum_j \binom{n}{j}
\lambda_1^{n - j} \lambda_2^j \cdot v_j
for some set of vectors :math:`v_j` given by ``nodes``.
Does so via a modified Horner's method for each pair of values
in ... | [
"r",
"Evaluates",
"a",
"B",
"|eacute|",
"zier",
"type",
"-",
"function",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L222-L273 |
dhermes/bezier | src/bezier/_curve_helpers.py | vec_size | def vec_size(nodes, s_val):
r"""Compute :math:`\|B(s)\|_2`.
.. note::
This is a helper for :func:`_compute_length` and does not have
a Fortran speedup.
Intended to be used with ``functools.partial`` to fill in the
value of ``nodes`` and create a callable that only accepts ``s_val``.
... | python | def vec_size(nodes, s_val):
r"""Compute :math:`\|B(s)\|_2`.
.. note::
This is a helper for :func:`_compute_length` and does not have
a Fortran speedup.
Intended to be used with ``functools.partial`` to fill in the
value of ``nodes`` and create a callable that only accepts ``s_val``.
... | [
"def",
"vec_size",
"(",
"nodes",
",",
"s_val",
")",
":",
"result_vec",
"=",
"evaluate_multi",
"(",
"nodes",
",",
"np",
".",
"asfortranarray",
"(",
"[",
"s_val",
"]",
")",
")",
"# NOTE: We convert to 1D to make sure NumPy uses vector norm.",
"return",
"np",
".",
... | r"""Compute :math:`\|B(s)\|_2`.
.. note::
This is a helper for :func:`_compute_length` and does not have
a Fortran speedup.
Intended to be used with ``functools.partial`` to fill in the
value of ``nodes`` and create a callable that only accepts ``s_val``.
Args:
nodes (numpy.n... | [
"r",
"Compute",
":",
"math",
":",
"\\",
"|B",
"(",
"s",
")",
"\\",
"|_2",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L276-L296 |
dhermes/bezier | src/bezier/_curve_helpers.py | _compute_length | def _compute_length(nodes):
r"""Approximately compute the length of a curve.
.. _QUADPACK: https://en.wikipedia.org/wiki/QUADPACK
If ``degree`` is :math:`n`, then the Hodograph curve
:math:`B'(s)` is degree :math:`d = n - 1`. Using this curve, we
approximate the integral:
.. math::
\i... | python | def _compute_length(nodes):
r"""Approximately compute the length of a curve.
.. _QUADPACK: https://en.wikipedia.org/wiki/QUADPACK
If ``degree`` is :math:`n`, then the Hodograph curve
:math:`B'(s)` is degree :math:`d = n - 1`. Using this curve, we
approximate the integral:
.. math::
\i... | [
"def",
"_compute_length",
"(",
"nodes",
")",
":",
"_",
",",
"num_nodes",
"=",
"np",
".",
"shape",
"(",
"nodes",
")",
"# NOTE: We somewhat replicate code in ``evaluate_hodograph()``",
"# here. This is so we don't re-compute the nodes for the first",
"# derivative every... | r"""Approximately compute the length of a curve.
.. _QUADPACK: https://en.wikipedia.org/wiki/QUADPACK
If ``degree`` is :math:`n`, then the Hodograph curve
:math:`B'(s)` is degree :math:`d = n - 1`. Using this curve, we
approximate the integral:
.. math::
\int_{B\left(\left[0, 1\right]\rig... | [
"r",
"Approximately",
"compute",
"the",
"length",
"of",
"a",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L299-L343 |
dhermes/bezier | src/bezier/_curve_helpers.py | _elevate_nodes | def _elevate_nodes(nodes):
r"""Degree-elevate a B |eacute| zier curves.
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n + 1}` where
.. math::
\begin{align*}
w_0 &= v_0 \\
w_j &= \frac{j}{n + 1} v_{j - 1} + \frac{n + 1 - j}{... | python | def _elevate_nodes(nodes):
r"""Degree-elevate a B |eacute| zier curves.
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n + 1}` where
.. math::
\begin{align*}
w_0 &= v_0 \\
w_j &= \frac{j}{n + 1} v_{j - 1} + \frac{n + 1 - j}{... | [
"def",
"_elevate_nodes",
"(",
"nodes",
")",
":",
"dimension",
",",
"num_nodes",
"=",
"np",
".",
"shape",
"(",
"nodes",
")",
"new_nodes",
"=",
"np",
".",
"empty",
"(",
"(",
"dimension",
",",
"num_nodes",
"+",
"1",
")",
",",
"order",
"=",
"\"F\"",
")",... | r"""Degree-elevate a B |eacute| zier curves.
Does this by converting the current nodes :math:`v_0, \ldots, v_n`
to new nodes :math:`w_0, \ldots, w_{n + 1}` where
.. math::
\begin{align*}
w_0 &= v_0 \\
w_j &= \frac{j}{n + 1} v_{j - 1} + \frac{n + 1 - j}{n + 1} v_j \\
w_{n + 1} ... | [
"r",
"Degree",
"-",
"elevate",
"a",
"B",
"|eacute|",
"zier",
"curves",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L346-L385 |
dhermes/bezier | src/bezier/_curve_helpers.py | de_casteljau_one_round | def de_casteljau_one_round(nodes, lambda1, lambda2):
"""Perform one round of de Casteljau's algorithm.
.. note::
This is a helper for :func:`_specialize_curve`. It does not have a
Fortran speedup because it is **only** used by a function which has
a Fortran speedup.
The weights ar... | python | def de_casteljau_one_round(nodes, lambda1, lambda2):
"""Perform one round of de Casteljau's algorithm.
.. note::
This is a helper for :func:`_specialize_curve`. It does not have a
Fortran speedup because it is **only** used by a function which has
a Fortran speedup.
The weights ar... | [
"def",
"de_casteljau_one_round",
"(",
"nodes",
",",
"lambda1",
",",
"lambda2",
")",
":",
"return",
"np",
".",
"asfortranarray",
"(",
"lambda1",
"*",
"nodes",
"[",
":",
",",
":",
"-",
"1",
"]",
"+",
"lambda2",
"*",
"nodes",
"[",
":",
",",
"1",
":",
... | Perform one round of de Casteljau's algorithm.
.. note::
This is a helper for :func:`_specialize_curve`. It does not have a
Fortran speedup because it is **only** used by a function which has
a Fortran speedup.
The weights are assumed to sum to one.
Args:
nodes (numpy.nda... | [
"Perform",
"one",
"round",
"of",
"de",
"Casteljau",
"s",
"algorithm",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L388-L408 |
dhermes/bezier | src/bezier/_curve_helpers.py | _specialize_curve | def _specialize_curve(nodes, start, end):
"""Specialize a curve to a re-parameterization
.. note::
This assumes the curve is degree 1 or greater but doesn't check.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
... | python | def _specialize_curve(nodes, start, end):
"""Specialize a curve to a re-parameterization
.. note::
This assumes the curve is degree 1 or greater but doesn't check.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
... | [
"def",
"_specialize_curve",
"(",
"nodes",
",",
"start",
",",
"end",
")",
":",
"# NOTE: There is no corresponding \"enable\", but the disable only applies",
"# in this lexical scope.",
"# pylint: disable=too-many-locals",
"_",
",",
"num_nodes",
"=",
"np",
".",
"shape",
"... | Specialize a curve to a re-parameterization
.. note::
This assumes the curve is degree 1 or greater but doesn't check.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): Control points for a... | [
"Specialize",
"a",
"curve",
"to",
"a",
"re",
"-",
"parameterization"
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L411-L455 |
dhermes/bezier | src/bezier/_curve_helpers.py | _evaluate_hodograph | def _evaluate_hodograph(s, nodes):
r"""Evaluate the Hodograph curve at a point :math:`s`.
The Hodograph (first derivative) of a B |eacute| zier curve
degree :math:`d = n - 1` and is given by
.. math::
B'(s) = n \sum_{j = 0}^{d} \binom{d}{j} s^j
(1 - s)^{d - j} \cdot \Delta v_j
wher... | python | def _evaluate_hodograph(s, nodes):
r"""Evaluate the Hodograph curve at a point :math:`s`.
The Hodograph (first derivative) of a B |eacute| zier curve
degree :math:`d = n - 1` and is given by
.. math::
B'(s) = n \sum_{j = 0}^{d} \binom{d}{j} s^j
(1 - s)^{d - j} \cdot \Delta v_j
wher... | [
"def",
"_evaluate_hodograph",
"(",
"s",
",",
"nodes",
")",
":",
"_",
",",
"num_nodes",
"=",
"np",
".",
"shape",
"(",
"nodes",
")",
"first_deriv",
"=",
"nodes",
"[",
":",
",",
"1",
":",
"]",
"-",
"nodes",
"[",
":",
",",
":",
"-",
"1",
"]",
"retu... | r"""Evaluate the Hodograph curve at a point :math:`s`.
The Hodograph (first derivative) of a B |eacute| zier curve
degree :math:`d = n - 1` and is given by
.. math::
B'(s) = n \sum_{j = 0}^{d} \binom{d}{j} s^j
(1 - s)^{d - j} \cdot \Delta v_j
where each forward difference is given by
... | [
"r",
"Evaluate",
"the",
"Hodograph",
"curve",
"at",
"a",
"point",
":",
"math",
":",
"s",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L458-L490 |
dhermes/bezier | src/bezier/_curve_helpers.py | _get_curvature | def _get_curvature(nodes, tangent_vec, s):
r"""Compute the signed curvature of a curve at :math:`s`.
Computed via
.. math::
\frac{B'(s) \times B''(s)}{\left\lVert B'(s) \right\rVert_2^3}
.. image:: ../images/get_curvature.png
:align: center
.. testsetup:: get-curvature
imp... | python | def _get_curvature(nodes, tangent_vec, s):
r"""Compute the signed curvature of a curve at :math:`s`.
Computed via
.. math::
\frac{B'(s) \times B''(s)}{\left\lVert B'(s) \right\rVert_2^3}
.. image:: ../images/get_curvature.png
:align: center
.. testsetup:: get-curvature
imp... | [
"def",
"_get_curvature",
"(",
"nodes",
",",
"tangent_vec",
",",
"s",
")",
":",
"_",
",",
"num_nodes",
"=",
"np",
".",
"shape",
"(",
"nodes",
")",
"if",
"num_nodes",
"==",
"2",
":",
"# Lines have no curvature.",
"return",
"0.0",
"# NOTE: We somewhat replicate c... | r"""Compute the signed curvature of a curve at :math:`s`.
Computed via
.. math::
\frac{B'(s) \times B''(s)}{\left\lVert B'(s) \right\rVert_2^3}
.. image:: ../images/get_curvature.png
:align: center
.. testsetup:: get-curvature
import numpy as np
import bezier
fro... | [
"r",
"Compute",
"the",
"signed",
"curvature",
"of",
"a",
"curve",
"at",
":",
"math",
":",
"s",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L493-L564 |
dhermes/bezier | src/bezier/_curve_helpers.py | _newton_refine | def _newton_refine(nodes, point, s):
r"""Refine a solution to :math:`B(s) = p` using Newton's method.
Computes updates via
.. math::
\mathbf{0} \approx
\left(B\left(s_{\ast}\right) - p\right) +
B'\left(s_{\ast}\right) \Delta s
For example, consider the curve
.. math... | python | def _newton_refine(nodes, point, s):
r"""Refine a solution to :math:`B(s) = p` using Newton's method.
Computes updates via
.. math::
\mathbf{0} \approx
\left(B\left(s_{\ast}\right) - p\right) +
B'\left(s_{\ast}\right) \Delta s
For example, consider the curve
.. math... | [
"def",
"_newton_refine",
"(",
"nodes",
",",
"point",
",",
"s",
")",
":",
"pt_delta",
"=",
"point",
"-",
"evaluate_multi",
"(",
"nodes",
",",
"np",
".",
"asfortranarray",
"(",
"[",
"s",
"]",
")",
")",
"derivative",
"=",
"evaluate_hodograph",
"(",
"s",
"... | r"""Refine a solution to :math:`B(s) = p` using Newton's method.
Computes updates via
.. math::
\mathbf{0} \approx
\left(B\left(s_{\ast}\right) - p\right) +
B'\left(s_{\ast}\right) \Delta s
For example, consider the curve
.. math::
B(s) =
\left[\begin... | [
"r",
"Refine",
"a",
"solution",
"to",
":",
"math",
":",
"B",
"(",
"s",
")",
"=",
"p",
"using",
"Newton",
"s",
"method",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L567-L737 |
dhermes/bezier | src/bezier/_curve_helpers.py | _locate_point | def _locate_point(nodes, point):
r"""Locate a point on a curve.
Does so by recursively subdividing the curve and rejecting
sub-curves with bounding boxes that don't contain the point.
After the sub-curves are sufficiently small, uses Newton's
method to zoom in on the parameter value.
.. note::... | python | def _locate_point(nodes, point):
r"""Locate a point on a curve.
Does so by recursively subdividing the curve and rejecting
sub-curves with bounding boxes that don't contain the point.
After the sub-curves are sufficiently small, uses Newton's
method to zoom in on the parameter value.
.. note::... | [
"def",
"_locate_point",
"(",
"nodes",
",",
"point",
")",
":",
"candidates",
"=",
"[",
"(",
"0.0",
",",
"1.0",
",",
"nodes",
")",
"]",
"for",
"_",
"in",
"six",
".",
"moves",
".",
"xrange",
"(",
"_MAX_LOCATE_SUBDIVISIONS",
"+",
"1",
")",
":",
"next_can... | r"""Locate a point on a curve.
Does so by recursively subdividing the curve and rejecting
sub-curves with bounding boxes that don't contain the point.
After the sub-curves are sufficiently small, uses Newton's
method to zoom in on the parameter value.
.. note::
This assumes, but does not c... | [
"r",
"Locate",
"a",
"point",
"on",
"a",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L740-L801 |
dhermes/bezier | src/bezier/_curve_helpers.py | _reduce_pseudo_inverse | def _reduce_pseudo_inverse(nodes):
"""Performs degree-reduction for a B |eacute| zier curve.
Does so by using the pseudo-inverse of the degree elevation
operator (which is overdetermined).
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be... | python | def _reduce_pseudo_inverse(nodes):
"""Performs degree-reduction for a B |eacute| zier curve.
Does so by using the pseudo-inverse of the degree elevation
operator (which is overdetermined).
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be... | [
"def",
"_reduce_pseudo_inverse",
"(",
"nodes",
")",
":",
"_",
",",
"num_nodes",
"=",
"np",
".",
"shape",
"(",
"nodes",
")",
"if",
"num_nodes",
"==",
"2",
":",
"reduction",
"=",
"_REDUCTION0",
"denom",
"=",
"_REDUCTION_DENOM0",
"elif",
"num_nodes",
"==",
"3... | Performs degree-reduction for a B |eacute| zier curve.
Does so by using the pseudo-inverse of the degree elevation
operator (which is overdetermined).
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.nd... | [
"Performs",
"degree",
"-",
"reduction",
"for",
"a",
"B",
"|eacute|",
"zier",
"curve",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L804-L842 |
dhermes/bezier | src/bezier/_curve_helpers.py | projection_error | def projection_error(nodes, projected):
"""Compute the error between ``nodes`` and the projected nodes.
.. note::
This is a helper for :func:`maybe_reduce`, which is in turn a helper
for :func:`_full_reduce`. Hence there is no corresponding Fortran
speedup.
For now, just compute t... | python | def projection_error(nodes, projected):
"""Compute the error between ``nodes`` and the projected nodes.
.. note::
This is a helper for :func:`maybe_reduce`, which is in turn a helper
for :func:`_full_reduce`. Hence there is no corresponding Fortran
speedup.
For now, just compute t... | [
"def",
"projection_error",
"(",
"nodes",
",",
"projected",
")",
":",
"relative_err",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"nodes",
"-",
"projected",
",",
"ord",
"=",
"\"fro\"",
")",
"if",
"relative_err",
"!=",
"0.0",
":",
"relative_err",
"/=",
"np... | Compute the error between ``nodes`` and the projected nodes.
.. note::
This is a helper for :func:`maybe_reduce`, which is in turn a helper
for :func:`_full_reduce`. Hence there is no corresponding Fortran
speedup.
For now, just compute the relative error in the Frobenius norm. But,
... | [
"Compute",
"the",
"error",
"between",
"nodes",
"and",
"the",
"projected",
"nodes",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L845-L868 |
dhermes/bezier | src/bezier/_curve_helpers.py | maybe_reduce | def maybe_reduce(nodes):
r"""Reduce nodes in a curve if they are degree-elevated.
.. note::
This is a helper for :func:`_full_reduce`. Hence there is no
corresponding Fortran speedup.
We check if the nodes are degree-elevated by projecting onto the
space of degree-elevated curves of t... | python | def maybe_reduce(nodes):
r"""Reduce nodes in a curve if they are degree-elevated.
.. note::
This is a helper for :func:`_full_reduce`. Hence there is no
corresponding Fortran speedup.
We check if the nodes are degree-elevated by projecting onto the
space of degree-elevated curves of t... | [
"def",
"maybe_reduce",
"(",
"nodes",
")",
":",
"_",
",",
"num_nodes",
"=",
"nodes",
".",
"shape",
"if",
"num_nodes",
"<",
"2",
":",
"return",
"False",
",",
"nodes",
"elif",
"num_nodes",
"==",
"2",
":",
"projection",
"=",
"_PROJECTION0",
"denom",
"=",
"... | r"""Reduce nodes in a curve if they are degree-elevated.
.. note::
This is a helper for :func:`_full_reduce`. Hence there is no
corresponding Fortran speedup.
We check if the nodes are degree-elevated by projecting onto the
space of degree-elevated curves of the same degree, then comparin... | [
"r",
"Reduce",
"nodes",
"in",
"a",
"curve",
"if",
"they",
"are",
"degree",
"-",
"elevated",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L871-L923 |
dhermes/bezier | src/bezier/_curve_helpers.py | _full_reduce | def _full_reduce(nodes):
"""Apply degree reduction to ``nodes`` until it can no longer be reduced.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): The nodes in the curve.
Returns:
num... | python | def _full_reduce(nodes):
"""Apply degree reduction to ``nodes`` until it can no longer be reduced.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): The nodes in the curve.
Returns:
num... | [
"def",
"_full_reduce",
"(",
"nodes",
")",
":",
"was_reduced",
",",
"nodes",
"=",
"maybe_reduce",
"(",
"nodes",
")",
"while",
"was_reduced",
":",
"was_reduced",
",",
"nodes",
"=",
"maybe_reduce",
"(",
"nodes",
")",
"return",
"nodes"
] | Apply degree reduction to ``nodes`` until it can no longer be reduced.
.. note::
There is also a Fortran implementation of this function, which
will be used if it can be built.
Args:
nodes (numpy.ndarray): The nodes in the curve.
Returns:
numpy.ndarray: The fully degree-red... | [
"Apply",
"degree",
"reduction",
"to",
"nodes",
"until",
"it",
"can",
"no",
"longer",
"be",
"reduced",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L926-L943 |
dhermes/bezier | scripts/rewrite_package_rst.py | get_public_members | def get_public_members():
"""Get public members in :mod:`bezier` package.
Also validates the contents of ``bezier.__all__``.
Returns:
list: List of all public members **defined** in the
main package (i.e. in ``__init__.py``).
Raises:
ValueError: If ``__all__`` has repeated ele... | python | def get_public_members():
"""Get public members in :mod:`bezier` package.
Also validates the contents of ``bezier.__all__``.
Returns:
list: List of all public members **defined** in the
main package (i.e. in ``__init__.py``).
Raises:
ValueError: If ``__all__`` has repeated ele... | [
"def",
"get_public_members",
"(",
")",
":",
"if",
"bezier",
"is",
"None",
":",
"return",
"[",
"]",
"local_members",
"=",
"[",
"]",
"all_members",
"=",
"set",
"(",
")",
"for",
"name",
"in",
"dir",
"(",
"bezier",
")",
":",
"# Filter out non-public.",
"if",... | Get public members in :mod:`bezier` package.
Also validates the contents of ``bezier.__all__``.
Returns:
list: List of all public members **defined** in the
main package (i.e. in ``__init__.py``).
Raises:
ValueError: If ``__all__`` has repeated elements.
ValueError: If the... | [
"Get",
"public",
"members",
"in",
":",
"mod",
":",
"bezier",
"package",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/rewrite_package_rst.py#L69-L120 |
dhermes/bezier | scripts/rewrite_package_rst.py | get_desired | def get_desired():
"""Populate ``DESIRED_TEMPLATE`` with public members.
If there are no members, does nothing.
Returns:
str: The "desired" contents of ``bezier.rst``.
"""
public_members = get_public_members()
if public_members:
members = "\n :members: {}".format(", ".join(p... | python | def get_desired():
"""Populate ``DESIRED_TEMPLATE`` with public members.
If there are no members, does nothing.
Returns:
str: The "desired" contents of ``bezier.rst``.
"""
public_members = get_public_members()
if public_members:
members = "\n :members: {}".format(", ".join(p... | [
"def",
"get_desired",
"(",
")",
":",
"public_members",
"=",
"get_public_members",
"(",
")",
"if",
"public_members",
":",
"members",
"=",
"\"\\n :members: {}\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"public_members",
")",
")",
"else",
":",
"member... | Populate ``DESIRED_TEMPLATE`` with public members.
If there are no members, does nothing.
Returns:
str: The "desired" contents of ``bezier.rst``. | [
"Populate",
"DESIRED_TEMPLATE",
"with",
"public",
"members",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/rewrite_package_rst.py#L123-L136 |
dhermes/bezier | scripts/rewrite_package_rst.py | main | def main():
"""Main entry point to replace autogenerated contents.
Raises:
ValueError: If the file doesn't contain the expected or
desired contents.
"""
with open(FILENAME, "r") as file_obj:
contents = file_obj.read()
desired = get_desired()
if contents == EXPECTED:
... | python | def main():
"""Main entry point to replace autogenerated contents.
Raises:
ValueError: If the file doesn't contain the expected or
desired contents.
"""
with open(FILENAME, "r") as file_obj:
contents = file_obj.read()
desired = get_desired()
if contents == EXPECTED:
... | [
"def",
"main",
"(",
")",
":",
"with",
"open",
"(",
"FILENAME",
",",
"\"r\"",
")",
"as",
"file_obj",
":",
"contents",
"=",
"file_obj",
".",
"read",
"(",
")",
"desired",
"=",
"get_desired",
"(",
")",
"if",
"contents",
"==",
"EXPECTED",
":",
"with",
"op... | Main entry point to replace autogenerated contents.
Raises:
ValueError: If the file doesn't contain the expected or
desired contents. | [
"Main",
"entry",
"point",
"to",
"replace",
"autogenerated",
"contents",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/scripts/rewrite_package_rst.py#L139-L153 |
dhermes/bezier | setup_helpers_windows.py | run_cleanup | def run_cleanup(build_ext_cmd):
"""Cleanup after ``BuildFortranThenExt.run``.
For in-place builds, moves the built shared library into the source
directory.
"""
if not build_ext_cmd.inplace:
return
bezier_dir = os.path.join("src", "bezier")
shutil.move(os.path.join(build_ext_cmd.bu... | python | def run_cleanup(build_ext_cmd):
"""Cleanup after ``BuildFortranThenExt.run``.
For in-place builds, moves the built shared library into the source
directory.
"""
if not build_ext_cmd.inplace:
return
bezier_dir = os.path.join("src", "bezier")
shutil.move(os.path.join(build_ext_cmd.bu... | [
"def",
"run_cleanup",
"(",
"build_ext_cmd",
")",
":",
"if",
"not",
"build_ext_cmd",
".",
"inplace",
":",
"return",
"bezier_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"\"src\"",
",",
"\"bezier\"",
")",
"shutil",
".",
"move",
"(",
"os",
".",
"path",
... | Cleanup after ``BuildFortranThenExt.run``.
For in-place builds, moves the built shared library into the source
directory. | [
"Cleanup",
"after",
"BuildFortranThenExt",
".",
"run",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/setup_helpers_windows.py#L77-L88 |
dhermes/bezier | setup_helpers_windows.py | patch_f90_compiler | def patch_f90_compiler(f90_compiler):
"""Patch up ``f90_compiler.library_dirs``.
Updates flags in ``gfortran`` and ignores other compilers. The only
modification is the removal of ``-fPIC`` since it is not used on Windows
and the build flags turn warnings into errors.
Args:
f90_compiler (n... | python | def patch_f90_compiler(f90_compiler):
"""Patch up ``f90_compiler.library_dirs``.
Updates flags in ``gfortran`` and ignores other compilers. The only
modification is the removal of ``-fPIC`` since it is not used on Windows
and the build flags turn warnings into errors.
Args:
f90_compiler (n... | [
"def",
"patch_f90_compiler",
"(",
"f90_compiler",
")",
":",
"# NOTE: NumPy may not be installed, but we don't want **this** module to",
"# cause an import failure.",
"from",
"numpy",
".",
"distutils",
".",
"fcompiler",
"import",
"gnu",
"# Only Windows.",
"if",
"os",
".",
... | Patch up ``f90_compiler.library_dirs``.
Updates flags in ``gfortran`` and ignores other compilers. The only
modification is the removal of ``-fPIC`` since it is not used on Windows
and the build flags turn warnings into errors.
Args:
f90_compiler (numpy.distutils.fcompiler.FCompiler): A Fortra... | [
"Patch",
"up",
"f90_compiler",
".",
"library_dirs",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/setup_helpers_windows.py#L103-L132 |
dhermes/bezier | noxfile.py | clean | def clean(session):
"""Clean up build files.
Cleans up all artifacts that might get created during
other ``nox`` sessions.
There is no need for the session to create a ``virtualenv``
here (we are just pretending to be ``make``).
"""
clean_dirs = (
get_path(".cache"),
get_pa... | python | def clean(session):
"""Clean up build files.
Cleans up all artifacts that might get created during
other ``nox`` sessions.
There is no need for the session to create a ``virtualenv``
here (we are just pretending to be ``make``).
"""
clean_dirs = (
get_path(".cache"),
get_pa... | [
"def",
"clean",
"(",
"session",
")",
":",
"clean_dirs",
"=",
"(",
"get_path",
"(",
"\".cache\"",
")",
",",
"get_path",
"(",
"\".coverage\"",
")",
",",
"get_path",
"(",
"\".pytest_cache\"",
")",
",",
"get_path",
"(",
"\"__pycache__\"",
")",
",",
"get_path",
... | Clean up build files.
Cleans up all artifacts that might get created during
other ``nox`` sessions.
There is no need for the session to create a ``virtualenv``
here (we are just pretending to be ``make``). | [
"Clean",
"up",
"build",
"files",
"."
] | train | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/noxfile.py#L373-L420 |
allianceauth/allianceauth | allianceauth/hooks.py | register | def register(name, fn=None):
"""
Decorator to register a function as a hook
Register hook for ``hook_name``. Can be used as a decorator::
@register('hook_name')
def my_hook(...):
pass
or as a function call::
def my_hook(...):
pass
register('hook_... | python | def register(name, fn=None):
"""
Decorator to register a function as a hook
Register hook for ``hook_name``. Can be used as a decorator::
@register('hook_name')
def my_hook(...):
pass
or as a function call::
def my_hook(...):
pass
register('hook_... | [
"def",
"register",
"(",
"name",
",",
"fn",
"=",
"None",
")",
":",
"def",
"_hook_add",
"(",
"func",
")",
":",
"if",
"name",
"not",
"in",
"_hooks",
":",
"logger",
".",
"debug",
"(",
"\"Creating new hook %s\"",
"%",
"name",
")",
"_hooks",
"[",
"name",
"... | Decorator to register a function as a hook
Register hook for ``hook_name``. Can be used as a decorator::
@register('hook_name')
def my_hook(...):
pass
or as a function call::
def my_hook(...):
pass
register('hook_name', my_hook)
:param name: str Nam... | [
"Decorator",
"to",
"register",
"a",
"function",
"as",
"a",
"hook"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/hooks.py#L47-L81 |
allianceauth/allianceauth | allianceauth/hooks.py | get_app_submodules | def get_app_submodules(module_name):
"""
Get a specific sub module of the app
:param module_name: module name to get
:return: name, module tuple
"""
for name, module in get_app_modules():
if module_has_submodule(module, module_name):
yield name, import_module('{0}.{1}'.format... | python | def get_app_submodules(module_name):
"""
Get a specific sub module of the app
:param module_name: module name to get
:return: name, module tuple
"""
for name, module in get_app_modules():
if module_has_submodule(module, module_name):
yield name, import_module('{0}.{1}'.format... | [
"def",
"get_app_submodules",
"(",
"module_name",
")",
":",
"for",
"name",
",",
"module",
"in",
"get_app_modules",
"(",
")",
":",
"if",
"module_has_submodule",
"(",
"module",
",",
"module_name",
")",
":",
"yield",
"name",
",",
"import_module",
"(",
"'{0}.{1}'",... | Get a specific sub module of the app
:param module_name: module name to get
:return: name, module tuple | [
"Get",
"a",
"specific",
"sub",
"module",
"of",
"the",
"app",
":",
"param",
"module_name",
":",
"module",
"name",
"to",
"get",
":",
"return",
":",
"name",
"module",
"tuple"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/hooks.py#L93-L101 |
allianceauth/allianceauth | allianceauth/hooks.py | register_all_hooks | def register_all_hooks():
"""
Register all hooks found in 'auth_hooks' sub modules
:return:
"""
global _all_hooks_registered
if not _all_hooks_registered:
logger.debug("Searching for hooks")
hooks = list(get_app_submodules('auth_hooks'))
logger.debug("Got %s hooks" % len(... | python | def register_all_hooks():
"""
Register all hooks found in 'auth_hooks' sub modules
:return:
"""
global _all_hooks_registered
if not _all_hooks_registered:
logger.debug("Searching for hooks")
hooks = list(get_app_submodules('auth_hooks'))
logger.debug("Got %s hooks" % len(... | [
"def",
"register_all_hooks",
"(",
")",
":",
"global",
"_all_hooks_registered",
"if",
"not",
"_all_hooks_registered",
":",
"logger",
".",
"debug",
"(",
"\"Searching for hooks\"",
")",
"hooks",
"=",
"list",
"(",
"get_app_submodules",
"(",
"'auth_hooks'",
")",
")",
"... | Register all hooks found in 'auth_hooks' sub modules
:return: | [
"Register",
"all",
"hooks",
"found",
"in",
"auth_hooks",
"sub",
"modules",
":",
"return",
":"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/hooks.py#L104-L114 |
allianceauth/allianceauth | allianceauth/services/modules/seat/manager.py | SeatManager.exec_request | def exec_request(endpoint, func, raise_for_status=False, **kwargs):
""" Send an https api request """
try:
endpoint = '{0}/api/v1/{1}'.format(settings.SEAT_URL, endpoint)
headers = {'X-Token': settings.SEAT_XTOKEN, 'Accept': 'application/json'}
logger.debug(headers)
... | python | def exec_request(endpoint, func, raise_for_status=False, **kwargs):
""" Send an https api request """
try:
endpoint = '{0}/api/v1/{1}'.format(settings.SEAT_URL, endpoint)
headers = {'X-Token': settings.SEAT_XTOKEN, 'Accept': 'application/json'}
logger.debug(headers)
... | [
"def",
"exec_request",
"(",
"endpoint",
",",
"func",
",",
"raise_for_status",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"endpoint",
"=",
"'{0}/api/v1/{1}'",
".",
"format",
"(",
"settings",
".",
"SEAT_URL",
",",
"endpoint",
")",
"headers"... | Send an https api request | [
"Send",
"an",
"https",
"api",
"request"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/seat/manager.py#L32-L46 |
allianceauth/allianceauth | allianceauth/services/modules/seat/manager.py | SeatManager.add_user | def add_user(cls, username, email):
""" Add user to service """
sanitized = str(cls.__sanitize_username(username))
logger.debug("Adding user to SeAT with username %s" % sanitized)
password = cls.__generate_random_pass()
ret = cls.exec_request('user', 'post', username=sanitized, e... | python | def add_user(cls, username, email):
""" Add user to service """
sanitized = str(cls.__sanitize_username(username))
logger.debug("Adding user to SeAT with username %s" % sanitized)
password = cls.__generate_random_pass()
ret = cls.exec_request('user', 'post', username=sanitized, e... | [
"def",
"add_user",
"(",
"cls",
",",
"username",
",",
"email",
")",
":",
"sanitized",
"=",
"str",
"(",
"cls",
".",
"__sanitize_username",
"(",
"username",
")",
")",
"logger",
".",
"debug",
"(",
"\"Adding user to SeAT with username %s\"",
"%",
"sanitized",
")",
... | Add user to service | [
"Add",
"user",
"to",
"service"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/seat/manager.py#L49-L60 |
allianceauth/allianceauth | allianceauth/services/modules/seat/manager.py | SeatManager.delete_user | def delete_user(cls, username):
""" Delete user """
ret = cls.exec_request('user/{}'.format(username), 'delete')
logger.debug(ret)
if cls._response_ok(ret):
logger.info("Deleted SeAT user with username %s" % username)
return username
return None | python | def delete_user(cls, username):
""" Delete user """
ret = cls.exec_request('user/{}'.format(username), 'delete')
logger.debug(ret)
if cls._response_ok(ret):
logger.info("Deleted SeAT user with username %s" % username)
return username
return None | [
"def",
"delete_user",
"(",
"cls",
",",
"username",
")",
":",
"ret",
"=",
"cls",
".",
"exec_request",
"(",
"'user/{}'",
".",
"format",
"(",
"username",
")",
",",
"'delete'",
")",
"logger",
".",
"debug",
"(",
"ret",
")",
"if",
"cls",
".",
"_response_ok",... | Delete user | [
"Delete",
"user"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/seat/manager.py#L63-L70 |
allianceauth/allianceauth | allianceauth/services/modules/seat/manager.py | SeatManager.enable_user | def enable_user(cls, username):
""" Enable user """
ret = cls.exec_request('user/{}'.format(username), 'put', account_status=1)
logger.debug(ret)
if cls._response_ok(ret):
logger.info("Enabled SeAT user with username %s" % username)
return username
logger.... | python | def enable_user(cls, username):
""" Enable user """
ret = cls.exec_request('user/{}'.format(username), 'put', account_status=1)
logger.debug(ret)
if cls._response_ok(ret):
logger.info("Enabled SeAT user with username %s" % username)
return username
logger.... | [
"def",
"enable_user",
"(",
"cls",
",",
"username",
")",
":",
"ret",
"=",
"cls",
".",
"exec_request",
"(",
"'user/{}'",
".",
"format",
"(",
"username",
")",
",",
"'put'",
",",
"account_status",
"=",
"1",
")",
"logger",
".",
"debug",
"(",
"ret",
")",
"... | Enable user | [
"Enable",
"user"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/seat/manager.py#L73-L81 |
allianceauth/allianceauth | allianceauth/services/modules/seat/manager.py | SeatManager.disable_user | def disable_user(cls, username):
""" Disable user """
cls.update_roles(username, [])
ret = cls.exec_request('user/{}'.format(username), 'put', account_status=0)
logger.debug(ret)
if cls._response_ok(ret):
logger.info("Disabled SeAT user with username %s" % username)
... | python | def disable_user(cls, username):
""" Disable user """
cls.update_roles(username, [])
ret = cls.exec_request('user/{}'.format(username), 'put', account_status=0)
logger.debug(ret)
if cls._response_ok(ret):
logger.info("Disabled SeAT user with username %s" % username)
... | [
"def",
"disable_user",
"(",
"cls",
",",
"username",
")",
":",
"cls",
".",
"update_roles",
"(",
"username",
",",
"[",
"]",
")",
"ret",
"=",
"cls",
".",
"exec_request",
"(",
"'user/{}'",
".",
"format",
"(",
"username",
")",
",",
"'put'",
",",
"account_st... | Disable user | [
"Disable",
"user"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/seat/manager.py#L84-L93 |
allianceauth/allianceauth | allianceauth/services/modules/seat/manager.py | SeatManager._check_email_changed | def _check_email_changed(cls, username, email):
"""Compares email to one set on SeAT"""
ret = cls.exec_request('user/{}'.format(username), 'get', raise_for_status=True)
return ret['email'] != email | python | def _check_email_changed(cls, username, email):
"""Compares email to one set on SeAT"""
ret = cls.exec_request('user/{}'.format(username), 'get', raise_for_status=True)
return ret['email'] != email | [
"def",
"_check_email_changed",
"(",
"cls",
",",
"username",
",",
"email",
")",
":",
"ret",
"=",
"cls",
".",
"exec_request",
"(",
"'user/{}'",
".",
"format",
"(",
"username",
")",
",",
"'get'",
",",
"raise_for_status",
"=",
"True",
")",
"return",
"ret",
"... | Compares email to one set on SeAT | [
"Compares",
"email",
"to",
"one",
"set",
"on",
"SeAT"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/seat/manager.py#L96-L99 |
allianceauth/allianceauth | allianceauth/services/modules/seat/manager.py | SeatManager.update_user | def update_user(cls, username, email, password):
""" Edit user info """
if cls._check_email_changed(username, email):
# if we try to set the email to whatever it is already on SeAT, we get a HTTP422 error
logger.debug("Updating SeAT username %s with email %s and password" % (user... | python | def update_user(cls, username, email, password):
""" Edit user info """
if cls._check_email_changed(username, email):
# if we try to set the email to whatever it is already on SeAT, we get a HTTP422 error
logger.debug("Updating SeAT username %s with email %s and password" % (user... | [
"def",
"update_user",
"(",
"cls",
",",
"username",
",",
"email",
",",
"password",
")",
":",
"if",
"cls",
".",
"_check_email_changed",
"(",
"username",
",",
"email",
")",
":",
"# if we try to set the email to whatever it is already on SeAT, we get a HTTP422 error",
"logg... | Edit user info | [
"Edit",
"user",
"info"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/seat/manager.py#L102-L117 |
allianceauth/allianceauth | allianceauth/services/hooks.py | NameFormatter.format_name | def format_name(self):
"""
:return: str Generated name
"""
format_data = self.get_format_data()
return Formatter().vformat(self.string_formatter, args=[], kwargs=format_data) | python | def format_name(self):
"""
:return: str Generated name
"""
format_data = self.get_format_data()
return Formatter().vformat(self.string_formatter, args=[], kwargs=format_data) | [
"def",
"format_name",
"(",
"self",
")",
":",
"format_data",
"=",
"self",
".",
"get_format_data",
"(",
")",
"return",
"Formatter",
"(",
")",
".",
"vformat",
"(",
"self",
".",
"string_formatter",
",",
"args",
"=",
"[",
"]",
",",
"kwargs",
"=",
"format_data... | :return: str Generated name | [
":",
"return",
":",
"str",
"Generated",
"name"
] | train | https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/hooks.py#L143-L148 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.