text stringlengths 81 112k |
|---|
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**.
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... |
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)... |
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"""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"""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 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 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 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 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"""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"""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):
r""... |
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"""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... |
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): ... |
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:`... |
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... |
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 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"""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... |
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... |
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
... |
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... |
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... |
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
... |
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... |
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 ... |
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 `... |
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 ... |
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... |
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 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, ..... |
Visit a ``literal_block`` node.
This verifies the state of each literal / code 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_t... |
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"""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"""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"""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... |
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 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 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... |
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"""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 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"""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... |
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... |
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... |
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... |
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.
... |
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
... |
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... |
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.
def subdivide(self):
"""Split the curve into a left and right half.
See :meth:`.Curv... |
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... |
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
... |
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
... |
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... |
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.... |
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-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
... |
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 ... |
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... |
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 ... |
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``.
def get_version():
"""Get the current version from ``setup.py``.... |
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 ``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 ``binary-extension.rst`` with release-specific data.
Args:
version (str): The current version.
def populate_native_libraries(version):
"""Populates ``binary-extension.rst`` with release-specific data.
Args:
version (str): The current version.
"""
with open(BINARY_EXT_TEM... |
Populates ``DEVELOPMENT.rst`` with release-specific data.
This is because ``DEVELOPMENT.rst`` is used in the Sphinx documentation.
Args:
version (str): The current version.
def populate_development(version):
"""Populates ``DEVELOPMENT.rst`` with release-specific data.
This is because ``DEVEL... |
Populate the templates with release-specific fields.
Requires user input for the CircleCI, AppVeyor, Coveralls.io and Travis
build IDs.
def main():
"""Populate the templates with release-specific fields.
Requires user input for the CircleCI, AppVeyor, Coveralls.io and Travis
build IDs.
"""
... |
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... |
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... |
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"""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"""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"""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} ... |
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... |
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... |
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"""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"""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"""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... |
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... |
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,
... |
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... |
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... |
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... |
Populate ``DESIRED_TEMPLATE`` with public members.
If there are no members, does nothing.
Returns:
str: The "desired" contents of ``bezier.rst``.
def get_desired():
"""Populate ``DESIRED_TEMPLATE`` with public members.
If there are no members, does nothing.
Returns:
str: The "de... |
Main entry point to replace autogenerated contents.
Raises:
ValueError: If the file doesn't contain the expected or
desired contents.
def main():
"""Main entry point to replace autogenerated contents.
Raises:
ValueError: If the file doesn't contain the expected or
... |
Cleanup after ``BuildFortranThenExt.run``.
For in-place builds, moves the built shared library into the source
directory.
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... |
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... |
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``).
def clean(session):
"""Clean up build files.
Cleans up all artifacts that might get cr... |
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... |
Get a specific sub module of the app
:param module_name: module name to get
:return: name, module tuple
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_module... |
Register all hooks found in 'auth_hooks' sub modules
:return:
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_s... |
Send an https api 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'}
... |
Add user to service
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', ... |
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 No... |
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
... |
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"... |
Compares email to one set on SeAT
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 |
Edit user info
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 p... |
:return: str Generated 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) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.