Skip to content

DOC: improve record/structured array nomenclature & guide - #5482

Merged
charris merged 1 commit into
numpy:masterfrom
ahaldane:recordarray_doc
Jan 22, 2015
Merged

charris merged 1 commit into
numpy:masterfrom
ahaldane:recordarray_doc

Conversation

@ahaldane

Copy link
Copy Markdown
Member

This is an improvement, to better differentiate structured arrays, record arrays, and recarrays in the docs. I also added a section to the user guide about record arrays (numpy/doc/structured_arrays.py).

I also discussed these changes on the mailing list in a message "structured arrays, recarrays, and record arrays" on Jan 19 2015. Please look at that for a more detailed rationale.

I define a nomenclature where "structured array" refers to
ndarrays with structured dtype, "record array" refers to modified
ndarrays as created by np.rec.array, and "recarray" refers to ndarrays
viewed as np.recarray.

Comment thread doc/source/reference/arrays.dtypes.rst Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line may be over long.

@charris

charris commented Jan 22, 2015

Copy link
Copy Markdown
Member

LGTM apart from several nitpicks. Try to keep line length less than 80 characters.

This update adds a section better describing record arrays in the user
guide (numpy/doc/structured_arrays.py).

It also corrects nomenclature, such that "structured array" refers to
ndarrays with structured dtype, "record array" refers to modified
ndarrays as created by np.rec.array, and "recarray" refers to ndarrays
viewed as np.recarray. See the note at the end of the structured
array user guide.
@ahaldane

Copy link
Copy Markdown
Member Author

Thanks, I missed those long lines. It should all be fixed now.

charris added a commit that referenced this pull request Jan 22, 2015
DOC: improve record/structured array nomenclature & guide
@charris
charris merged commit 5b714c7 into numpy:master Jan 22, 2015
@charris

charris commented Jan 22, 2015

Copy link
Copy Markdown
Member

Merged, thats @ahaldane.

@ahaldane
ahaldane deleted the recordarray_doc branch January 25, 2015 19:14
ahaldane added a commit to ahaldane/numpy that referenced this pull request Jan 30, 2015
In numpy#5483, I solved the problem that a
"recarray" and a "record array" (nomenclature defined in
numpy#5482) looked identical by making
sure that a type's subclass was listed in the repr. However, recarrays
are still represented using the function 'rec.array' even though this
function technically creates record arrays, not recarrays.

So I have updated recarray.__repr__.

Setup:

    >>> a = np.array([(1,'ABC'), (2, "DEF")], dtype=[('foo', int), ('bar', 'S4')])
    >>> recordarr = np.rec.array(a)
    >>> recarr = a.view(np.recarray)

Behavior after numpy#5483:

    >>> recordarr
    rec.array([(1, 'ABC'), (2, 'DEF')],
          dtype=(numpy.record, [('foo', '<i8'), ('bar', 'S4')]))
    >>> recarr
    rec.array([(1, 'ABC'), (2, 'DEF')],
          dtype=[('foo', '<i8'), ('bar', 'S4')])

New Behavior:

    >>> recordarr
    rec.array([(1, 'ABC'), (2, 'DEF')],
          dtype=[('foo', '<i8'), ('bar', '|S4')])
    >>> recarr
    array([(1, 'ABC'), (2, 'DEF')],
          dtype=[('foo', '<i8'), ('bar', 'S4')]).view(numpy.recarray)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants