[Numpy-discussion] deprecate numpy.matrix

Nathaniel Smith njs at pobox.com
Mon Feb 10 11:31:20 EST 2014


On Mon, Feb 10, 2014 at 11:16 AM, Alexander Belopolsky <ndarray at mac.com> wrote:
>
> On Sun, Feb 9, 2014 at 4:59 PM, alex <argriffi at ncsu.edu> wrote:
>>
>> On the other hand, it really needs to be deprecated.
>
>
> While numpy.matrix may have its problems, a NEP should list a better
> rationale than the above to gain acceptance.
>
> Personally, I decided not to use numpy.matrix in production code about 10
> years ago and never looked back to that decision.  I've heard however that
> some of the worst inheritance warts have been fixed over the years.  I also
> resisted introducing inheritance  in the implementation of masked arrays,
> but I lost that argument.  For better or worse, inheritance from ndarray is
> here to stay and I would rather see numpy.matrix stay as a test-bed for
> fixing inheritance issues rather than see it deprecated and have the same
> issues pop up in ma or elsewhere.

In practice, the existence of np.matrix doesn't seem to have any
affect on whether inheritance issues get fixed. And in the long run, I
think the goal is to move people away from inheriting from np.ndarray.
Really the only good reason to inherit from np.ndarray right now, is
if there's something you want to do that is impossible without using
inheritance. But we're working on fixing those issues (e.g.,
__numpy_ufunc__ in the next release). And AFAICT most of the remaining
issues with inheritance simply cannot be fixed, because the
requirements are ill-defined and contradictory.

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org



More information about the NumPy-Discussion mailing list