图片解析应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
944 B

  1. """
  2. Limited tests of the visualization module. Right now it just makes
  3. sure that passing custom Axes works.
  4. """
  5. from mpmath import mp, fp
  6. def test_axes():
  7. try:
  8. import matplotlib
  9. version = matplotlib.__version__.split("-")[0]
  10. version = version.split(".")[:2]
  11. if [int(_) for _ in version] < [0,99]:
  12. raise ImportError
  13. import pylab
  14. except ImportError:
  15. print("\nSkipping test (pylab not available or too old version)\n")
  16. return
  17. fig = pylab.figure()
  18. axes = fig.add_subplot(111)
  19. for ctx in [mp, fp]:
  20. ctx.plot(lambda x: x**2, [0, 3], axes=axes)
  21. assert axes.get_xlabel() == 'x'
  22. assert axes.get_ylabel() == 'f(x)'
  23. fig = pylab.figure()
  24. axes = fig.add_subplot(111)
  25. for ctx in [mp, fp]:
  26. ctx.cplot(lambda z: z, [-2, 2], [-10, 10], axes=axes)
  27. assert axes.get_xlabel() == 'Re(z)'
  28. assert axes.get_ylabel() == 'Im(z)'