@@ -27,11 +27,11 @@ class ExtensionArray(object):
2727 * copy
2828 * _concat_same_type
2929
30- Some additional methods are available to satisfy pandas' internal, private
31- block API.
30+ Some additional methods are available to satisfy pandas' internals.
3231
3332 * _can_hold_na
3433 * _formatting_values
34+ * _constructor
3535
3636 This class does not inherit from 'abc.ABCMeta' for performance reasons.
3737 Methods and properties required by the interface raise
@@ -49,13 +49,32 @@ class ExtensionArray(object):
4949 assumptions on how the data are stored, just that it can be converted
5050 to a NumPy array.
5151
52- Extension arrays should be able to be constructed with instances of
53- the class, i.e. ``ExtensionArray(extension_array)`` should return
54- an instance, not error.
52+ There are a few restrictions on how ExtensionArrays are created.
53+
54+ * An ExtensionArray should be valid, i.e.
55+ ``ExtensionArray(extension_array)`` should return an instance
56+ * A sequence of the scalar type should be valid, i.e.
57+ ``ExtensionArray(Sequence[ExtensionDtype.type]])`` should return
58+ an instance, not error.
5559 """
5660 # '_typ' is for pandas.core.dtypes.generic.ABCExtensionArray.
5761 # Don't override this.
5862 _typ = 'extension'
63+
64+ @classmethod
65+ def _constructor (cls , data ):
66+ """Construct a new instance of of the extension array.
67+
68+ Parameters
69+ ----------
70+ data : Sequence
71+
72+ Returns
73+ -------
74+ ExtensionArray
75+ """
76+ return cls (data )
77+
5978 # ------------------------------------------------------------------------
6079 # Must be a Sequence
6180 # ------------------------------------------------------------------------
@@ -226,7 +245,7 @@ def unique(self):
226245 from pandas import unique
227246
228247 uniques = unique (self .astype (object ))
229- return type ( self ) (uniques )
248+ return self . _constructor (uniques )
230249
231250 # ------------------------------------------------------------------------
232251 # Indexing methods
0 commit comments