Skip to content

Commit c1fb5e6

Browse files
committed
fixed problem with matplotlib in tests
1 parent 250e3be commit c1fb5e6

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

.travis.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22
# travis-ci.org definition for stl_tools build
33
#
44

5-
language: python
6-
env:
7-
- PYTHON=python PYSUF='' PYVER=2.7
8-
- PYTHON=python3 PYSUF='3' PYVER=3.2
5+
language: erlang
96
python:
107
- "2.7"
11-
- "3.2"
128
# command to install dependencies
139
install:
14-
- sudo apt-get update # needed for python3-numpy
15-
- sudo apt-get install $PYTHON-dev
16-
- sudo apt-get install $PYTHON-numpy
17-
- sudo apt-get install $PYTHON-scipy
18-
- sudo apt-get install $PYTHON-setuptools
19-
- sudo apt-get install $PYTHON-nose
20-
- "sudo python setup.py build install"
10+
- sudo apt-get update -qq # needed for python3-numpy
11+
- sudo apt-get install -qq python-dev
12+
- sudo apt-get install -qq python-numpy
13+
- sudo apt-get install -qq python-scipy
14+
- sudo apt-get install -qq python-setuptools
15+
- sudo apt-get install -qq python-matplotlib
16+
- sudo apt-get install -qq python-nose
17+
2118
# command to run tests
22-
script: nosetests
19+
script:
20+
- sudo python setup.py build install
21+
- nosetests

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
stl_tools
44
=======================
5+
[![Build Status](https://travis-ci.org/thearn/stl_tools.png?branch=master)](https://travis-ci.org/thearn/stl_tools)
6+
57
Python code to generate STL geometry files from plain text, LaTeX code, and 2D numpy arrays (matrices).
68

79
This allows for rapid 3D printing of text, rendered equations, or simple digital images.
@@ -28,6 +30,7 @@ want to write Python code directly.
2830
- [Matplotlib](http://matplotlib.org/) 1.2.1 or higher (for rendering text and LaTeX to image data)
2931

3032
## Installation:
33+
3134
Run `python setup.py build install` to install.
3235

3336
This will check for the 3rd party

stl_tools/test/test_stl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import numpy as np
66
from scipy.misc import imresize
77
from stl_tools import text2array, numpy2stl, text2png
8-
from qimshow import qimshow
98

109
"""
1110
Some basic tests for stl_tools

stl_tools/text2png.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
2-
import pylab
2+
import matplotlib as mpl
3+
mpl.use('Agg')
4+
import matplotlib.pyplot as plt
35

46

57
def text2png(text, fn=None, fontsize=100):
@@ -16,19 +18,19 @@ def text2png(text, fn=None, fontsize=100):
1618
Returns: (None)
1719
"""
1820

19-
f = pylab.figure(frameon=False)
21+
f = plt.figure(frameon=False)
2022
ax = f.add_subplot(111)
21-
pylab.text(0.5, 0.5, text,
22-
horizontalalignment='center',
23-
verticalalignment='center',
24-
transform=ax.transAxes,
25-
fontsize=fontsize)
23+
plt.text(0.5, 0.5, text,
24+
horizontalalignment='center',
25+
verticalalignment='center',
26+
transform=ax.transAxes,
27+
fontsize=fontsize)
2628
ax.set_axis_off()
2729
ax.autoscale_view(True, True, True)
2830
if not fn:
2931
fn = ''.join(e for e in text if e.isalnum())
3032
f.savefig(fn + '.png', bbox_inches='tight')
31-
pylab.close()
33+
plt.close()
3234

3335

3436
def text2array(text, fontsize=100):
@@ -42,6 +44,6 @@ def text2array(text, fontsize=100):
4244
"""
4345

4446
text2png(text, fn="_text", fontsize=fontsize)
45-
A = pylab.imread("_text.png")[:, :, :3].mean(axis=2)
47+
A = plt.imread("_text.png")[:, :, :3].mean(axis=2)
4648
os.remove("_text.png")
4749
return A.max() - A

0 commit comments

Comments
 (0)