numbers.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. from __future__ import absolute_import
  2. # Copyright (c) 2010-2019 openpyxl
  3. try:
  4. # Python 2
  5. long = long
  6. except NameError:
  7. # Python 3
  8. long = int
  9. from decimal import Decimal
  10. NUMERIC_TYPES = (int, float, long, Decimal)
  11. try:
  12. import numpy
  13. NUMPY = True
  14. except ImportError:
  15. NUMPY = False
  16. if NUMPY:
  17. NUMERIC_TYPES = NUMERIC_TYPES + (numpy.short,
  18. numpy.ushort,
  19. numpy.intc,
  20. numpy.uintc,
  21. numpy.int_,
  22. numpy.uint,
  23. numpy.longlong,
  24. numpy.ulonglong,
  25. numpy.half,
  26. numpy.float16,
  27. numpy.single,
  28. numpy.double,
  29. numpy.longdouble,
  30. numpy.int8,
  31. numpy.int16,
  32. numpy.int32,
  33. numpy.int64,
  34. numpy.uint8,
  35. numpy.uint16,
  36. numpy.uint32,
  37. numpy.uint64,
  38. numpy.intp,
  39. numpy.uintp,
  40. numpy.float32,
  41. numpy.float64,
  42. numpy.float,
  43. numpy.bool_,
  44. numpy.floating,
  45. numpy.integer)
  46. try:
  47. import pandas
  48. PANDAS = True
  49. except ImportError:
  50. PANDAS = False