diff --git a/.github/workflows/regression-tests.yml b/.github/workflows/regression-tests.yml
index a7124a55..3bf7e128 100644
--- a/.github/workflows/regression-tests.yml
+++ b/.github/workflows/regression-tests.yml
@@ -2,7 +2,7 @@ name: Regression tests
on:
push:
- branches: [ main ]
+ branches: [ main, remove-animation ]
pull_request:
branches: [ main ]
@@ -12,7 +12,11 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: ["3.8", "3.9", "3.10", "3.11"]
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
+ numpy-version: ["numpy<2.0.0", "numpy>=2.0.0"]
+ exclude:
+ - python-version: "3.8"
+ numpy-version: "numpy>=2.0.0"
steps:
- uses: actions/checkout@v3
@@ -25,6 +29,7 @@ jobs:
sudo apt-get install ffmpeg ghostscript
python -m pip install --upgrade pip
pip install coveralls
+ pip install "${{ matrix.numpy-version }}"
pip install .[all]
- name: Run tests
run: |
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644
index 00000000..f6a12ce2
--- /dev/null
+++ b/.readthedocs.yaml
@@ -0,0 +1,35 @@
+# Read the Docs configuration file for Sphinx projects
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+
+# Required
+version: 2
+
+# Set the OS, Python version and other tools you might need
+build:
+ os: ubuntu-22.04
+ tools:
+ python: "3.11"
+ # You can also specify other tool versions:
+ # nodejs: "20"
+ # rust: "1.70"
+ # golang: "1.20"
+
+# Build documentation in the "docs/" directory with Sphinx
+sphinx:
+ configuration: docs/conf.py
+ # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
+ # builder: "dirhtml"
+ # Fail on all warnings to avoid broken references
+ # fail_on_warning: true
+
+# Optionally build your docs in additional formats such as PDF and ePub
+# formats:
+# - pdf
+# - epub
+
+# Optional but recommended, declare the Python requirements required
+# to build your documentation
+# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
+python:
+ install:
+ - requirements: docs/requirements.txt
diff --git a/docs/installation.rst b/docs/installation.rst
index 160a0357..95b73e7c 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -26,15 +26,6 @@ Ghostscript, which can't be installed via pip. If you use `Conda `_
-(again, strongly recommended), you can install it as follows::
-
- $ conda install ffmpeg
-
.. _documentation:
Documentation
diff --git a/docs/reference.rst b/docs/reference.rst
index a1d859f6..ff9fc663 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -24,7 +24,6 @@ Python API
toyplot.locator.rst
toyplot.mark.rst
toyplot.marker.rst
- toyplot.mp4.rst
toyplot.pdf.rst
toyplot.png.rst
toyplot.projection.rst
diff --git a/docs/requirements.txt b/docs/requirements.txt
index d6364949..51ecf0ac 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -2,7 +2,7 @@ custom_inherit
ipython
multipledispatch
nbsphinx
-numpy
+numpy < 2.0.0
pypng
reportlab
sphinx >= 3.5
diff --git a/docs/toyplot.mp4.rst b/docs/toyplot.mp4.rst
deleted file mode 100644
index 454b1939..00000000
--- a/docs/toyplot.mp4.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-toyplot.mp4 module
-==================
-
-.. automodule:: toyplot.mp4
- :members:
- :undoc-members:
- :show-inheritance:
diff --git a/docs/tutorial.ipynb b/docs/tutorial.ipynb
index cbae5205..d9e49cd2 100644
--- a/docs/tutorial.ipynb
+++ b/docs/tutorial.ipynb
@@ -3,7 +3,12 @@
{
"cell_type": "raw",
"metadata": {
- "raw_mimetype": "text/restructuredtext"
+ "editable": true,
+ "raw_mimetype": "text/restructuredtext",
+ "slideshow": {
+ "slide_type": ""
+ },
+ "tags": []
},
"source": [
"Tutorial\n",
@@ -14,7 +19,7 @@
"\n",
"Welcome! This tutorial will introduce you to the basics of working with Toyplot.\n",
"\n",
- "Note: this tutorial was created in a [Jupyter](http://www.ipython.org) notebook and assumes that you're following-along in a notebook of your own. If you aren't using a notebook, you should read the user guide section on :ref:`rendering` for some important information on how to display your figures."
+ "Note: this tutorial was created in a `Jupyter `_ notebook and assumes that you're following-along in a notebook of your own. If you aren't using a notebook, you should read the user guide section on :ref:`rendering` for some important information on how to display your figures."
]
},
{
@@ -66,7 +71,7 @@
{
"data": {
"text/html": [
- "
"
]
},
@@ -13258,950 +13263,6 @@
"source": [
"toyplot.plot(x, x, marker=\"o\", xscale=\"linear\", yscale=\"log\", width=500);"
]
- },
- {
- "cell_type": "raw",
- "metadata": {
- "raw_mimetype": "text/restructuredtext"
- },
- "source": [
- "There are many more properties that control axes positioning and behavior - for more details, see :ref:`canvas-layout` and :ref:`cartesian-coordinates` in the user guide."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Animation"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Toyplot can also create animated figures, by recording changes to a figure over time. Assume you've setup the following scatterplot:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 57,
- "metadata": {},
- "outputs": [],
- "source": [
- "x = numpy.random.normal(size=100)\n",
- "y = numpy.random.normal(size=len(x))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 58,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "
"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "canvas = toyplot.Canvas(300, 300)\n",
- "axes = canvas.cartesian()\n",
- "mark = axes.scatterplot(x, y, size=10)"
- ]
- },
- {
- "cell_type": "raw",
- "metadata": {
- "raw_mimetype": "text/restructuredtext"
- },
- "source": [
- "Suppose we want to show the order in which the samples were drawn from some distribution. We could use the `fill` parameter to map each sample's index to a color, but an animation can be more intuitive. We can use :meth:`toyplot.canvas.Canvas.frames` to add a sequence of animation frames to the canvas. We pass the desired number of frames as an argument, iterate over the results which are instances of :class:`frame `. We can use the frame objects to retrieve information about each frame and specify changes to be made to the canvas at that frame. In the example below, we set the opacity of each scatterplot datum to 10% in the first frame, then change them back to 100% over the course of the animation:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 59,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "
"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "canvas = toyplot.Canvas(300, 300)\n",
- "axes = canvas.cartesian()\n",
- "mark = axes.scatterplot(x, y, size=10)\n",
- "\n",
- "for frame in canvas.frames(len(x) + 1):\n",
- " if frame.number == 0:\n",
- " for i in range(len(x)):\n",
- " frame.set_datum_style(mark, 0, i, style={\"opacity\":0.1})\n",
- " else:\n",
- " frame.set_datum_style(mark, 0, frame.number - 1, style={\"opacity\":1.0})"
- ]
}
],
"metadata": {
@@ -14221,9 +13282,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.11"
+ "version": "3.11.8"
}
},
"nbformat": 4,
- "nbformat_minor": 1
+ "nbformat_minor": 4
}
diff --git a/features/steps/administrivia.py b/features/steps/administrivia.py
index 0de9de35..01cd96d3 100644
--- a/features/steps/administrivia.py
+++ b/features/steps/administrivia.py
@@ -3,7 +3,6 @@
# rights in this software.
from behave import *
-import nose.tools
import os
import pkgutil
diff --git a/features/steps/backend.py b/features/steps/backend.py
index 32e1df52..da4ac633 100644
--- a/features/steps/backend.py
+++ b/features/steps/backend.py
@@ -6,11 +6,11 @@
import importlib
import io
-import nose.tools
import numpy
import os
import xml.etree.ElementTree as xml
+import test
import testing
if not os.path.exists(testing.backend_dir):
@@ -30,7 +30,7 @@ def step_impl(context):
target = os.path.join(testing.backend_dir, "%s.html" % context.name)
context.backend.render(context.canvas, target)
#html = xml.parse(target)
- #nose.tools.assert_equal(html.getroot().tag, "{http://www.w3.org/2000/svg}svg")
+ #test.assert_equal(html.getroot().tag, "{http://www.w3.org/2000/svg}svg")
@then(u'the canvas can be rendered to an html buffer')
@@ -38,14 +38,14 @@ def step_impl(context):
buffer = io.BytesIO()
context.backend.render(context.canvas, buffer)
#html = xml.parse(buffer.getvalue())
- #nose.tools.assert_equal(html.getroot().tag, "html")
+ #test.assert_equal(html.getroot().tag, "html")
@then(u'the canvas can be rendered to a returned html dom')
def step_impl(context):
html = context.backend.render(context.canvas)
- nose.tools.assert_is_instance(html, xml.Element)
- nose.tools.assert_equal(html.tag, "div")
+ test.assert_is_instance(html, xml.Element)
+ test.assert_equal(html.tag, "div")
@then(u'the canvas can be rendered to a pdf file')
@@ -70,8 +70,8 @@ def step_impl(context):
target = os.path.join(testing.backend_dir, "%s.png" % context.name)
context.backend.render(context.canvas, target)
image = testing.read_png(target)
- nose.tools.assert_equal(image.shape, (600, 600, 4))
- nose.tools.assert_equal(image.dtype, "uint8")
+ test.assert_equal(image.shape, (600, 600, 4))
+ test.assert_equal(image.dtype, "uint8")
@then(u'the canvas can be rendered to a png buffer')
@@ -81,38 +81,38 @@ def step_impl(context):
buffer.seek(0)
image = testing.read_png(buffer)
- nose.tools.assert_equal(image.shape, (600, 600, 4))
- nose.tools.assert_equal(image.dtype, "uint8")
+ test.assert_equal(image.shape, (600, 600, 4))
+ test.assert_equal(image.dtype, "uint8")
@then(u'the canvas can be rendered to a returned png document')
def step_impl(context):
png = context.backend.render(context.canvas)
image = testing.read_png(io.BytesIO(png))
- nose.tools.assert_equal(image.shape, (600, 600, 4))
- nose.tools.assert_equal(image.dtype, "uint8")
+ test.assert_equal(image.shape, (600, 600, 4))
+ test.assert_equal(image.dtype, "uint8")
@then(u'the canvas can be rendered to a 200 pixel wide png document')
def step_impl(context):
png = context.backend.render(context.canvas, width="200px")
image = testing.read_png(io.BytesIO(png))
- nose.tools.assert_equal(image.shape, (200, 200, 4))
- nose.tools.assert_equal(image.dtype, "uint8")
+ test.assert_equal(image.shape, (200, 200, 4))
+ test.assert_equal(image.dtype, "uint8")
@then(u'the canvas can be rendered to a 150 pixel high png document')
def step_impl(context):
png = context.backend.render(context.canvas, height="150px")
image = testing.read_png(io.BytesIO(png))
- nose.tools.assert_equal(image.shape, (150, 150, 4))
- nose.tools.assert_equal(image.dtype, "uint8")
+ test.assert_equal(image.shape, (150, 150, 4))
+ test.assert_equal(image.dtype, "uint8")
@then(u'the canvas can be rendered to a half scale png document')
def step_impl(context):
png = context.backend.render(context.canvas, scale=0.5)
image = testing.read_png(io.BytesIO(png))
- nose.tools.assert_equal(image.shape, (300, 300, 4))
- nose.tools.assert_equal(image.dtype, "uint8")
+ test.assert_equal(image.shape, (300, 300, 4))
+ test.assert_equal(image.dtype, "uint8")
@then(u'the canvas can be rendered to an svg file')
@@ -120,7 +120,7 @@ def step_impl(context):
target = os.path.join(testing.backend_dir, "%s.svg" % context.name)
context.backend.render(context.canvas, target)
svg = xml.parse(target)
- nose.tools.assert_equal(svg.getroot().tag, "{http://www.w3.org/2000/svg}svg")
+ test.assert_equal(svg.getroot().tag, "{http://www.w3.org/2000/svg}svg")
@then(u'the canvas can be rendered to an svg buffer')
@@ -128,11 +128,11 @@ def step_impl(context):
buffer = io.BytesIO()
context.backend.render(context.canvas, buffer)
#svg = xml.parse(buffer.getvalue())
- #nose.tools.assert_equal(svg.getroot().tag, "svg")
+ #test.assert_equal(svg.getroot().tag, "svg")
@then(u'the canvas can be rendered to a returned svg dom')
def step_impl(context):
svg = context.backend.render(context.canvas)
- nose.tools.assert_is_instance(svg, xml.Element)
- nose.tools.assert_equal(svg.tag, "svg")
+ test.assert_is_instance(svg, xml.Element)
+ test.assert_equal(svg.tag, "svg")
diff --git a/features/steps/bar-visualization.py b/features/steps/bar-visualization.py
index 78d93eaf..f183f078 100644
--- a/features/steps/bar-visualization.py
+++ b/features/steps/bar-visualization.py
@@ -6,7 +6,6 @@
import collections
-import nose.tools
import numpy.testing
import toyplot
diff --git a/features/steps/browser.py b/features/steps/browser.py
index 54a580ca..239cf789 100644
--- a/features/steps/browser.py
+++ b/features/steps/browser.py
@@ -4,7 +4,7 @@
from behave import *
-import nose.tools
+import test
import numpy
import sys
import toyplot.browser
@@ -17,10 +17,10 @@ def step_impl(context):
canvas, axes, mark = toyplot.plot(numpy.sin(numpy.linspace(0, 10)))
with unittest.mock.patch("webbrowser.open") as webbrowser_open:
toyplot.browser.show(canvas)
- nose.tools.assert_equal(webbrowser_open.call_count, 1)
- nose.tools.assert_true(
+ test.assert_equal(webbrowser_open.call_count, 1)
+ test.assert_true(
webbrowser_open.call_args[0][0].startswith("file://"))
- nose.tools.assert_equal(webbrowser_open.call_args[1]["new"], 1)
- nose.tools.assert_equal(webbrowser_open.call_args[1]["autoraise"], True)
+ test.assert_equal(webbrowser_open.call_args[1]["new"], 1)
+ test.assert_equal(webbrowser_open.call_args[1]["autoraise"], True)
diff --git a/features/steps/canvas.py b/features/steps/canvas.py
index 3eff0016..e2215cf3 100644
--- a/features/steps/canvas.py
+++ b/features/steps/canvas.py
@@ -6,7 +6,7 @@
import io
-import nose.tools
+import test
import numpy.testing
import toyplot
@@ -65,14 +65,14 @@ def step_impl(context):
@then(u'the canvas can be rendered in Jupyter as HTML')
def step_impl(context):
html = context.canvas._repr_html_()
- nose.tools.assert_is_instance(html, str)
+ test.assert_is_instance(html, str)
@then(u'the canvas can be rendered in Jupyter as a PNG image')
def step_impl(context):
png = context.canvas._repr_png_()
image = testing.read_png(io.BytesIO(png))
- nose.tools.assert_equal(image.shape, (600, 600, 4))
- nose.tools.assert_equal(image.dtype, "uint8")
+ test.assert_equal(image.shape, (600, 600, 4))
+ test.assert_equal(image.dtype, "uint8")
@then(u'numberlines can be added to the canvas using relative coordinates')
def step_impl(context):
diff --git a/features/steps/cartesian-coordinates.py b/features/steps/cartesian-coordinates.py
index 635b0939..43dadc1e 100644
--- a/features/steps/cartesian-coordinates.py
+++ b/features/steps/cartesian-coordinates.py
@@ -4,10 +4,10 @@
from behave import *
-import nose
import numpy
import toyplot.data
+import test
import testing
@@ -19,58 +19,58 @@ def step_impl(context):
@then(u'the cartesian axes can be rendered with hidden axes')
def step_impl(context):
context.axes.show = False
- nose.tools.assert_equal(context.axes.show, False)
+ test.assert_equal(context.axes.show, False)
@then(u'the cartesian axes can be rendered with axes label')
def step_impl(context):
context.axes.label.text = "Howdy!"
- nose.tools.assert_equal(context.axes.label.text, "Howdy!")
+ test.assert_equal(context.axes.label.text, "Howdy!")
context.axes.label.style = {"fill": "red"}
- nose.tools.assert_equal(context.axes.label.style["fill"], "red")
+ test.assert_equal(context.axes.label.style["fill"], "red")
@then(u'the cartesian axes can be rendered with hidden x axis')
def step_impl(context):
context.axes.x.show = False
- nose.tools.assert_equal(context.axes.x.show, False)
+ test.assert_equal(context.axes.x.show, False)
@then(u'the cartesian axes can be rendered with log-10 x scale')
def step_impl(context):
context.axes.x.scale = "log"
- nose.tools.assert_equal(context.axes.x.scale, ("log", 10))
+ test.assert_equal(context.axes.x.scale, ("log", 10))
@then(u'the cartesian axes can be rendered with hidden x spine')
def step_impl(context):
context.axes.x.spine.show = False
- nose.tools.assert_equal(context.axes.x.spine.show, False)
+ test.assert_equal(context.axes.x.spine.show, False)
@then(
u'the cartesian axes can be rendered with x spine at an explicit position')
def step_impl(context):
context.axes.x.spine.position = 0
- nose.tools.assert_equal(context.axes.x.spine.position, 0)
+ test.assert_equal(context.axes.x.spine.position, 0)
@then(u'the cartesian axes can be rendered with x spine at the high end of y')
def step_impl(context):
context.axes.x.spine.position = "high"
- nose.tools.assert_equal(context.axes.x.spine.position, "high")
+ test.assert_equal(context.axes.x.spine.position, "high")
@then(u'the cartesian axes can be rendered with styled x spine')
def step_impl(context):
context.axes.x.spine.style = {"stroke": "red"}
- nose.tools.assert_equal(context.axes.x.spine.style["stroke"], "red")
+ test.assert_equal(context.axes.x.spine.style["stroke"], "red")
@then(u'the cartesian axes can be rendered with visible x ticks')
def step_impl(context):
context.axes.x.ticks.show = True
- nose.tools.assert_equal(context.axes.x.ticks.show, True)
+ test.assert_equal(context.axes.x.ticks.show, True)
@then(u'the cartesian axes can be rendered with sized x ticks')
@@ -78,15 +78,15 @@ def step_impl(context):
context.axes.x.ticks.show = True
context.axes.x.ticks.far = 10
context.axes.x.ticks.near = 3
- nose.tools.assert_equal(context.axes.x.ticks.far, 10)
- nose.tools.assert_equal(context.axes.x.ticks.near, 3)
+ test.assert_equal(context.axes.x.ticks.far, 10)
+ test.assert_equal(context.axes.x.ticks.near, 3)
@then(u'the cartesian axes can be rendered with styled x ticks')
def step_impl(context):
context.axes.x.ticks.show = True
context.axes.x.ticks.style = {"stroke": "red"}
- nose.tools.assert_equal(context.axes.x.ticks.style["stroke"], "red")
+ test.assert_equal(context.axes.x.ticks.style["stroke"], "red")
@then(
@@ -95,7 +95,7 @@ def step_impl(context):
context.axes.x.ticks.show = True
locator = toyplot.locator.Uniform(count=11)
context.axes.x.ticks.locator = locator
- nose.tools.assert_is(context.axes.x.ticks.locator, locator)
+ test.assert_is(context.axes.x.ticks.locator, locator)
@then(
@@ -103,7 +103,7 @@ def step_impl(context):
def step_impl(context):
context.axes.x.ticks.show = True
context.axes.x.ticks.tick(index=0).style = {"stroke": "red"}
- nose.tools.assert_equal(
+ test.assert_equal(
context.axes.x.ticks.tick(index=0).style["stroke"], "red")
@@ -112,40 +112,40 @@ def step_impl(context):
def step_impl(context):
context.axes.x.ticks.show = True
context.axes.x.ticks.tick(value=0).style = {"stroke": "red"}
- nose.tools.assert_equal(
+ test.assert_equal(
context.axes.x.ticks.tick(value=0).style["stroke"], "red")
@then(u'the cartesian axes can be rendered with hidden x tick labels')
def step_impl(context):
context.axes.x.ticks.labels.show = False
- nose.tools.assert_equal(context.axes.x.ticks.labels.show, False)
+ test.assert_equal(context.axes.x.ticks.labels.show, False)
@then(u'the cartesian axes can be rendered with angled x tick labels')
def step_impl(context):
context.axes.x.ticks.labels.angle = 45
- nose.tools.assert_equal(context.axes.x.ticks.labels.angle, 45)
+ test.assert_equal(context.axes.x.ticks.labels.angle, 45)
context.axes.x.ticks.show = True
@then(u'the cartesian axes can be rendered with offset x tick labels')
def step_impl(context):
context.axes.x.ticks.labels.offset = "0.125in"
- nose.tools.assert_equal(context.axes.x.ticks.labels.offset, 12)
+ test.assert_equal(context.axes.x.ticks.labels.offset, 12)
@then(u'the cartesian axes can be rendered with styled x tick labels')
def step_impl(context):
context.axes.x.ticks.labels.style = {"fill": "red"}
- nose.tools.assert_equal(context.axes.x.ticks.labels.style["fill"], "red")
+ test.assert_equal(context.axes.x.ticks.labels.style["fill"], "red")
@then(
u'the cartesian axes can be rendered with x axis per-tick-label styles identified by index')
def step_impl(context):
context.axes.x.ticks.labels.label(index=0).style = {"fill": "red"}
- nose.tools.assert_equal(
+ test.assert_equal(
context.axes.x.ticks.labels.label(index=0).style["fill"], "red")
@@ -153,67 +153,67 @@ def step_impl(context):
u'the cartesian axes can be rendered with x axis per-tick-label styles identified by value')
def step_impl(context):
context.axes.x.ticks.labels.label(value=0).style = {"fill": "red"}
- nose.tools.assert_equal(
+ test.assert_equal(
context.axes.x.ticks.labels.label(value=0).style["fill"], "red")
@then(u'the cartesian axes can be rendered with x axis label')
def step_impl(context):
context.axes.x.label.text = "Howdy!"
- nose.tools.assert_equal(context.axes.x.label.text, "Howdy!")
+ test.assert_equal(context.axes.x.label.text, "Howdy!")
context.axes.x.label.style = {"fill": "red"}
- nose.tools.assert_equal(context.axes.x.label.style["fill"], "red")
+ test.assert_equal(context.axes.x.label.style["fill"], "red")
@then(u'the cartesian axes can be rendered with explicit x axis domain')
def step_impl(context):
context.axes.x.domain.min = 0
- nose.tools.assert_equal(context.axes.x.domain.min, 0)
+ test.assert_equal(context.axes.x.domain.min, 0)
context.axes.x.domain.max = 1
- nose.tools.assert_equal(context.axes.x.domain.max, 1)
+ test.assert_equal(context.axes.x.domain.max, 1)
@then(u'the cartesian axes can be rendered with hidden y axis')
def step_impl(context):
context.axes.y.show = False
- nose.tools.assert_equal(context.axes.y.show, False)
+ test.assert_equal(context.axes.y.show, False)
@then(u'the cartesian axes can be rendered with log-10 y scale')
def step_impl(context):
context.axes.y.scale = "log"
- nose.tools.assert_equal(context.axes.y.scale, ("log", 10))
+ test.assert_equal(context.axes.y.scale, ("log", 10))
@then(u'the cartesian axes can be rendered with hidden y spine')
def step_impl(context):
context.axes.y.spine.show = False
- nose.tools.assert_equal(context.axes.y.spine.show, False)
+ test.assert_equal(context.axes.y.spine.show, False)
@then(
u'the cartesian axes can be rendered with y spine at an explicit position')
def step_impl(context):
context.axes.y.spine.position = 10
- nose.tools.assert_equal(context.axes.y.spine.position, 10)
+ test.assert_equal(context.axes.y.spine.position, 10)
@then(u'the cartesian axes can be rendered with y spine at the high end of x')
def step_impl(context):
context.axes.y.spine.position = "high"
- nose.tools.assert_equal(context.axes.y.spine.position, "high")
+ test.assert_equal(context.axes.y.spine.position, "high")
@then(u'the cartesian axes can be rendered with styled y spine')
def step_impl(context):
context.axes.y.spine.style = {"stroke": "red"}
- nose.tools.assert_equal(context.axes.y.spine.style["stroke"], "red")
+ test.assert_equal(context.axes.y.spine.style["stroke"], "red")
@then(u'the cartesian axes can be rendered with visible y ticks')
def step_impl(context):
context.axes.y.ticks.show = True
- nose.tools.assert_equal(context.axes.y.ticks.show, True)
+ test.assert_equal(context.axes.y.ticks.show, True)
@then(u'the cartesian axes can be rendered with sized y ticks')
@@ -221,15 +221,15 @@ def step_impl(context):
context.axes.y.ticks.show = True
context.axes.y.ticks.near = 3
context.axes.y.ticks.far = 10
- nose.tools.assert_equal(context.axes.y.ticks.near, 3)
- nose.tools.assert_equal(context.axes.y.ticks.far, 10)
+ test.assert_equal(context.axes.y.ticks.near, 3)
+ test.assert_equal(context.axes.y.ticks.far, 10)
@then(u'the cartesian axes can be rendered with styled y ticks')
def step_impl(context):
context.axes.y.ticks.show = True
context.axes.y.ticks.style = {"stroke": "red"}
- nose.tools.assert_equal(context.axes.y.ticks.style["stroke"], "red")
+ test.assert_equal(context.axes.y.ticks.style["stroke"], "red")
@then(
@@ -238,7 +238,7 @@ def step_impl(context):
context.axes.y.ticks.show = True
locator = toyplot.locator.Uniform(count=5)
context.axes.y.ticks.locator = locator
- nose.tools.assert_is(context.axes.y.ticks.locator, locator)
+ test.assert_is(context.axes.y.ticks.locator, locator)
@then(
@@ -246,7 +246,7 @@ def step_impl(context):
def step_impl(context):
context.axes.y.ticks.show = True
context.axes.y.ticks.tick(index=0).style = {"stroke": "red"}
- nose.tools.assert_equal(
+ test.assert_equal(
context.axes.y.ticks.tick(index=0).style["stroke"], "red")
@@ -255,40 +255,40 @@ def step_impl(context):
def step_impl(context):
context.axes.y.ticks.show = True
context.axes.y.ticks.tick(value=0).style = {"stroke": "red"}
- nose.tools.assert_equal(
+ test.assert_equal(
context.axes.y.ticks.tick(value=0).style["stroke"], "red")
@then(u'the cartesian axes can be rendered with hidden y tick labels')
def step_impl(context):
context.axes.y.ticks.labels.show = False
- nose.tools.assert_equal(context.axes.y.ticks.labels.show, False)
+ test.assert_equal(context.axes.y.ticks.labels.show, False)
@then(u'the cartesian axes can be rendered with angled y tick labels')
def step_impl(context):
context.axes.y.ticks.labels.angle = -45
- nose.tools.assert_equal(context.axes.y.ticks.labels.angle, -45)
+ test.assert_equal(context.axes.y.ticks.labels.angle, -45)
context.axes.y.ticks.show = True
@then(u'the cartesian axes can be rendered with offset y tick labels')
def step_impl(context):
context.axes.y.ticks.labels.offset = "16px"
- nose.tools.assert_equal(context.axes.y.ticks.labels.offset, 16)
+ test.assert_equal(context.axes.y.ticks.labels.offset, 16)
@then(u'the cartesian axes can be rendered with styled y tick labels')
def step_impl(context):
context.axes.y.ticks.labels.style = {"fill": "red"}
- nose.tools.assert_equal(context.axes.y.ticks.labels.style["fill"], "red")
+ test.assert_equal(context.axes.y.ticks.labels.style["fill"], "red")
@then(
u'the cartesian axes can be rendered with y axis per-tick-label styles identified by index')
def step_impl(context):
context.axes.y.ticks.labels.label(index=0).style = {"fill": "red"}
- nose.tools.assert_equal(
+ test.assert_equal(
context.axes.y.ticks.labels.label(index=0).style["fill"], "red")
@@ -296,24 +296,24 @@ def step_impl(context):
u'the cartesian axes can be rendered with y axis per-tick-label styles identified by value')
def step_impl(context):
context.axes.y.ticks.labels.label(value=0).style = {"fill": "red"}
- nose.tools.assert_equal(
+ test.assert_equal(
context.axes.y.ticks.labels.label(value=0).style["fill"], "red")
@then(u'the cartesian axes can be rendered with y axis label')
def step_impl(context):
context.axes.y.label.text = "Howdy!"
- nose.tools.assert_equal(context.axes.y.label.text, "Howdy!")
+ test.assert_equal(context.axes.y.label.text, "Howdy!")
context.axes.y.label.style = {"fill": "red"}
- nose.tools.assert_equal(context.axes.y.label.style["fill"], "red")
+ test.assert_equal(context.axes.y.label.style["fill"], "red")
@then(u'the cartesian axes can be rendered with explicit y axis domain')
def step_impl(context):
context.axes.y.domain.min = 0
- nose.tools.assert_equal(context.axes.y.domain.min, 0)
+ test.assert_equal(context.axes.y.domain.min, 0)
context.axes.y.domain.max = 1
- nose.tools.assert_equal(context.axes.y.domain.max, 1)
+ test.assert_equal(context.axes.y.domain.max, 1)
@given(u'a shared axis')
diff --git a/features/steps/color.py b/features/steps/color.py
index 1c07a1e8..dd2f31be 100644
--- a/features/steps/color.py
+++ b/features/steps/color.py
@@ -6,7 +6,7 @@
from behave import *
import json
-import nose.tools
+import test
import numpy
import toyplot.color
@@ -31,7 +31,7 @@ def step_impl(context, value):
@then(u'toyplot.color.to_css should return {value}')
def step_impl(context, value):
- nose.tools.assert_equal(toyplot.color.to_css(context.value), value)
+ test.assert_equal(toyplot.color.to_css(context.value), value)
@given(u'a color value')
@@ -59,7 +59,7 @@ def step_impl(context):
@given(u'a color brewer category, the palette names for that category can be retrieved.')
def step_impl(context):
- nose.tools.assert_equal(toyplot.color.brewer.names("sequential"), [
+ test.assert_equal(toyplot.color.brewer.names("sequential"), [
'BlueGreen',
'BlueGreenYellow',
'BluePurple',
@@ -79,7 +79,7 @@ def step_impl(context):
'RedPurple',
'Reds',
])
- nose.tools.assert_equal(toyplot.color.brewer.names("diverging"), [
+ test.assert_equal(toyplot.color.brewer.names("diverging"), [
'BlueGreenBrown',
'BlueRed',
'BlueYellowRed',
@@ -90,7 +90,7 @@ def step_impl(context):
'PurpleOrange',
'Spectral',
])
- nose.tools.assert_equal(toyplot.color.brewer.names("qualitative"), [
+ test.assert_equal(toyplot.color.brewer.names("qualitative"), [
'Accent',
'Dark2',
'Paired',
@@ -104,12 +104,12 @@ def step_impl(context):
@given(u'a color brewer palette name, the color counts for that palette can be retrieved.')
def step_impl(context):
- nose.tools.assert_equal(toyplot.color.brewer.counts("BlueRed"), [3, 4, 5, 6, 7, 8, 9, 10, 11])
+ test.assert_equal(toyplot.color.brewer.counts("BlueRed"), [3, 4, 5, 6, 7, 8, 9, 10, 11])
@given(u'a color brewer palette name, the category for that palette can be retrieved.')
def step_impl(context):
- nose.tools.assert_equal(toyplot.color.brewer.category("BlueRed"), "diverging")
+ test.assert_equal(toyplot.color.brewer.category("BlueRed"), "diverging")
@when(u'the user creates a Color Brewer palette')
@@ -202,15 +202,15 @@ def step_impl(context):
@then(
u'individual values can be mapped to css colors by the diverging color map')
def step_impl(context):
- nose.tools.assert_equal(
+ test.assert_equal(
context.color_map.css(-1), "rgba(23.0%,29.9%,75.4%,1.000)")
- nose.tools.assert_equal(
+ test.assert_equal(
context.color_map.css(0), "rgba(23.0%,29.9%,75.4%,1.000)")
- nose.tools.assert_equal(
+ test.assert_equal(
context.color_map.css(0.5), "rgba(86.5%,86.5%,86.5%,1.000)")
- nose.tools.assert_equal(
+ test.assert_equal(
context.color_map.css(1), "rgba(70.6%,1.6%,15.0%,1.000)")
- nose.tools.assert_equal(
+ test.assert_equal(
context.color_map.css(2), "rgba(70.6%,1.6%,15.0%,1.000)")
@@ -242,21 +242,21 @@ def step_impl(context):
@then(u'the linear color map can map scalar values to css colors')
def step_impl(context):
- nose.tools.assert_equal(context.color_map.css(-1), "rgba(100.0%,0.0%,0.0%,1.000)")
- nose.tools.assert_equal(context.color_map.css(0), "rgba(100.0%,0.0%,0.0%,1.000)")
- nose.tools.assert_equal(context.color_map.css(0.5), "rgba(50.0%,0.0%,50.0%,1.000)")
- nose.tools.assert_equal(context.color_map.css(1), "rgba(0.0%,0.0%,100.0%,1.000)")
- nose.tools.assert_equal(context.color_map.css(2), "rgba(0.0%,0.0%,100.0%,1.000)")
+ test.assert_equal(context.color_map.css(-1), "rgba(100.0%,0.0%,0.0%,1.000)")
+ test.assert_equal(context.color_map.css(0), "rgba(100.0%,0.0%,0.0%,1.000)")
+ test.assert_equal(context.color_map.css(0.5), "rgba(50.0%,0.0%,50.0%,1.000)")
+ test.assert_equal(context.color_map.css(1), "rgba(0.0%,0.0%,100.0%,1.000)")
+ test.assert_equal(context.color_map.css(2), "rgba(0.0%,0.0%,100.0%,1.000)")
@then(u'the color map domain can be changed')
def step_impl(context):
- nose.tools.assert_equal(context.color_map.domain.min, 0)
- nose.tools.assert_equal(context.color_map.domain.max, 1)
+ test.assert_equal(context.color_map.domain.min, 0)
+ test.assert_equal(context.color_map.domain.max, 1)
context.color_map.domain.min = -1
context.color_map.domain.max = 2
- nose.tools.assert_equal(context.color_map.domain.min, -1)
- nose.tools.assert_equal(context.color_map.domain.max, 2)
+ test.assert_equal(context.color_map.domain.min, -1)
+ test.assert_equal(context.color_map.domain.max, 2)
@given(u'a starting color')
@@ -302,7 +302,7 @@ def step_impl(context):
@then(u'the palette should contain 8 colors')
def step_impl(context):
- nose.tools.assert_equal(len(context.palette), 8)
+ test.assert_equal(len(context.palette), 8)
@then(u'the default palette can be rendered as ipython html')
@@ -351,9 +351,9 @@ def step_impl(context):
testing.assert_color_equal(palette[0], (1, 0, 0, 1))
testing.assert_color_equal(palette[1], (0, 1, 0, 1))
testing.assert_color_equal(palette[-1], (0, 0, 1, 1))
- with nose.tools.assert_raises(IndexError):
+ with test.assert_raises(IndexError):
palette[3]
- with nose.tools.assert_raises(TypeError):
+ with test.assert_raises(TypeError):
palette[0:3]
@given(u'a color palette, callers can iterate over the colors')
@@ -363,7 +363,7 @@ def step_impl(context):
testing.assert_color_equal(next(color), (1, 0, 0, 1))
testing.assert_color_equal(next(color), (0, 1, 0, 1))
testing.assert_color_equal(next(color), (0, 0, 1, 1))
- with nose.tools.assert_raises(StopIteration):
+ with test.assert_raises(StopIteration):
next(color)
@given(u'a color palette, callers can retrieve colors by index')
@@ -375,8 +375,8 @@ def step_impl(context):
@given(u'a color palette, colors can retrieve css colors by index')
def step_impl(context):
palette = toyplot.color.Palette([(1, 0, 0), (0, 1, 0), (0, 0, 1)])
- nose.tools.assert_equal(palette.css(0), "rgba(100.0%,0.0%,0.0%,1.000)")
- nose.tools.assert_equal(palette.css(-1), "rgba(0.0%,0.0%,100.0%,1.000)")
+ test.assert_equal(palette.css(0), "rgba(100.0%,0.0%,0.0%,1.000)")
+ test.assert_equal(palette.css(-1), "rgba(0.0%,0.0%,100.0%,1.000)")
@given(u'a categorical color map, the map can be rendered as ipython html')
def step_impl(context):
@@ -402,6 +402,6 @@ def step_impl(context):
def step_impl(context):
colormap = toyplot.color.CategoricalMap(
toyplot.color.Palette(["red", "lime", "blue", (1, 1, 1)]))
- nose.tools.assert_equal(colormap.css(0), "rgba(100.0%,0.0%,0.0%,1.000)")
- nose.tools.assert_equal(colormap.css(-1), "rgba(100.0%,100.0%,100.0%,1.000)")
+ test.assert_equal(colormap.css(0), "rgba(100.0%,0.0%,0.0%,1.000)")
+ test.assert_equal(colormap.css(-1), "rgba(100.0%,100.0%,100.0%,1.000)")
diff --git a/features/steps/data-table.py b/features/steps/data-table.py
index daa32e28..96f665ca 100644
--- a/features/steps/data-table.py
+++ b/features/steps/data-table.py
@@ -3,7 +3,7 @@
# rights in this software.
from behave import *
-import nose.tools
+import test
import numpy.testing
import collections
@@ -41,26 +41,26 @@ def step_impl(context):
@then(u'the table should be empty')
def step_impl(context):
- nose.tools.assert_equal(len(context.data), 0)
- nose.tools.assert_equal(context.data.shape, (0, 0))
- nose.tools.assert_equal(list(context.data.items()), [])
- nose.tools.assert_equal(list(context.data.keys()), [])
- nose.tools.assert_equal(list(context.data.values()), [])
+ test.assert_equal(len(context.data), 0)
+ test.assert_equal(context.data.shape, (0, 0))
+ test.assert_equal(list(context.data.items()), [])
+ test.assert_equal(list(context.data.keys()), [])
+ test.assert_equal(list(context.data.values()), [])
@then(u'adding columns should change the table')
def step_impl(context):
context.data["a"] = numpy.arange(10)
- nose.tools.assert_equal(list(context.data.keys()), ["a"])
- nose.tools.assert_equal(context.data.shape, (10, 1))
+ test.assert_equal(list(context.data.keys()), ["a"])
+ test.assert_equal(context.data.shape, (10, 1))
context.data["b"] = context.data["a"] ** 2
- nose.tools.assert_equal(list(context.data.keys()), ["a", "b"])
- nose.tools.assert_equal(context.data.shape, (10, 2))
+ test.assert_equal(list(context.data.keys()), ["a", "b"])
+ test.assert_equal(context.data.shape, (10, 2))
context.data["c"] = numpy.zeros(10)
- nose.tools.assert_equal(list(context.data.keys()), ["a", "b", "c"])
- nose.tools.assert_equal(context.data.shape, (10, 3))
+ test.assert_equal(list(context.data.keys()), ["a", "b", "c"])
+ test.assert_equal(context.data.shape, (10, 3))
@then(u'columns can be retrieved by name')
@@ -70,7 +70,7 @@ def step_impl(context):
@then(u'partial columns can be retrieved by name and index')
def step_impl(context):
- nose.tools.assert_equal(context.data["a", 5], 5)
+ test.assert_equal(context.data["a", 5], 5)
@then(u'partial columns can be retrieved by name and slice')
@@ -81,69 +81,69 @@ def step_impl(context):
@then(u'partial tables can be retrieved by row index')
def step_impl(context):
table = context.data[5]
- nose.tools.assert_equal(list(table.keys()), ["a", "b", "c"])
- nose.tools.assert_equal(table.shape, (1, 3))
+ test.assert_equal(list(table.keys()), ["a", "b", "c"])
+ test.assert_equal(table.shape, (1, 3))
numpy.testing.assert_array_equal(table["a"], [5])
@then(u'partial tables can be retrieved by row slice')
def step_impl(context):
table = context.data[5:7]
- nose.tools.assert_equal(list(table.keys()), ["a", "b", "c"])
- nose.tools.assert_equal(table.shape, (2, 3))
+ test.assert_equal(list(table.keys()), ["a", "b", "c"])
+ test.assert_equal(table.shape, (2, 3))
numpy.testing.assert_array_equal(table["a"], [5,6])
@then(u'partial tables can be retrieved by row index and column name')
def step_impl(context):
table = context.data[5, "b"]
- nose.tools.assert_equal(list(table.keys()), ["b"])
- nose.tools.assert_equal(table.shape, (1, 1))
+ test.assert_equal(list(table.keys()), ["b"])
+ test.assert_equal(table.shape, (1, 1))
numpy.testing.assert_array_equal(table["b"], [25])
@then(u'partial tables can be retrieved by row slice and column name')
def step_impl(context):
table = context.data[5:7, "b"]
- nose.tools.assert_equal(list(table.keys()), ["b"])
- nose.tools.assert_equal(table.shape, (2, 1))
+ test.assert_equal(list(table.keys()), ["b"])
+ test.assert_equal(table.shape, (2, 1))
numpy.testing.assert_array_equal(table["b"], [25,36])
@then(u'partial tables can be retrieved by row index and column names')
def step_impl(context):
table = context.data[5, ["b", "a"]]
- nose.tools.assert_equal(list(table.keys()), ["b", "a"])
- nose.tools.assert_equal(table.shape, (1, 2))
+ test.assert_equal(list(table.keys()), ["b", "a"])
+ test.assert_equal(table.shape, (1, 2))
numpy.testing.assert_array_equal(table["a"], [5])
@then(u'partial tables can be retrieved by row slice and column names')
def step_impl(context):
table = context.data[5:7, ["b", "a"]]
- nose.tools.assert_equal(list(table.keys()), ["b", "a"])
- nose.tools.assert_equal(table.shape, (2, 2))
+ test.assert_equal(list(table.keys()), ["b", "a"])
+ test.assert_equal(table.shape, (2, 2))
numpy.testing.assert_array_equal(table["a"], [5,6])
@then(u'partial tables can be retrieved by column names')
def step_impl(context):
table = context.data[["b", "a"]]
- nose.tools.assert_equal(list(table.keys()), ["b", "a"])
- nose.tools.assert_equal(table.shape, (10, 2))
+ test.assert_equal(list(table.keys()), ["b", "a"])
+ test.assert_equal(table.shape, (10, 2))
@then(u'partial tables can be retrieved by row indices')
def step_impl(context):
table = context.data[[5, 7]]
- nose.tools.assert_equal(list(table.keys()), ["a", "b", "c"])
- nose.tools.assert_equal(table.shape, (2, 3))
+ test.assert_equal(list(table.keys()), ["a", "b", "c"])
+ test.assert_equal(table.shape, (2, 3))
numpy.testing.assert_array_equal(table["a"], [5, 7])
@then(u'columns can be replaced by name')
def step_impl(context):
context.data["c"] = numpy.ones(10)
- nose.tools.assert_equal(list(context.data.keys()), ["a", "b", "c"])
- nose.tools.assert_equal(context.data.shape, (10, 3))
+ test.assert_equal(list(context.data.keys()), ["a", "b", "c"])
+ test.assert_equal(context.data.shape, (10, 3))
numpy.testing.assert_array_equal(context.data["c"], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
@@ -174,48 +174,48 @@ def step_impl(context):
@then(u'partial columns can be masked by name and index')
def step_impl(context):
context.data["c", 3] = numpy.ma.masked
- nose.tools.assert_is(context.data["c"][3], numpy.ma.masked)
+ test.assert_is(context.data["c"][3], numpy.ma.masked)
@then(u'partial columns can be masked by name and slice')
def step_impl(context):
context.data["c", 8:10] = numpy.ma.masked
- nose.tools.assert_is(context.data["c"][8], numpy.ma.masked)
- nose.tools.assert_is(context.data["c"][9], numpy.ma.masked)
+ test.assert_is(context.data["c"][8], numpy.ma.masked)
+ test.assert_is(context.data["c"][9], numpy.ma.masked)
@then(u'deleting columns should change the table')
def step_impl(context):
del context.data["c"]
- nose.tools.assert_equal(list(context.data.keys()), ["a", "b"])
- nose.tools.assert_equal(context.data.shape, (10, 2))
+ test.assert_equal(list(context.data.keys()), ["a", "b"])
+ test.assert_equal(context.data.shape, (10, 2))
@then(u'new columns must have a string name')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
context.data[3] = numpy.arange(10)
@then(u'new columns must have the same number of rows as existing columns')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
context.data["c"] = numpy.random.random(4)
@then(u'new columns must be one-dimensional')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
context.data["c"] = numpy.random.random((10, 4))
@then(u'per-column metadata can be specified')
def step_impl(context):
- nose.tools.assert_equal(context.data.metadata("b"), {})
+ test.assert_equal(context.data.metadata("b"), {})
context.data.metadata("b")["foo"] = True
- nose.tools.assert_equal(context.data.metadata("b"), {"foo": True})
+ test.assert_equal(context.data.metadata("b"), {"foo": True})
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
context.data.metadata("c")
@@ -232,11 +232,11 @@ def step_impl(context):
@then(u'the toyplot.data.Table is empty')
def step_impl(context):
- nose.tools.assert_equal(len(context.data), 0)
- nose.tools.assert_equal(context.data.shape, (0, 0))
- nose.tools.assert_equal(list(context.data.items()), [])
- nose.tools.assert_equal(list(context.data.keys()), [])
- nose.tools.assert_equal(list(context.data.values()), [])
+ test.assert_equal(len(context.data), 0)
+ test.assert_equal(context.data.shape, (0, 0))
+ test.assert_equal(list(context.data.items()), [])
+ test.assert_equal(list(context.data.keys()), [])
+ test.assert_equal(list(context.data.values()), [])
@when(u'toyplot.data.Table is initialized with a toyplot.data.Table')
@@ -257,7 +257,7 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the columns')
def step_impl(context):
table = toyplot.data.Table(context.data)
- nose.tools.assert_equal(list(table.keys()), ["a", "b"])
+ test.assert_equal(list(table.keys()), ["a", "b"])
numpy.testing.assert_array_equal(
table["a"], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
numpy.testing.assert_array_equal(
@@ -272,7 +272,7 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the columns, sorted by key')
def step_impl(context):
table = toyplot.data.Table(context.data)
- nose.tools.assert_equal(list(table.keys()), ["a", "b"])
+ test.assert_equal(list(table.keys()), ["a", "b"])
numpy.testing.assert_array_equal(
table["a"], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
numpy.testing.assert_array_equal(
@@ -289,7 +289,7 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the matrix columns with generated keys')
def step_impl(context):
table = toyplot.data.Table(context.data)
- nose.tools.assert_equal(list(table.keys()), ["0", "1", "2", "3"])
+ test.assert_equal(list(table.keys()), ["0", "1", "2", "3"])
numpy.testing.assert_array_equal(
table["0"], [0, 4, 8, 12])
numpy.testing.assert_array_equal(
@@ -312,7 +312,7 @@ def step_impl(context):
@then(u'the toyplot.data.Table raises ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.data.Table(context.data)
@@ -333,10 +333,10 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the csv file columns')
def step_impl(context):
- nose.tools.assert_equal(context.data.shape, (362, 6))
- nose.tools.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS'])
+ test.assert_equal(context.data.shape, (362, 6))
+ test.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS'])
for column in context.data.values():
- nose.tools.assert_true(issubclass(column.dtype.type, numpy.character))
+ test.assert_true(issubclass(column.dtype.type, numpy.character))
@when(u'toyplot.data.Table is initialized with a csv file and conversion')
@@ -346,10 +346,10 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the csv file columns with numeric type')
def step_impl(context):
- nose.tools.assert_equal(context.data.shape, (362, 6))
- nose.tools.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS'])
+ test.assert_equal(context.data.shape, (362, 6))
+ test.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS'])
for column, column_type in zip(context.data.values(), [numpy.character, numpy.character, numpy.integer, numpy.integer, numpy.integer, numpy.integer]):
- nose.tools.assert_true(issubclass(column.dtype.type, column_type))
+ test.assert_true(issubclass(column.dtype.type, column_type))
@when(u'toyplot.data.Table is initialized with a pandas dataframe')
@@ -360,8 +360,8 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the data frame columns')
def step_impl(context):
- nose.tools.assert_equal(context.data.shape, (362, 6))
- nose.tools.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS'])
+ test.assert_equal(context.data.shape, (362, 6))
+ test.assert_equal(list(context.data.keys()), ['STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS'])
@when(u'toyplot.data.Table is initialized with a pandas dataframe with index')
@@ -372,8 +372,8 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the data frame columns plus an index column')
def step_impl(context):
- nose.tools.assert_equal(context.data.shape, (362, 7))
- nose.tools.assert_equal(list(context.data.keys()), ["index0", 'STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS'])
+ test.assert_equal(context.data.shape, (362, 7))
+ test.assert_equal(list(context.data.keys()), ["index0", 'STATION', 'STATION_NAME', 'DATE', 'TMAX', 'TMIN', 'TOBS'])
@when(u'toyplot.data.Table is initialized with a pandas dataframe with hierarchical index')
@@ -386,8 +386,8 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the data frame columns plus multiple index columns')
def step_impl(context):
- nose.tools.assert_equal(context.data.shape, (4, 6))
- nose.tools.assert_equal(list(context.data.keys()), ["index0", 'index1', '0', '1', '2', '3'])
+ test.assert_equal(context.data.shape, (4, 6))
+ test.assert_equal(list(context.data.keys()), ["index0", 'index1', '0', '1', '2', '3'])
@when(u'toyplot.data.Table is initialized with a pandas dataframe with hierarchical index and custom index format')
@@ -400,8 +400,8 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the data frame columns plus multiple custom format index columns')
def step_impl(context):
- nose.tools.assert_equal(context.data.shape, (4, 6))
- nose.tools.assert_equal(list(context.data.keys()), ["Index 0", 'Index 1', '0', '1', '2', '3'])
+ test.assert_equal(context.data.shape, (4, 6))
+ test.assert_equal(list(context.data.keys()), ["Index 0", 'Index 1', '0', '1', '2', '3'])
@when(u'toyplot.data.Table is initialized with a pandas dataframe with duplicate column names')
@@ -412,13 +412,13 @@ def step_impl(context):
@then(u'the toyplot.data.Table contains the data frame columns with uniqified column names')
def step_impl(context):
- nose.tools.assert_equal(list(context.data.keys()), ['STATION', 'DATE', 'STATION-1', 'DATE-1', 'DATE-2'])
+ test.assert_equal(list(context.data.keys()), ['STATION', 'DATE', 'STATION-1', 'DATE-1', 'DATE-2'])
@then(u'the table can be rendered as format ipython html string')
def step_impl(context):
html = context.data._repr_html_()
- nose.tools.assert_is_instance(html, str)
+ test.assert_is_instance(html, str)
testing.assert_html_equal(html, "data-table")
diff --git a/features/steps/data.py b/features/steps/data.py
index 0622753f..4d9900c9 100644
--- a/features/steps/data.py
+++ b/features/steps/data.py
@@ -3,7 +3,7 @@
# rights in this software.
from behave import *
-import nose.tools
+import test
import numpy.testing
import toyplot.data
diff --git a/features/steps/documentation.py b/features/steps/documentation.py
index abb2007f..b14294fd 100644
--- a/features/steps/documentation.py
+++ b/features/steps/documentation.py
@@ -3,7 +3,7 @@
# rights in this software.
from behave import *
-import nose.tools
+import test
import glob
import logging
diff --git a/features/steps/fill-visualization.py b/features/steps/fill-visualization.py
index 530c4604..a9ccfa3d 100644
--- a/features/steps/fill-visualization.py
+++ b/features/steps/fill-visualization.py
@@ -4,7 +4,6 @@
from behave import *
-import nose
import numpy
import toyplot.data
diff --git a/features/steps/format.py b/features/steps/format.py
index 3e5b6f30..86a7de0c 100644
--- a/features/steps/format.py
+++ b/features/steps/format.py
@@ -4,7 +4,7 @@
from behave import *
-import nose.tools
+import test
import numpy.testing
import toyplot.format
@@ -39,7 +39,7 @@ def step_impl(context, value, output):
value = eval(value)
output = eval(output)
prefix, separator, suffix = context.formatter.format(value)
- nose.tools.assert_equal(prefix, output[0])
- nose.tools.assert_equal(separator, output[1])
- nose.tools.assert_equal(suffix, output[2])
+ test.assert_equal(prefix, output[0])
+ test.assert_equal(separator, output[1])
+ test.assert_equal(suffix, output[2])
diff --git a/features/steps/image-visualization.py b/features/steps/image-visualization.py
index 1fedeb82..4270a9f0 100644
--- a/features/steps/image-visualization.py
+++ b/features/steps/image-visualization.py
@@ -6,7 +6,7 @@
import os
-import nose.tools
+import test
import numpy
import PIL.Image
import toyplot.color
@@ -21,89 +21,89 @@
def step_impl(context):
context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-L.png"))
context.image = context.image > 128
- nose.tools.assert_equal(context.image.shape, (256, 256, 1))
- nose.tools.assert_equal(context.image.dtype, "bool")
+ test.assert_equal(context.image.shape, (256, 256, 1))
+ test.assert_equal(context.image.dtype, "bool")
@given(u'a numpy 8 bit L image')
def step_impl(context):
context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-L.png"))
- nose.tools.assert_equal(context.image.shape, (256, 256, 1))
- nose.tools.assert_equal(context.image.dtype, "uint8")
+ test.assert_equal(context.image.shape, (256, 256, 1))
+ test.assert_equal(context.image.dtype, "uint8")
@given(u'a numpy 8 bit L image with colormap')
def step_impl(context):
context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-L.png"))
- nose.tools.assert_equal(context.image.shape, (256, 256, 1))
- nose.tools.assert_equal(context.image.dtype, "uint8")
+ test.assert_equal(context.image.shape, (256, 256, 1))
+ test.assert_equal(context.image.dtype, "uint8")
context.image = (context.image, toyplot.color.brewer.map("BlueRed"))
@given(u'a numpy 8 bit LA image')
def step_impl(context):
context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-LA.png"))
- nose.tools.assert_equal(context.image.shape, (256, 256, 2))
- nose.tools.assert_equal(context.image.dtype, "uint8")
+ test.assert_equal(context.image.shape, (256, 256, 2))
+ test.assert_equal(context.image.dtype, "uint8")
@given(u'a numpy 8 bit RGB image')
def step_impl(context):
context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-RGB.png"))
- nose.tools.assert_equal(context.image.shape, (256, 256, 3))
- nose.tools.assert_equal(context.image.dtype, "uint8")
+ test.assert_equal(context.image.shape, (256, 256, 3))
+ test.assert_equal(context.image.dtype, "uint8")
@given(u'a numpy 8 bit RGBA image')
def step_impl(context):
context.image = testing.read_png(os.path.join(art_dir, "toyplot-8-RGBA.png"))
- nose.tools.assert_equal(context.image.shape, (256, 256, 4))
- nose.tools.assert_equal(context.image.dtype, "uint8")
+ test.assert_equal(context.image.shape, (256, 256, 4))
+ test.assert_equal(context.image.dtype, "uint8")
@given(u'a pillow 8 bit L image')
def step_impl(context):
context.image = PIL.Image.open(os.path.join(art_dir, "toyplot-8-L.png"))
- nose.tools.assert_equal(context.image.size, (256, 256))
- nose.tools.assert_equal(context.image.mode, "L")
+ test.assert_equal(context.image.size, (256, 256))
+ test.assert_equal(context.image.mode, "L")
@given(u'a pillow 8 bit L image with colormap')
def step_impl(context):
context.image = PIL.Image.open(os.path.join(art_dir, "toyplot-8-L.png"))
- nose.tools.assert_equal(context.image.size, (256, 256))
- nose.tools.assert_equal(context.image.mode, "L")
+ test.assert_equal(context.image.size, (256, 256))
+ test.assert_equal(context.image.mode, "L")
context.image = (context.image, toyplot.color.brewer.map("BlueRed"))
@given(u'a pillow 8 bit RGB image')
def step_impl(context):
context.image = PIL.Image.open(os.path.join(art_dir, "toyplot-8-RGB.png"))
- nose.tools.assert_equal(context.image.size, (256, 256))
- nose.tools.assert_equal(context.image.mode, "RGB")
+ test.assert_equal(context.image.size, (256, 256))
+ test.assert_equal(context.image.mode, "RGB")
@given(u'a pillow 8 bit RGBA image')
def step_impl(context):
context.image = PIL.Image.open(os.path.join(art_dir, "toyplot-8-RGBA.png"))
- nose.tools.assert_equal(context.image.size, (256, 256))
- nose.tools.assert_equal(context.image.mode, "RGBA")
+ test.assert_equal(context.image.size, (256, 256))
+ test.assert_equal(context.image.mode, "RGBA")
@given(u'a non-square numpy 8 bit L image')
def step_impl(context):
numpy.random.seed(1234)
context.image = numpy.random.uniform(0, 1, size=(10, 5)).repeat(50, axis=0).repeat(50, axis=1)
- nose.tools.assert_equal(context.image.shape, (500, 250))
- nose.tools.assert_equal(context.image.dtype, "float64")
+ test.assert_equal(context.image.shape, (500, 250))
+ test.assert_equal(context.image.dtype, "float64")
@given(u'a non-square numpy 8 bit L image with colormap')
def step_impl(context):
numpy.random.seed(1234)
context.image = numpy.random.uniform(0, 1, size=(10, 5)).repeat(50, axis=0).repeat(50, axis=1)
- nose.tools.assert_equal(context.image.shape, (500, 250))
- nose.tools.assert_equal(context.image.dtype, "float64")
+ test.assert_equal(context.image.shape, (500, 250))
+ test.assert_equal(context.image.dtype, "float64")
context.image = (context.image, toyplot.color.linear.map("Blackbody"))
diff --git a/features/steps/legends.py b/features/steps/legends.py
index 12bba7c4..1583c4d7 100644
--- a/features/steps/legends.py
+++ b/features/steps/legends.py
@@ -3,7 +3,7 @@
# rights in this software.
from behave import *
-import nose.tools
+import test
import numpy
def sample_data():
diff --git a/features/steps/log-scale-axes.py b/features/steps/log-scale-axes.py
index 00a29c4f..8fb2460d 100644
--- a/features/steps/log-scale-axes.py
+++ b/features/steps/log-scale-axes.py
@@ -4,7 +4,6 @@
from behave import *
-import nose
import numpy
import toyplot.data
diff --git a/features/steps/plot-visualization.py b/features/steps/plot-visualization.py
index 96d5f028..af486c19 100644
--- a/features/steps/plot-visualization.py
+++ b/features/steps/plot-visualization.py
@@ -6,7 +6,7 @@
import collections
-import nose.tools
+import test
import numpy.testing
import toyplot
diff --git a/features/steps/projection.py b/features/steps/projection.py
index 283d98a7..0da8eb4c 100644
--- a/features/steps/projection.py
+++ b/features/steps/projection.py
@@ -3,7 +3,7 @@
# rights in this software.
from behave import *
-import nose.tools
+import test
import numpy.testing
import toyplot.projection
@@ -16,20 +16,20 @@ def step_impl(context):
@then(u'0 should project to 0')
def step_impl(context):
- nose.tools.assert_equal(context.projection(0), 0)
- nose.tools.assert_equal(context.projection.inverse(0), 0)
+ test.assert_equal(context.projection(0), 0)
+ test.assert_equal(context.projection.inverse(0), 0)
@then(u'0.5 should project to 50')
def step_impl(context):
- nose.tools.assert_equal(context.projection(0.5), 50)
- nose.tools.assert_equal(context.projection.inverse(50), 0.5)
+ test.assert_equal(context.projection(0.5), 50)
+ test.assert_equal(context.projection.inverse(50), 0.5)
@then(u'1 should project to 100')
def step_impl(context):
- nose.tools.assert_equal(context.projection(1.0), 100)
- nose.tools.assert_equal(context.projection.inverse(100), 1.0)
+ test.assert_equal(context.projection(1.0), 100)
+ test.assert_equal(context.projection.inverse(100), 1.0)
@given(u'A log10 projection with 1, 100 and 0, 100')
@@ -39,20 +39,20 @@ def step_impl(context):
@then(u'1 should project to 0')
def step_impl(context):
- nose.tools.assert_equal(context.projection(1), 0)
- nose.tools.assert_equal(context.projection.inverse(0), 1)
+ test.assert_equal(context.projection(1), 0)
+ test.assert_equal(context.projection.inverse(0), 1)
@then(u'10 should project to 50')
def step_impl(context):
- nose.tools.assert_equal(context.projection(10), 50)
- nose.tools.assert_equal(context.projection.inverse(50), 10)
+ test.assert_equal(context.projection(10), 50)
+ test.assert_equal(context.projection.inverse(50), 10)
@then(u'100 should project to 100')
def step_impl(context):
- nose.tools.assert_equal(context.projection(100), 100)
- nose.tools.assert_equal(context.projection.inverse(100), 100)
+ test.assert_equal(context.projection(100), 100)
+ test.assert_equal(context.projection.inverse(100), 100)
@given(u'A log10 projection with -100, 100 and 0, 100')
@@ -62,11 +62,11 @@ def step_impl(context):
@then(u'-100 should project to 0')
def step_impl(context):
- nose.tools.assert_equal(context.projection(-100), 0)
- nose.tools.assert_equal(context.projection.inverse(0), -100)
+ test.assert_equal(context.projection(-100), 0)
+ test.assert_equal(context.projection.inverse(0), -100)
@then(u'0 should project to 50')
def step_impl(context):
- nose.tools.assert_equal(context.projection(0), 50)
- nose.tools.assert_equal(context.projection.inverse(50), 0)
+ test.assert_equal(context.projection(0), 50)
+ test.assert_equal(context.projection.inverse(50), 0)
diff --git a/features/steps/rectangle-visualization.py b/features/steps/rectangle-visualization.py
index 976d4bac..d9150f5c 100644
--- a/features/steps/rectangle-visualization.py
+++ b/features/steps/rectangle-visualization.py
@@ -6,7 +6,7 @@
import collections
-import nose.tools
+import test
import numpy.testing
import toyplot
diff --git a/features/steps/scatterplot-visualization.py b/features/steps/scatterplot-visualization.py
index 70d7664a..6a934fc3 100644
--- a/features/steps/scatterplot-visualization.py
+++ b/features/steps/scatterplot-visualization.py
@@ -6,7 +6,7 @@
import collections
-import nose.tools
+import test
import numpy.testing
import toyplot
diff --git a/features/steps/table-visualization.py b/features/steps/table-visualization.py
index 423b2b27..34d635c1 100644
--- a/features/steps/table-visualization.py
+++ b/features/steps/table-visualization.py
@@ -4,7 +4,6 @@
from behave import *
-import nose
import numpy
import toyplot.data
diff --git a/features/steps/test.py b/features/steps/test.py
new file mode 100644
index 00000000..231f4194
--- /dev/null
+++ b/features/steps/test.py
@@ -0,0 +1,44 @@
+# Copyright 2014, Sandia Corporation. Under the terms of Contract
+# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain
+# rights in this software.
+
+
+import unittest
+
+# Repackaging existing tests for PEP-8.
+
+def assert_almost_equal(first, second, places=7, delta=None, msg=None):
+ return unittest.TestCase().assertAlmostEqual(first, second, places=places, msg=msg, delta=delta)
+
+def assert_dict_equal(first, second, msg=None):
+ return unittest.TestCase().assertDictEqual(first, second, msg)
+
+def assert_equal(first, second, msg=None):
+ return unittest.TestCase().assertEqual(first, second, msg)
+
+def assert_false(expr, msg=None):
+ return unittest.TestCase().assertFalse(expr, msg)
+
+def assert_is(first, second, msg=None):
+ return unittest.TestCase().assertIs(first, second, msg)
+
+def assert_is_instance(obj, cls, msg=None):
+ return unittest.TestCase().assertIsInstance(obj, cls, msg)
+
+def assert_is_none(expr, msg=None):
+ return unittest.TestCase().assertIsNone(expr, msg)
+
+def assert_logs(logger=None, level=None):
+ return unittest.TestCase().assertLogs(logger, level)
+
+def assert_no_logs(logger=None, level=None):
+ return unittest.TestCase().assertNoLogs(logger, level)
+
+def assert_raises(exception):
+ return unittest.TestCase().assertRaises(exception)
+
+def assert_sequence_equal(first, second, msg=None, seq_type=None):
+ return unittest.TestCase().assertSequenceEqual(first, second, msg, seq_type)
+
+def assert_true(expr, msg=None):
+ return unittest.TestCase().assertTrue(expr, msg)
diff --git a/features/steps/testing.py b/features/steps/testing.py
index d592fe3b..ae338cca 100644
--- a/features/steps/testing.py
+++ b/features/steps/testing.py
@@ -20,6 +20,8 @@
import toyplot.require
import toyplot.svg
+from toyplot.require import as_float
+
try:
import toyplot.pdf
except:
@@ -146,7 +148,7 @@ def attribute_mismatch(tag, key, avalue, bvalue):
def optional_float(value):
try:
- return float(value)
+ return as_float(value)
except:
return value
@@ -173,8 +175,8 @@ def assert_path_equal(tag, key, avalue, bvalue):
def assert_points_equal(tag, key, avalue, bvalue):
- alist = [float(value) for pair in avalue.split() for value in pair.split(",")]
- blist = [float(value) for pair in bvalue.split() for value in pair.split(",")]
+ alist = [as_float(value) for pair in avalue.split() for value in pair.split(",")]
+ blist = [as_float(value) for pair in bvalue.split() for value in pair.split(",")]
assert_mixed_list_equal(alist, blist, tag, key, avalue, bvalue)
@@ -205,7 +207,7 @@ def assert_dom_equal(a, b, exceptions):
continue
if exception.get("type", None) == "float":
- if not numpy.allclose(float(avalue), float(bvalue)):
+ if not numpy.allclose(as_float(avalue), as_float(bvalue)):
attribute_mismatch(a.tag, akey, avalue, bvalue)
elif exception.get("type", None) == "path":
assert_path_equal(a.tag, akey, avalue, bvalue)
@@ -336,7 +338,7 @@ def read_png(fobj):
if meta["bitdepth"] == 1:
image = numpy.resize(numpy.vstack(pixels), (height, width, planes))
elif meta["bitdepth"] == 8:
- image = numpy.resize(numpy.vstack(map(numpy.uint8, pixels)), (height, width, planes))
+ image = numpy.resize(numpy.vstack(list(map(numpy.uint8, pixels))), (height, width, planes))
return image
diff --git a/features/steps/text.py b/features/steps/text.py
index 16a45797..d81721a1 100644
--- a/features/steps/text.py
+++ b/features/steps/text.py
@@ -4,7 +4,7 @@
from behave import *
-import nose.tools
+import test
import toyplot.html
@@ -184,7 +184,7 @@ def step_impl(context):
@when(u'text is aligned with an unknown text-anchor value, an exception is raised.')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
context.axes.text(
0, 0, "Text!", style={"text-anchor": "foo"})
toyplot.html.render(context.canvas)
@@ -192,7 +192,7 @@ def step_impl(context):
@when(u'text is aligned with an unknown alignment-baseline value, an exception is raised.')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
context.axes.text(
0, 0, "Text!", style={"alignment-baseline": "foo"})
toyplot.html.render(context.canvas)
@@ -210,7 +210,7 @@ def step_impl(context, family):
@when(u'text is drawn with an unknown font family, an exception is raised.')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
context.axes.text(0, 0, "Font-family: nonexistent", style={"font-family": "nonexistent", "font-size": "32px"})
context.canvas._repr_html_()
diff --git a/features/steps/tick-locator.py b/features/steps/tick-locator.py
index ea5af381..76c96bbc 100644
--- a/features/steps/tick-locator.py
+++ b/features/steps/tick-locator.py
@@ -7,6 +7,7 @@
import numpy
import sys
import toyplot.locator
+from toyplot.require import as_float
import testing
@@ -223,7 +224,7 @@ def step_impl(context):
@given(u'a {count} {units} interval')
def step_impl(context, count, units):
- context.timestamp_interval = (float(count), units)
+ context.timestamp_interval = (as_float(count), units)
@given(u'an interval of days')
def step_impl(context):
diff --git a/features/steps/units.py b/features/steps/units.py
index 2313b5e4..a2d9abae 100644
--- a/features/steps/units.py
+++ b/features/steps/units.py
@@ -3,7 +3,7 @@
# rights in this software.
from behave import *
-import nose.tools
+import test
import toyplot.units
@@ -11,103 +11,103 @@
@when(
u'converting "0" without default units to points the response should be 0.0')
def step_impl(context):
- nose.tools.assert_equal(toyplot.units.convert("0", "pt"), 0.0)
+ test.assert_equal(toyplot.units.convert("0", "pt"), 0.0)
@when(
u'converting 0 without default units to points the response should be 0.0')
def step_impl(context):
- nose.tools.assert_equal(toyplot.units.convert(0, "pt"), 0.0)
+ test.assert_equal(toyplot.units.convert(0, "pt"), 0.0)
@when(
u'converting 72 without default units to points the response should be raise ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.units.convert(72, "pt")
@when(u'converting 72 with default units pt to in the response should be 1.0')
def step_impl(context):
- nose.tools.assert_equal(toyplot.units.convert(72, "in", default="pt"), 1.0)
+ test.assert_equal(toyplot.units.convert(72, "in", default="pt"), 1.0)
@when(u'converting "72pt" to in the response should be 1.0')
def step_impl(context):
- nose.tools.assert_equal(toyplot.units.convert("72pt", "in"), 1.0)
+ test.assert_equal(toyplot.units.convert("72pt", "in"), 1.0)
@when(u'converting (72, "pt") to in the response should be 1.0')
def step_impl(context):
- nose.tools.assert_equal(toyplot.units.convert((72, "pt"), "in"), 1.0)
+ test.assert_equal(toyplot.units.convert((72, "pt"), "in"), 1.0)
@when(
u'converting "100%" without reference to in the response should be raise ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.units.convert("100%", "in")
@when(u'converting "100%" with reference 1.0 to in the response should be 1.0')
def step_impl(context):
- nose.tools.assert_equal(
+ test.assert_equal(
toyplot.units.convert("100%", "in", reference=1.0), 1.0)
@when(u'converting "40%" with reference 1.0 to in the response should be 0.4')
def step_impl(context):
- nose.tools.assert_equal(
+ test.assert_equal(
toyplot.units.convert("40%", "in", reference=1.0), 0.4)
@when(u'converting "96px" to in the response should be 1.0')
def step_impl(context):
- nose.tools.assert_equal(toyplot.units.convert("96px", "in"), 1.0)
+ test.assert_equal(toyplot.units.convert("96px", "in"), 1.0)
@when(u'converting "96px" to pt the response should be 72.0')
def step_impl(context):
- nose.tools.assert_equal(toyplot.units.convert("96px", "pt"), 72.0)
+ test.assert_equal(toyplot.units.convert("96px", "pt"), 72.0)
@when(u'converting ".5in" to pt the response should be 36.0')
def step_impl(context):
- nose.tools.assert_equal(toyplot.units.convert(".5in", "pt"), 36.0)
+ test.assert_equal(toyplot.units.convert(".5in", "pt"), 36.0)
@when(u'converting "1in" to cm the response should be 2.54')
def step_impl(context):
- nose.tools.assert_almost_equal(toyplot.units.convert("1in", "cm"), 2.54)
+ test.assert_almost_equal(toyplot.units.convert("1in", "cm"), 2.54)
@when(u'converting "1furlong" to in the response should be raise ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.units.convert("1furlong", "in")
@when(u'converting ("72pt",) to in the response should be raise ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.units.convert(("72pt",), "in")
@when(u'converting "1in" to furlong the response should be raise ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.units.convert("1in", "furlong")
@when(u'converting [] to in the response should be raise ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.units.convert([], "in")
@when(u'converting ("1","cm") to in the response should be raise ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.units.convert(("1", "cm"), "in")
@when(u'converting (1,2) to in the response should be raise ValueError')
def step_impl(context):
- with nose.tools.assert_raises(ValueError):
+ with test.assert_raises(ValueError):
toyplot.units.convert((1, 2), "in")
diff --git a/features/steps/video.py b/features/steps/video.py
deleted file mode 100644
index b048beac..00000000
--- a/features/steps/video.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright 2014, Sandia Corporation. Under the terms of Contract
-# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain
-# rights in this software.
-
-from behave import *
-import nose.tools
-
-import collections
-import io
-import json
-import logging
-import numpy.testing
-import os
-import subprocess
-import sys
-import tempfile
-
-import testing
-
-try:
- import toyplot.mp4
-except:
- pass
-
-try:
- import toyplot.png
-except:
- pass
-
-
-@given(u'an animated canvas')
-def step_impl(context):
- context.canvas = toyplot.Canvas(
- style={"background-color": "white"}, width=600, height=600)
- axes = context.canvas.cartesian()
- scatterplot = axes.scatterplot(numpy.arange(10))
-
- for frame in context.canvas.frames(11):
- if frame.number == 0:
- for i in numpy.arange(10):
- frame.set_datum_style(scatterplot, 0, i, {"opacity": 0})
- else:
- frame.set_datum_style(
- scatterplot, 0, frame.number - 1, {"opacity": 1})
-
-
-@then(u'the canvas can be rendered as {type} video')
-def step_impl(context, type):
- nose.tools.assert_in(type, ["mp4"])
-
- def progress(frame):
- pass
- context.path = os.path.join(tempfile.mkdtemp(), "test.%s" % type)
- context.backend.render(context.canvas, context.path, progress=progress)
- sys.stderr.write("**** %s ****\n" % context.path)
- sys.stderr.flush()
-
- command = ["ffprobe", "-print_format", "json", "-show_format",
- "-show_streams", "-count_frames", context.path]
- ffprobe = subprocess.Popen(
- command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- stdout, stderr = ffprobe.communicate()
- video_metadata = json.loads(stdout.decode())
- logging.info("video metadata: %s", video_metadata)
- video_format = video_metadata["format"]
- nose.tools.assert_equal(video_format["nb_streams"], 1)
- nose.tools.assert_in(type, video_format["format_name"])
- video_stream = video_metadata["streams"][0]
- nose.tools.assert_equal(
- video_stream["codec_name"], "h264" if type == "mp4" else "vp8")
- nose.tools.assert_equal(video_stream["codec_type"], "video")
- nose.tools.assert_equal(video_stream["width"], 600)
- nose.tools.assert_equal(video_stream["height"], 600)
- nose.tools.assert_equal(video_stream["nb_read_frames"], "11")
-
-
-@then(u'the canvas can be rendered as png frames')
-def step_impl(context):
- for frame in toyplot.png.render_frames(context.canvas):
- image = testing.read_png(io.BytesIO(frame))
- nose.tools.assert_equal(image.shape, (600, 600, 4))
- nose.tools.assert_equal(image.dtype, "uint8")
-
-
-@when(u'an animation frame is created, its fields are populated correctly.')
-def step_impl(context):
- frame = toyplot.canvas.AnimationFrame(number=1, begin=2.3, end=2.4, count=1, changes=collections.defaultdict(lambda: collections.defaultdict(list)))
- nose.tools.assert_equal(frame.number, 1)
- nose.tools.assert_equal(frame.begin, 2.3)
- numpy.testing.assert_almost_equal(frame.length, 0.1)
- with nose.tools.assert_raises(ValueError):
- frame.set_mark_style(None, {})
- with nose.tools.assert_raises(ValueError):
- frame.set_datum_style(None, 0, 0, {})
-
-
-@when(u'a canvas is used to create an animation frame, its fields are populated correctly.')
-def step_impl(context):
- canvas = toyplot.Canvas()
- frame = canvas.frame(0.3, 0.4)
- nose.tools.assert_equal(frame.begin, 0.3)
- numpy.testing.assert_almost_equal(frame.length, 0.1)
- nose.tools.assert_equal(frame.number, 0)
-
- frame = canvas.frame(0.3, 0.4, 5)
- nose.tools.assert_equal(frame.begin, 0.3)
- numpy.testing.assert_almost_equal(frame.length, 0.1)
- nose.tools.assert_equal(frame.number, 5)
-
-
-
diff --git a/features/video.feature b/features/video.feature
deleted file mode 100644
index feaabb3b..00000000
--- a/features/video.feature
+++ /dev/null
@@ -1,17 +0,0 @@
-Feature: Video
- Scenario: Animation frame
- When an animation frame is created, its fields are populated correctly.
-
- Scenario: Canvas frame
- When a canvas is used to create an animation frame, its fields are populated correctly.
-
- Scenario Outline: Render animated canvas
- Given that the backend is available
- And an animated canvas
- Then the canvas can be rendered as
-
- Examples:
- | backend | format |
- | toyplot.png | png frames |
- | toyplot.mp4 | mp4 video |
-
diff --git a/notebooks/animation.ipynb b/notebooks/animation.ipynb
deleted file mode 100644
index e1cbf4e5..00000000
--- a/notebooks/animation.ipynb
+++ /dev/null
@@ -1,2941 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Animation"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Toyplot can also create animated figures, by recording changes to a figure over time. Assume you've setup the following scatterplot:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [],
- "source": [
- "import numpy\n",
- "x = numpy.random.normal(size=100)\n",
- "y = numpy.random.normal(size=len(x))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "
"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "import toyplot\n",
- "canvas = toyplot.Canvas(300, 300)\n",
- "axes = canvas.cartesian()\n",
- "mark = axes.scatterplot(x, y, size=10)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Suppose we want to show the order in which the samples were drawn from some distribution. We could use the `fill` parameter to map each sample's index to a color, but an animation can be more intuitive. We can use :meth:`toyplot.canvas.Canvas.animate` to add a sequence of animation frames to the canvas. We pass the number of frames and a callback function as arguments, and the callback function will be called once per frame with a single :class:`frame ` argument. The callback uses the frame object to retrieve information about the frame and record any changes that should be made to the canvas at that frame. In the example below, we set the opacity of each scatterplot datum to 5% in the first frame, then change them back to 100% over the course of the animation:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "scrolled": false
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "
"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "canvas = toyplot.Canvas(300, 300)\n",
- "axes = canvas.cartesian()\n",
- "mark = axes.scatterplot(x, y, size=10)\n",
- "text = canvas.text(150, 20, \" \")\n",
- "\n",
- "for frame in canvas.frames(len(x) + 1):\n",
- " label = \"%s/%s (%.2f s)\" % (frame.number + 1, frame.count, frame.begin)\n",
- " frame.set_datum_text(text, 0, 0, label)\n",
- " \n",
- " if frame.number == 0:\n",
- " for i in range(len(x)):\n",
- " frame.set_datum_style(mark, 0, i, style={\"opacity\":0.05})\n",
- " else:\n",
- " frame.set_datum_style(mark, 0, frame.number - 1, style={\"opacity\":1.0})"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Note from this example that each frame has a zero-based frame index, along with begin and end times, which are measured in seconds. If you look closely, you'll see that the difference in begin and end times is 0.03 seconds for each frame, which corresponds to a default 30 frames per second. If we want to control the framerate, we can pass a (frames, framerate) tuple when we call :meth:`toyplot.canvas.Canvas.animate` (note that the playback is slower, and the times for the frames are changed):"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "