Skip to content

Commit

Permalink
Fix #4239: Don't include scientific notation in path strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Mar 18, 2015
1 parent be6a691 commit 0c8c640
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Binary file not shown.
12 changes: 12 additions & 0 deletions lib/matplotlib/tests/test_path.py
Expand Up @@ -99,6 +99,18 @@ def test_xkcd():
ax.plot(x, y)


@image_comparison(baseline_images=['marker_paths'], extensions=['pdf'],
remove_text=True)
def test_marker_paths_pdf():
N = 7

plt.errorbar(np.arange(N),
np.ones(N) + 4,
np.ones(N))
plt.xlim(-1, N)
plt.ylim(-1, 7)


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
6 changes: 3 additions & 3 deletions src/_path.h
Expand Up @@ -989,7 +989,7 @@ int __convert_to_string(PathIterator &path,
{
#if PY_VERSION_HEX < 0x02070000
char format[64];
snprintf(format, 64, "%s.%dg", "%", precision);
snprintf(format, 64, "%s.%df", "%", precision);
#endif

char *p = *buffer;
Expand Down Expand Up @@ -1031,14 +1031,14 @@ int __convert_to_string(PathIterator &path,
for (int i = 0; i < size; ++i) {
#if PY_VERSION_HEX >= 0x02070000
char *str;
str = PyOS_double_to_string(x[i], 'g', precision, 0, NULL);
str = PyOS_double_to_string(x[i], 'f', precision, 0, NULL);
if ((p = __append_to_string(p, buffer, buffersize, str)) == NULL) {
PyMem_Free(str);
return 1;
}
PyMem_Free(str);
if ((p = __append_to_string(p, buffer, buffersize, " ")) == NULL) return 1;
str = PyOS_double_to_string(y[i], 'g', precision, 0, NULL);
str = PyOS_double_to_string(y[i], 'f', precision, 0, NULL);
if ((p = __append_to_string(p, buffer, buffersize, str)) == NULL) {
PyMem_Free(str);
return 1;
Expand Down

0 comments on commit 0c8c640

Please sign in to comment.