Skip to content

Commit 4b3a286

Browse files
committed
Minor notes/style fixes.
1 parent f09f8ee commit 4b3a286

File tree

7 files changed

+34
-27
lines changed

7 files changed

+34
-27
lines changed

README.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,15 @@ Test suite
279279

280280
Run ``run-mpl-test-suite.py`` to run the Matplotlib test suite with
281281
the Agg backend patched by the mplcairo backend. Matplotlib *must* be
282-
editably-installed from a git checkout. Certain tests that are known to fail
283-
(and listed in ``ISSUES.rst``) are automatically skipped.
282+
editably-installed from a git checkout.
283+
284+
Nearly all image comparison tests "fail" as the renderers are fundamentally
285+
different; currently, the intent is to manually check the diff images. Passing
286+
``--infinite-tolerance`` marks these tests as "passed" so that one can spot
287+
issues not related to rendering differences.
288+
289+
Some other (non-image-comparison) tests are also known to fail (they are listed
290+
in ``ISSUES.rst``, with the relevant explanations), and automatically skipped.
284291

285292
Notes
286293
=====

lib/mplcairo/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
_log = logging.getLogger()
33-
# FreeType2 is thread-unsafe (as we rely on Matplotlib's unique FT_Library).
33+
# FreeType2 is thread-unsafe.
3434
_LOCK = RLock()
3535
MathTextParser._backend_mapping[
3636
"mplcairo"] = _mplcairo.MathtextBackendCairo

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
if sys.platform == "darwin":
1414
os.environ.setdefault("CC", "clang")
15-
# Funnily enough, distutils uses $CC to compile c++ extensions but $CXX to
16-
# *link* such extensions... (Moreover, it does some funky changes to $CXX
17-
# if either $CC or $CXX has multiple words -- see UnixCCompiler.link for
18-
# details.)
15+
# Funnily enough, distutils uses $CC to compile c++ extensions but
16+
# $CXX to *link* such extensions... (Moreover, it does some funky
17+
# changes to $CXX if either $CC or $CXX has multiple words -- see e.g.
18+
# https://bugs.python.org/issue6863.)
1919
os.environ.setdefault("CXX", "clang")
2020

2121
from setupext import Extension, build_ext, find_packages, setup

src/_mplcairo.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,11 @@ GraphicsContextRenderer::~GraphicsContextRenderer()
166166
// not called on e.g. a SVG surface before the GCR gets GC'd. e.g. comment
167167
// out this catch, and _finish() in base.py, and run
168168
//
169-
// import gc
170-
// from matplotlib import pyplot as plt
171-
//
172-
// fig = plt.gcf()
173-
// file = open("/dev/null", "wb")
174-
// fig.savefig(file, format="svg")
175-
// file.close()
169+
// import gc; from matplotlib import pyplot as plt
170+
// with open("/dev/null", "wb") as file:
171+
// plt.gcf().savefig(file, format="svg")
176172
// plt.close("all")
177-
// del fig
178173
// gc.collect()
179-
// print("ok")
180174
std::cerr << "Exception ignored in destructor: " << e.what() << "\n";
181175
}
182176
}

src/_pattern_cache.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void PatternCache::CacheKey::draw(
4343
case draw_func_t::Stroke:
4444
cairo_save(cr);
4545
cairo_set_line_width(cr, linewidth);
46-
cairo_set_miter_limit(cr, linewidth); // cf. set_linewidth.
46+
cairo_set_miter_limit(cr, linewidth); // cf. set_linewidth.
4747
set_dashes(cr, dash);
4848
cairo_set_line_cap(cr, capstyle);
4949
cairo_set_line_join(cr, joinstyle);
@@ -82,7 +82,8 @@ size_t PatternCache::Hash::operator()(CacheKey const& key) const
8282
bool PatternCache::EqualTo::operator()(
8383
CacheKey const& lhs, CacheKey const& rhs) const
8484
{
85-
return (lhs.path.is(rhs.path))
85+
return
86+
lhs.path.is(rhs.path)
8687
&& lhs.matrix.xx == rhs.matrix.xx && lhs.matrix.xy == rhs.matrix.xy
8788
&& lhs.matrix.yx == rhs.matrix.yx && lhs.matrix.yy == rhs.matrix.yy
8889
&& lhs.matrix.x0 == rhs.matrix.x0 && lhs.matrix.y0 == rhs.matrix.y0
@@ -163,15 +164,15 @@ void PatternCache::mask(
163164
}
164165
}
165166
// Approximate ("quantize") the transform matrix, so that the transformed
166-
// path is within 3 x (thresholds/3) of the path transformed by the original
167-
// matrix. 1 x threshold will be added by the patterns_ cache.
167+
// path is within 3x(threshold/3) of the path transformed by the original
168+
// matrix. 1x threshold will be added by the patterns_ cache.
168169
// If the entire object is within the threshold of the origin in either
169170
// direction, then draw it directly, as doing otherwise would be highly
170171
// inaccurate (see e.g. test_mplot3d.test_quiver3d).
171172
auto const& bbox = it_bboxes->second;
172-
// Here, gcc 7.2 (not cairo) fails to extend the lifetime of the temporaries
173-
// whose references are bound to constant *references* (various issues on
174-
// bugzilla; see also gotw#88); so bind values instead.
173+
// Here, gcc 7.2 fails to extend the lifetime of the temporaries whose
174+
// references are bound to constant *references* (various issues on bugzilla;
175+
// see also gotw#88); so bind values instead.
175176
auto const x_max = std::max(std::abs(bbox.x), std::abs(bbox.x + bbox.width)),
176177
y_max = std::max(std::abs(bbox.y), std::abs(bbox.y + bbox.height));
177178
if (x_max < threshold_ || y_max < threshold_) {
@@ -202,7 +203,7 @@ void PatternCache::mask(
202203
case draw_func_t::Stroke:
203204
cairo_save(cr);
204205
cairo_set_line_width(cr, key.linewidth);
205-
cairo_set_miter_limit(cr, key.linewidth); // cf. set_linewidth.
206+
cairo_set_miter_limit(cr, key.linewidth); // cf. set_linewidth.
206207
set_dashes(cr, key.dash);
207208
cairo_stroke_extents(cr, &x0, &y0, &x1, &y1);
208209
cairo_restore(cr);
@@ -219,7 +220,7 @@ void PatternCache::mask(
219220
throw std::runtime_error("Unexpected insertion failure into cache");
220221
}
221222
}
222-
auto const& entry = it_patterns->second; // Reference, as we have a unique_ptr.
223+
auto const& entry = it_patterns->second;
223224
auto const& target_x = x + entry.x,
224225
& target_y = y + entry.y;
225226
auto const& i_target_x = std::floor(target_x),
@@ -236,6 +237,8 @@ void PatternCache::mask(
236237
auto const& raster_surface =
237238
cairo_image_surface_create(CAIRO_FORMAT_A8, width, height);
238239
auto const& raster_gcr =
240+
// FIXME: Looks like building a full new gcr is too costly :/ (involves
241+
// Python to build the additional state).
239242
GraphicsContextRenderer::make_pattern_gcr(raster_surface);
240243
key.draw(
241244
raster_gcr.cr_,

src/_raqm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#include "_raqm.h"
2+
23
#include "_os.h"
3-
#include "_macros.h"
44

55
#include <stdexcept>
66

7+
#include "_macros.h"
8+
79
namespace mplcairo {
810

911
namespace raqm {

src/_util.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include "_raqm.h"
21
#include "_util.h"
32

3+
#include "_raqm.h"
4+
45
#include <stack>
56

67
#include "_macros.h"

0 commit comments

Comments
 (0)