|
9 | 9 |
|
10 | 10 | import operator |
11 | 11 |
|
12 | | -from pandas.core.base import StringMixin |
13 | 12 | from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass |
14 | 13 | from pandas.errors import AbstractMethodError |
15 | 14 | from pandas.compat.numpy import function as nv |
|
20 | 19 | _not_implemented_message = "{} does not implement {}." |
21 | 20 |
|
22 | 21 |
|
23 | | -class ExtensionArray(StringMixin): |
| 22 | +class ExtensionArray(object): |
24 | 23 | """Abstract base class for custom 1-D array types. |
25 | 24 |
|
26 | 25 | pandas will recognize instances of this class as proper arrays |
@@ -50,7 +49,7 @@ class ExtensionArray(StringMixin): |
50 | 49 | by overriding: |
51 | 50 |
|
52 | 51 | * _formatter |
53 | | - * __unicode__ |
| 52 | + * __repr__ |
54 | 53 |
|
55 | 54 | Some methods require casting the ExtensionArray to an ndarray of Python |
56 | 55 | objects with ``self.astype(object)``, which may be expensive. When |
@@ -658,7 +657,7 @@ def copy(self, deep=False): |
658 | 657 | # ------------------------------------------------------------------------ |
659 | 658 | # Printing |
660 | 659 | # ------------------------------------------------------------------------ |
661 | | - def __unicode__(self): |
| 660 | + def __repr__(self): |
662 | 661 | from pandas.io.formats.printing import format_object_summary |
663 | 662 |
|
664 | 663 | template = ( |
@@ -686,18 +685,22 @@ def _formatter(self, formatter=None): |
686 | 685 | Parameters |
687 | 686 | ---------- |
688 | 687 | formatter: GenericArrayFormatter, optional |
689 | | - The formatter this array is being rendered with. The formatter |
690 | | - may have a `.formatter` method already defined. By default, this |
691 | | - will be used if a `formatter` is passed, otherwise the formatter |
692 | | - is ``str``. |
| 688 | + The formatter this array is being rendered with. This will be |
| 689 | + passed when the ExtensionArray is being rendered inside of a |
| 690 | + Series, Index, or DataFrame. This will be ``None`` when called |
| 691 | + from a top-level ``repr(array)``. |
| 692 | +
|
| 693 | + By default, when ``formatter`` is passed, the return value |
| 694 | + is ``formatter.formatter``. Otherwise, the default formatter |
| 695 | + is ``repr``. |
693 | 696 |
|
694 | 697 | Returns |
695 | 698 | ------- |
696 | 699 | Callable[[Any], str] |
697 | 700 | A callable that gets instances of the scalar type and |
698 | 701 | returns a string. |
699 | 702 | """ |
700 | | - return getattr(formatter, 'formatter', None) or str |
| 703 | + return getattr(formatter, 'formatter', None) or repr |
701 | 704 |
|
702 | 705 | def _formatting_values(self): |
703 | 706 | # type: () -> np.ndarray |
|
0 commit comments