Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making all docs pages import external packages at least once. #257

Merged
merged 15 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ For example, to create a curve:

.. code-block:: python

>>> import bezier
>>> import numpy as np
>>> nodes1 = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, 0.0],
Expand Down
2 changes: 2 additions & 0 deletions README.rst.release.template
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ For example, to create a curve:

.. code-block:: python

>>> import bezier
>>> import numpy as np
>>> nodes1 = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, 0.0],
Expand Down
2 changes: 2 additions & 0 deletions README.rst.template
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ For example, to create a curve:

{code_block1}

>>> import bezier
>>> import numpy as np
>>> nodes1 = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, 0.0],
Expand Down
2 changes: 2 additions & 0 deletions docs/algorithms/curve-curve-intersection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Curve-Line Intersection
.. doctest:: intersect-1-8
:options: +NORMALIZE_WHITESPACE

>>> import bezier
>>> import numpy as np
>>> nodes1 = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, 0.0],
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ For example, to create a curve:

.. doctest:: getting-started

>>> import bezier
>>> import numpy as np
>>> nodes1 = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, 0.0],
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst.release.template
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ For example, to create a curve:

.. doctest:: getting-started

>>> import bezier
>>> import numpy as np
>>> nodes1 = np.asfortranarray([
... [0.0, 0.5, 1.0],
... [0.0, 1.0, 0.0],
Expand Down
7 changes: 7 additions & 0 deletions docs/releases/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ Additive Changes
``Curve.intersect()``
(`doc <https://bezier.readthedocs.io/en/2021.2.13.dev1/python/reference/bezier.curve.html#bezier.curve.Curve.intersect>`__)

Documentation
-------------

- Making all docs pages import external packages at least once
(`#257 <https://github.com/dhermes/bezier/pull/257>`__). Fixed
`#210 <https://github.com/dhermes/bezier/issues/210>`__.

.. |pypi| image:: https://img.shields.io/pypi/v/bezier/2021.2.13.dev1.svg
:target: https://pypi.org/project/bezier/2021.2.13.dev1/
:alt: PyPI link to release 2021.2.13.dev1
Expand Down
1 change: 1 addition & 0 deletions src/python/bezier/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Curve(_base.Base):
.. doctest:: curve-constructor

>>> import bezier
>>> import numpy as np
>>> nodes = np.asfortranarray([
... [0.0, 0.625, 1.0],
... [0.0, 0.5 , 0.5],
Expand Down
1 change: 1 addition & 0 deletions src/python/bezier/curved_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class CurvedPolygon:
.. doctest:: curved-polygon-constructor

>>> import bezier
>>> import numpy as np
>>> nodes0 = np.asfortranarray([
... [0.0, 1.0, 2.0],
... [0.0, -1.0, 0.0],
Expand Down
1 change: 1 addition & 0 deletions src/python/bezier/hazmat/algebraic_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def bezier_roots(coeffs):

.. doctest:: bezier-roots0

>>> import numpy as np
>>> coeffs0 = np.asfortranarray([12.0, 11.0, 8.0])
>>> companion0, _, _ = bernstein_companion(coeffs0)
>>> companion0
Expand Down
4 changes: 1 addition & 3 deletions src/python/bezier/hazmat/clipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def compute_implicit_line(nodes):
.. testsetup:: compute-implicit-line

import numpy as np
import bezier
from bezier.hazmat.clipping import compute_implicit_line

.. doctest:: compute-implicit-line
:options: +NORMALIZE_WHITESPACE

>>> import numpy as np
>>> nodes = np.asfortranarray([
... [0.0, 1.0, 3.0, 4.0],
... [0.0, 2.5, 0.5, 3.0],
Expand Down Expand Up @@ -127,7 +127,6 @@ def compute_fat_line(nodes):
.. testsetup:: compute-fat-line

import numpy as np
import bezier
from bezier.hazmat.clipping import compute_fat_line

.. doctest:: compute-fat-line
Expand Down Expand Up @@ -341,7 +340,6 @@ def clip_range(nodes1, nodes2):
.. testsetup:: clip-range-start, clip-range

import numpy as np
import bezier
from bezier.hazmat.clipping import clip_range

nodes1 = np.asfortranarray([
Expand Down
4 changes: 3 additions & 1 deletion src/python/bezier/hazmat/curve_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def compute_length(nodes):
return np.linalg.norm(first_deriv[:, 0], ord=2)

# NOTE: We import SciPy at runtime to avoid the import-time cost for users
# that don't pure Python curve helpers (e.g. if the ``_speedup``
# that don't need pure Python curve helpers (e.g. if the ``_speedup``
# module is available). The ``scipy`` import is a tad expensive.
import scipy.integrate # pylint: disable=import-outside-toplevel

Expand Down Expand Up @@ -506,6 +506,7 @@ def get_curvature(nodes, tangent_vec, s):
.. doctest:: get-curvature
:options: +NORMALIZE_WHITESPACE

>>> import numpy as np
>>> nodes = np.asfortranarray([
... [1.0, 0.75, 0.5, 0.25, 0.0],
... [0.0, 2.0 , -2.0, 2.0 , 0.0],
Expand Down Expand Up @@ -611,6 +612,7 @@ def newton_refine(nodes, point, s):
.. doctest:: newton-refine-curve
:options: +NORMALIZE_WHITESPACE

>>> import bezier
>>> nodes = np.asfortranarray([
... [0.0, 1.0, 3.0],
... [0.0, 2.0, 1.0],
Expand Down
2 changes: 1 addition & 1 deletion src/python/bezier/hazmat/geometric_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ def linearization_error(nodes):
.. testsetup:: linearization-error, linearization-error-fail

import numpy as np
import bezier
from bezier.hazmat.geometric_intersection import linearization_error

.. doctest:: linearization-error

>>> import numpy as np
>>> nodes = np.asfortranarray([
... [0.0, 3.0, 9.0],
... [0.0, 1.0, -2.0],
Expand Down
7 changes: 2 additions & 5 deletions src/python/bezier/hazmat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,11 @@ class UnsupportedDegree(NotImplementedError):
a small subset of possible degrees, so the implementation is
**degree-specific**:

.. testsetup:: unsupported-degree

import numpy as np
import bezier

.. doctest:: unsupported-degree
:options: +NORMALIZE_WHITESPACE

>>> import bezier
>>> import numpy as np
>>> degree = 5
>>> nodes = np.empty((2, degree + 1), order="F")
>>> curve = bezier.Curve(nodes, degree=degree)
Expand Down
2 changes: 2 additions & 0 deletions src/python/bezier/hazmat/intersection_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def realroots(*coeffs):

.. doctest:: newton-refine1

>>> import bezier
>>> import numpy as np
>>> nodes1 = np.asfortranarray([
... [0.0, 2.0, 4.0],
... [0.0, 4.0, 0.0],
Expand Down
4 changes: 3 additions & 1 deletion src/python/bezier/hazmat/triangle_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ def make_transform(degree, weights_a, weights_b, weights_c):

This is a helper used only by :func:`specialize_triangle`.

Applies the de Casteljau to the identity matrix, thus
Applies the de Casteljau algorithm to the identity matrix, thus
effectively caching the algorithm in a transformation matrix.

.. note::
Expand Down Expand Up @@ -1290,6 +1290,8 @@ def jacobian_det(nodes, degree, st_vals):
.. doctest:: jacobian-det
:options: +NORMALIZE_WHITESPACE

>>> import bezier
>>> import numpy as np
>>> nodes = np.asfortranarray([
... [0.0, 1.0, 2.0, 0.0, 1.5, 0.0],
... [0.0, 0.0, 0.0, 1.0, 1.5, 2.0],
Expand Down
4 changes: 2 additions & 2 deletions src/python/bezier/hazmat/triangle_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ def newton_refine(nodes, degree, x_val, y_val, s, t):

.. testsetup:: newton-refine-triangle

import numpy as np
import bezier
from bezier.hazmat.triangle_intersection import newton_refine

.. doctest:: newton-refine-triangle

>>> import bezier
>>> import numpy as np
>>> nodes = np.asfortranarray([
... [0.0, 1.0, 2.0, 2.0, 2.0, 0.0],
... [0.0, 0.0, 0.0, 1.0, 2.0, 2.0],
Expand Down
1 change: 1 addition & 0 deletions src/python/bezier/triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class Triangle(_base.Base):
.. doctest:: triangle-constructor

>>> import bezier
>>> import numpy as np
>>> nodes = np.asfortranarray([
... [0.0, 0.5, 1.0 , 0.125, 0.375, 0.25],
... [0.0, 0.0, 0.25, 0.5 , 0.375, 1.0 ],
Expand Down