numpy / numpy/numpy

Array creation in `numpy.mat` style

Open
#4,817 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

01 - Enhancement
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

Is there any function similar to numpy.mat to create an numpy.ndarray? I mean something equivolent to

np.array(np.mat('.2 .7 .1; .3 .5 .2; .1 .1 .9'))

which is a little bit verbose. And

np.array([[.2, .7, .1], [.3, .5, .2], [.1, .1, .9]])

sounds daunting for beginners. This might seem trivial (as mkarry = lambda s:np.array), but when I do some demonstrations to people who have never used Python, it matters.

Is there such a function in numpy? If no, is it sensible to add one in numpy?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing numpy.mat and NumPy's existing ndarray-construction APIs, then compare the requested compact string form with the two examples in the issue. Confirm whether a new public function is needed and define its accepted input and expected output before implementation; done means an agreed API with coverage for the demonstrated matrix form.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.