same name and title in structured arrays
Hi, I've been finding numpy/scipy/matplotlib a very useful tool for data analysis. However, a recent change has caused me some problems. Numpy used to allow the name and title of a column of a structured array or recarray to be the same (at least in the svn version as of early last winter). Now, it seems that this is not allowed; see below. Python 2.6.5 (r265:79063, Apr 27 2010, 12:20:23) [GCC 4.2.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import numpy as np np.__version__ '2.0.0.dev-799179d' data = np.ndarray((5,1),dtype=[(('T','T'),float)]) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: title already used as a name or title. data = np.ndarray((5,1),dtype=[(('T at 0.25-in in F','T'),float)])
Would it be possible to change the tests to allow the name and title to be the same for the same component? I can work around this new limitation for new data files, but I'm having trouble reading data files I created last winter. (But even for new stuff, it would be nice if it name=title was allowed. I like using both names and titles so that I can record interesting information like point location and units in the titles. Sometimes, though, there isn't anything else interesting to say about a column (e.g., 'point','date', 'time'), and I'd like to (1) have both a title and a name to be consistent with more interesting columns and (2) have the title be equal to the name.) Thanks for any help you can give me with this! Kathy Tacina
On Mon, 13 Dec 2010 16:39:20 -0500, Kathleen M Tacina wrote:
I've been finding numpy/scipy/matplotlib a very useful tool for data analysis. However, a recent change has caused me some problems.
Numpy used to allow the name and title of a column of a structured array or recarray to be the same (at least in the svn version as of early last winter). Now, it seems that this is not allowed; see below.
Python 2.6.5 (r265:79063, Apr 27 2010, 12:20:23) [GCC 4.2.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import numpy as np np.__version__ '2.0.0.dev-799179d' data = np.ndarray((5,1),dtype=[(('T','T'),float)]) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: title already used as a name or title.
This behavior was changed when fixing #1254: http://projects.scipy.org/numpy/ticket/1254 It seems that it will not be possible to just revert to the old behavior, since apparently allowing that was a design mistake. The data loading routines however could in principle be changed to handle duplicate title/field combinations. How did you save your data, with numpy.save/numpy.savez or via pickling? -- Pauli Virtanen
participants (2)
-
Kathleen M Tacina
-
Pauli Virtanen