Re: [Numpy-discussion] Enhancing dot()

2006-07-06 Thread Tim Hochberg
Bill Baxter wrote: > On 7/7/06, *Tim Hochberg* <[EMAIL PROTECTED] > > wrote: > > > The funny thing is that having a dot(a,b,c,...) would lead to the > > exact same kind of hidden performance problems you're arguing > against. > Not exactly arguing -- this

Re: [Numpy-discussion] Enhancing dot()

2006-07-06 Thread Bill Baxter
On 7/7/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > The funny thing is that having a dot(a,b,c,...) would lead to the> exact same kind of hidden performance problems you're arguing against.Not exactly arguing -- this isn't why I don't like H and friends -- just noting that this is one of the traps

Re: [Numpy-discussion] Call for a vote on .M .A .T .H attributes

2006-07-06 Thread Bill Baxter
On 7/7/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: 1) .T  Have some kind of .T attribute+1    If >0 on this then:    a) .T == .swapaxes(-2,-1)+1    b) .T == .transpose() +0    c) .T raises error for ndim > 2 +0    d) .T returns (N,1) array for length (N,) array +1   e) .T returns self for ndim <

Re: [Numpy-discussion] Enhancing dot()

2006-07-06 Thread Tim Hochberg
Bill Baxter wrote: > On 7/7/06, *Tim Hochberg* <[EMAIL PROTECTED] > > wrote: > > I'd caution here though that the H is another thing that's going to > encourage people to write code that's less accurate and slower than it > needs to be. Consider the simple equ

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/7/06, Robert Kern <[EMAIL PROTECTED]> wrote: Bill Baxter wrote:> I am also curious, given the number of times I've heard this nebulous> argument of "there are lots kinds of numerical computing that don't> invlolve linear algebra", that no one ever seems to name any of these > "lots of kinds". 

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sasha wrote: > On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > >> ... >> Yep, like Tim said. The usage is say a N sets of basis vectors. Each set >> of basis vectors is a matrix. >> > > This brings up a feature that I really miss from numpy: an ability to do > > array([f(x) for x in a

Re: [Numpy-discussion] Call for a vote on .M .A .T .H attributes

2006-07-06 Thread Sasha
On 7/7/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > 1) .T Have some kind of .T attribute > -1 (but -0 if raises an error if ndim != 2) >If >0 on this then: > >a) .T == .swapaxes(-2,-1) > >b) .T == .transpose() > >c) .T raises error for ndim > 2 > >d) .T returns (N,1) arra

Re: [Numpy-discussion] Call for a vote on .M .A .T .H attributes

2006-07-06 Thread Robert Kern
Travis Oliphant wrote: > This is a call for a vote on each of the math attributes. Please post > your vote as > > +1 : support > +0 : don't care so go ahead > -0 : don't care so why do it > -1 : against > > Vote on the following issues separately: > > 1) .T Have some kind of .T attribute

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > ... > Yep, like Tim said. The usage is say a N sets of basis vectors. Each set > of basis vectors is a matrix. This brings up a feature that I really miss from numpy: an ability to do array([f(x) for x in a]) without python overhead. APL-lik

Re: [Numpy-discussion] Call for a vote on .M .A .T .H attributes

2006-07-06 Thread Travis Oliphant
Travis Oliphant wrote: > This is a call for a vote on each of the math attributes. Please post > your vote as > > +1 : support > +0 : don't care so go ahead > -0 : don't care so why do it > -1 : against > > Vote on the following issues separately: > > > > 1) .T Have some kind of .T attribut

[Numpy-discussion] Call for a vote on .M .A .T .H attributes

2006-07-06 Thread Travis Oliphant
This is a call for a vote on each of the math attributes. Please post your vote as +1 : support +0 : don't care so go ahead -0 : don't care so why do it -1 : against Vote on the following issues separately: 1) .T Have some kind of .T attribute If >0 on this then: a) .T == .swa

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Robert Kern
Bill Baxter wrote: > On 7/7/06, *Robert Kern* <[EMAIL PROTECTED] > > wrote: > > Bill Baxter wrote: > > Robert Kern wrote: [snip] > > I don't think that just because arrays are often used for linear > > algebra that > > > > linear

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/7/06, Robert Kern <[EMAIL PROTECTED]> wrote: Bill Baxter wrote:> Robert Kern wrote:>>> The slippery slope argument only applies to the .M, not the .T or .H.No, it was the "Let's have a .T attribute. And if we're going to do that, then we should also do this. And this. And this."There's no slip

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Robert Kern
Bill Baxter wrote: > Robert Kern wrote: > > Like Sasha, I'm mildly opposed to .T (as a synonym for .transpose()) > and much > more opposed to the rest (including .T being a synonym for > .swapaxes(-2, -1)). > It's not often that a proposal carries with it its own > slippery

[Numpy-discussion] Enhancing dot()

2006-07-06 Thread Bill Baxter
On 7/7/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: I'd caution here though that the H is another thing that's going toencourage people to write code that's less accurate and slower than itneeds to be. Consider the simple equation:[Side note: Here's something I periodically think about -- it would b

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
Tim Wrote:That second argument is particularly uncompelling, but I think I agreethat in a vacuum swapaxes(-2,-1) would be a better choice for .T than reversing the axes. However, we're not in a vacuum and there are severalreasons not to do this.    1. A.T and A.transpose() should really have the sa

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sasha wrote: > On 7/6/06, Robert Kern <[EMAIL PROTECTED]> wrote: > >> ... >> I don't think that just because arrays are often used for linear algebra that >> linear algebra assumptions should be built in to the core array type. >> >> > > In addition, transpose is a (rank-2) array or matrix

Re: [Numpy-discussion] Speed degression?

2006-07-06 Thread Travis Oliphant
Arnd Baecker wrote: >Bingo! Only numpy 0.9.9.2749 + math is slower than >Numeric+math by a factor 1.6 and mod-array is 2.5 times slower >than numpy. >It would be nice if you could have a look at the module operation, >if possible ... > > O.K. I looked at how Python computed modulo and impleme

Re: [Numpy-discussion] More zaniness Re: simple question

2006-07-06 Thread Travis Oliphant
Mathew Yeates wrote: >okay, I went back to the binary windows distrib. Based on Keths code I wrote > > >> print numpy.asmatrix(all_dates == start_dates[row],dtype=int) >[[0 0 0 0 0 0 0 0 0 0 0 1 0 0]] > >> [row,numpy.asmatrix(all_dates == start_dates[row],dtype=int)] = -1 > >> print A[row,:] >[[-1

Re: [Numpy-discussion] More zaniness Re: simple question

2006-07-06 Thread Keith Goodman
On 7/6/06, Mathew Yeates <[EMAIL PROTECTED]> wrote: > okay, I went back to the binary windows distrib. Based on Keths code I wrote > > >> print numpy.asmatrix(all_dates == start_dates[row],dtype=int) > [[0 0 0 0 0 0 0 0 0 0 0 1 0 0]] > >> [row,numpy.asmatrix(all_dates == start_dates[row],dtype=in

[Numpy-discussion] More zaniness Re: simple question

2006-07-06 Thread Mathew Yeates
okay, I went back to the binary windows distrib. Based on Keths code I wrote >> print numpy.asmatrix(all_dates == start_dates[row],dtype=int) [[0 0 0 0 0 0 0 0 0 0 0 1 0 0]] >> [row,numpy.asmatrix(all_dates == start_dates[row],dtype=int)] = -1 >> print A[row,:] [[-1. -1. 0. 0. 0. 0. 0. 0.

Re: [Numpy-discussion] simple question

2006-07-06 Thread Keith Goodman
On 7/6/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Mathew Yeates wrote: > > >Not working. > >A[row,all_dates == 10] = -1 where all_dates is a matrix with column > >length of 14 [[960111,..,.. > >and A is a matrix with same column length > > > >I get > >IndexError: arrays used as indices must b

Re: [Numpy-discussion] simple question

2006-07-06 Thread Mathew Yeates
The very example you give produces IndexError: arrays used as indices must be of integer type this is with 0.9.8 Also .while your example says "rand" I had to say numpy.rand This is on WindowsXP Mathew Travis Oliphant wrote: > Mathew Yeates wrote: > >> Not working. >> A[row,all_dates == 10

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > ... > It looks even closer to † (dagger if that doesn't make it through) which > is the symbol used for the hermitian adjoint. If it pleases the matlab crowd, '+' can be defined to do the hermitian adjoint. on the complex type. > ... > Perhaps

Re: [Numpy-discussion] simple question

2006-07-06 Thread Travis Oliphant
Mathew Yeates wrote: >Not working. >A[row,all_dates == 10] = -1 where all_dates is a matrix with column >length of 14 [[960111,..,.. >and A is a matrix with same column length > >I get >IndexError: arrays used as indices must be of integer type > >when I print out all_dates == 10 >I get >[True Tr

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Robert Kern <[EMAIL PROTECTED]> wrote: > ... > I don't think that just because arrays are often used for linear algebra that > linear algebra assumptions should be built in to the core array type. > In addition, transpose is a (rank-2) array or matrix operation and not a linear algebra

Re: [Numpy-discussion] simple question

2006-07-06 Thread Mathew Yeates
Not working. A[row,all_dates == 10] = -1 where all_dates is a matrix with column length of 14 [[960111,..,.. and A is a matrix with same column length I get IndexError: arrays used as indices must be of integer type when I print out all_dates == 10 I get [True True True True True True True True

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Alexander Belopolsky wrote: > On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: >> ... >> Overloading '+' sure seems perverse, but maybe that's just me. >> > The first time I saw it, it seemed perverse to me as well, but it > actually make a lot of sense: > > 1. It is visually appealing as in '+'

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > ... > Overloading '+' sure seems perverse, but maybe that's just me. > The first time I saw it, it seemed perverse to me as well, but it actually make a lot of sense: 1. It is visually appealing as in '+' makes '|' from '-' and '-' from '|' and

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Alexander Belopolsky
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > ... > Overloading '+' sure seems perverse, but maybe that's just me. > The first time I saw it, it seemed perverse to me as well, but it actually make a lot of sense: 1. It is visually appealing as in '+' makes '|' from '-' and '-' from '|' and

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Alexander Belopolsky
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > ... > So this is essentially turning a row vector into a column vector? Is > that right? > Being a definition, this is neither right nor wrong. It all depends on what you are using it for. If you want to distinguish row and column vectors, you h

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Robert Kern
Travis Oliphant wrote: > Bill Baxter wrote: >> So in short my proposal is to: >> -- make a.T a property of array that returns a.swapaxes(-2,-1), >> -- make a.H a property of array that returns >> a.conjugate().swapaxes(-2,-1) >> and maybe >> -- make a.M a property of array that returns numpy.as

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sasha wrote: > On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > >> On 7/7/06, Sasha <[EMAIL PROTECTED]> wrote: >> ... I think it's much >> more common to want to swap just two axes, and the last two seem a logical >> choice since a) in the default C-ordering they're the closest together in >>

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > > > On 7/7/06, Sasha <[EMAIL PROTECTED]> wrote: > ... I think it's much > more common to want to swap just two axes, and the last two seem a logical > choice since a) in the default C-ordering they're the closest together in > memory and b) they'r

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sven Schreiber wrote: > Tim Hochberg schrieb: > > -) .I for inverse; actually, why not add that to arrays as well as "syntactic sugar"? >>> Because it encourages people to do the wrong thing numerically speaking? >>> My understanding is that one almost

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/7/06, Sasha <[EMAIL PROTECTED]> wrote: I would like to raise a few objections going from mild to strong:1. .T : I am mildly against it.  As an inexpensive operation thatreturns a view (so that a.T[...] = makes sense) it is a reasonablecandidate for an attribute.   Unfortunately reversing the o

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Keith Goodman
On 7/6/06, Sven Schreiber <[EMAIL PROTECTED]> wrote: > Maybe you guys as the developers of numpy should really make up your > mind about the future of matrices in numpy. Either it's supported, then > eventually I would expect matrix versions of ones, zeros, eye, for > example. (Although eye().M wo

Re: [Numpy-discussion] Numpy import problem

2006-07-06 Thread Christopher Barker
Satellite Data Research Group wrote: > Hi, I have a problem when importing numpy into python 2.4.1. I did a > successful (I think) build and install of Numpy 0.9.8 on a mac osx > (10.4) intel, Which Python 2.4.1 are you using? It would be great if you would give the Python2.4.3 version found

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sven Schreiber
Tim Hochberg schrieb: >>> -) .I for inverse; actually, why not add that to arrays as well as >>> "syntactic sugar"? >>> >>> >> Because it encourages people to do the wrong thing numerically speaking? >> My understanding is that one almost never wants to compute the inverse >> directly, a

Re: [Numpy-discussion] simple question

2006-07-06 Thread Christopher Barker
Mathew Yeates wrote: > o. I was looking at using "where" There's nothing wrong with where: >>> y = N.asmatrix(N.rand(3,3)) >>> y matrix([[ 0.29741635, 0.78756994, 0.641378 ], [ 0.0198837 , 0.71677631, 0.76068183], [ 0.84904382, 0.80169706, 0.23877389]]) >>> x = N.a

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sasha
I would like to raise a few objections going from mild to strong: 1. .T : I am mildly against it. As an inexpensive operation that returns a view (so that a.T[...] = makes sense) it is a reasonable candidate for an attribute. Unfortunately reversing the order of axes at least as reasonable as sw

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Bill Baxter wrote: > On 7/6/06, *Tim Hochberg* <[EMAIL PROTECTED] > > wrote: > > > -) Being able to distinguish between row and column vectors; I guess > > this is just not possible with arrays... > > > Why can't you distinguish between them the same way t

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Tim Hochberg wrote: > Sven Schreiber wrote: > >> Travis Oliphant schrieb: >> >> >>> Bill Baxter wrote: >>> >>> So in short my proposal is to: -- make a.T a property of array that returns a.swapaxes(-2,-1), -- make a.H a property of array that returns a.

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/6/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > -) Being able to distinguish between row and column vectors; I guess> this is just not possible with arrays...>Why can't you distinguish between them the same way that the matrixclass does? Shape [1, N] is a row array, shape [N,1] is column array

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Tim Hochberg
Sven Schreiber wrote: > Travis Oliphant schrieb: > >> Bill Baxter wrote: >> >>> So in short my proposal is to: >>> -- make a.T a property of array that returns a.swapaxes(-2,-1), >>> -- make a.H a property of array that returns >>> a.conjugate().swapaxes(-2,-1) >>> and maybe >>> -- make

Re: [Numpy-discussion] Speed degression?

2006-07-06 Thread Arnd Baecker
On Thu, 6 Jul 2006, Travis Oliphant wrote: > Arnd Baecker wrote: > > Hi > >>> i made some speed tests using the sin-function and the %-operation to > >>> compare > >>> Numeric, numpy 0.9.8 and numpy 0.9.9.2732. > >>> As result the latest numpy version seems to be very slow in comparison to > >>>

Re: [Numpy-discussion] Speed degression?

2006-07-06 Thread Travis Oliphant
Arnd Baecker wrote: > Hi >>> i made some speed tests using the sin-function and the %-operation to >>> compare >>> Numeric, numpy 0.9.8 and numpy 0.9.9.2732. >>> As result the latest numpy version seems to be very slow in comparison to >>> the >>> two other candidates. >>> Arrgggh. It lo

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Bill Baxter
On 7/6/06, Sven Schreiber <[EMAIL PROTECTED]> wrote: Travis Oliphant schrieb:> Bill Baxter wrote:>> So in short my proposal is to:>> --  make a.T a property of array that returns a.swapaxes(-2,-1),>> --  make a.H a property of array that returns >> a.conjugate().swapaxes(-2,-1)>> and maybe>> --  ma

Re: [Numpy-discussion] Speed degression?

2006-07-06 Thread Arnd Baecker
Hi Travis, On Thu, 6 Jul 2006, Travis Oliphant wrote: > Steffen Loeck wrote: > > Hi all, > > > > i made some speed tests using the sin-function and the %-operation to > > compare > > Numeric, numpy 0.9.8 and numpy 0.9.9.2732. > > As result the latest numpy version seems to be very slow in compar

Re: [Numpy-discussion] Dot as a method

2006-07-06 Thread Bart Vandereycken
Tim Hochberg wrote: > Bart Vandereycken wrote: >> Hi all, >> >> reading the thread "Ransom proposals" I was wondering why there isn't a >> ndarray.dot() method? There is already a scipy.sparse.dot() so this >> would fit nicely in the whole idea of polymorphism. >> > Are you sure about that? >

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Sven Schreiber
Travis Oliphant schrieb: > Bill Baxter wrote: >> So in short my proposal is to: >> -- make a.T a property of array that returns a.swapaxes(-2,-1), >> -- make a.H a property of array that returns >> a.conjugate().swapaxes(-2,-1) >> and maybe >> -- make a.M a property of array that returns numpy.

Re: [Numpy-discussion] Speed degression?

2006-07-06 Thread Travis Oliphant
Steffen Loeck wrote: > Hi all, > > i made some speed tests using the sin-function and the %-operation to compare > Numeric, numpy 0.9.8 and numpy 0.9.9.2732. > As result the latest numpy version seems to be very slow in comparison to the > two other candidates. > > Results (in usec per loop): >

Re: [Numpy-discussion] .T Transpose shortcut for arrays again

2006-07-06 Thread Travis Oliphant
Bill Baxter wrote: > So in short my proposal is to: > -- make a.T a property of array that returns a.swapaxes(-2,-1), > -- make a.H a property of array that returns > a.conjugate().swapaxes(-2,-1) > and maybe > -- make a.M a property of array that returns numpy.asmatrix(a) I've tentatively imp

Re: [Numpy-discussion] Determining if two arrays share data

2006-07-06 Thread Rob W.W. Hooft
Albert Strasheim wrote: > I think we might be talking about two related but different concepts. One is > sharing of data between arrays, the other is whether the data overlaps. When is it useful to know whether data buffers overlap? As long as they are disjoint, it should be irrelevant at the hig

[Numpy-discussion] bug in svn/numpy/numpy/doc/swig/numpy.i

2006-07-06 Thread Zhang Le
Hi, I found a bug in svn/numpy/numpy/doc/swig/numpy.i: a ')' is missed at line 72 which causes a compilation error: if (is_array(input) && (typecode == PyArray_NOTYPE || PyArray_EquivTypenums(array_type(input), typecode))) { ^ missing ary = (PyArrayObje

Re: [Numpy-discussion] Determining if two arrays share data

2006-07-06 Thread Albert Strasheim
Hello all > > Python 2.3b1+ (#2, Jun 10 2003, 20:53:51) > [GCC 3.0.2 20010905 (Red Hat Linux 7.1 3.0.1-3)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import Numeric > >>> a=Numeric.arange(20) > >>> b=a[::2] > >>> c=a[1::2] > >>> a > array([ 0, 1

Re: [Numpy-discussion] Determining if two arrays share data

2006-07-06 Thread Rob W.W. Hooft
Stefan van der Walt wrote: > On Thu, Jul 06, 2006 at 11:39:19AM +0900, Bill Baxter wrote: > >>Often when I'm doing interactive prototyping I find myself wanting to check >>whether two arrays are sharing a copy of the same data. > > > Say you have > > x = N.array([1,2,3,4]) > > and > > y = x.r

Re: [Numpy-discussion] simple question

2006-07-06 Thread Pau Gargallo
On 7/6/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > That's the kind of thing that should maybe be on the NumpyExample list: > http://www.scipy.org/Numpy_Example_List > But currently little syntactical tricks like that aren't listed there. I'm > not sure how you'd list that even. > There is a (ten

Re: [Numpy-discussion] Comparing arrays with dtypes with field names

2006-07-06 Thread Travis Oliphant
Albert Strasheim wrote: > Hello all > > I noticed that arrays with dtypes with field names don't compare correctly > when using the equality operator. > > Example: > > In [17]: dt = N.dtype({'names' : ['f1', 'f2'], >'formats' : [N.intc, N.intc]}) > > In [18]: x = N.array([(0

[Numpy-discussion] Comparing arrays with dtypes with field names

2006-07-06 Thread Albert Strasheim
Hello all I noticed that arrays with dtypes with field names don't compare correctly when using the equality operator. Example: In [17]: dt = N.dtype({'names' : ['f1', 'f2'], 'formats' : [N.intc, N.intc]}) In [18]: x = N.array([(0,0)], dtype=dt) In [19]: y = N.array([(0,

Re: [Numpy-discussion] Determining if two arrays share data

2006-07-06 Thread Stefan van der Walt
On Thu, Jul 06, 2006 at 11:39:19AM +0900, Bill Baxter wrote: > Often when I'm doing interactive prototyping I find myself wanting to check > whether two arrays are sharing a copy of the same data. > > It seems like there ought to be a concise way to do that, but right now seems > like the only way