-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
DOC: improve record/structured array nomenclature & guide #5482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -432,7 +431,7 @@ Type strings | |||
Both arguments must be convertible to data-type objects in this | |||
case. The *base_dtype* is the data-type object that the new | |||
data-type builds on. This is how you could assign named fields to | |||
any built-in data-type object. | |||
any built-in data-type object, as done in :ref:`record arrays <arrays.classes.rec>`. |
There was a problem hiding this comment.
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.
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.
014f280
to
1bd0b4e
Compare
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
Merged, thats @ahaldane. |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.