# [AstroPy] Constructing Angle from a tuple specified as sign string plus numbers for degrees, arcmin, arcsec

Erik Bray embray at stsci.edu
Tue Aug 11 10:30:39 EDT 2015

```On 08/10/2015 11:13 PM, Eric Jensen wrote:
> "I don't think is unusual for CDS tables. I always thought it was because Fortran77 didn't know -00 is different than +00. “
>
> It’s not just Fortran - Python too!   (And pretty much any other language you can name, unless you’re dealing with strings.)
>
> In [1]: +0 == -0
> Out[1]: True

This is the only logical possibility though.  However, as I mentioned in the
last message it's important to note a difference between integers and floats in
this regard.  For floats you still get:

In [17]: +0.0 == -0.0
Out[17]: True

However:

In [18]: +0.0 is -0.0
Out[18]: False

Unlike for integers where the aren't distinct representations for signed zero:

In [19]: +0 is -0
Out[19]: True

Although +0.0 == -0.0, signed float zeros still follow the usual arithmetic
rules for signed zero:

In [19]: +0 is -0
Out[19]: True

In [20]: -0.0 * 1
Out[20]: -0.0

In [21]: -0.0 * -1
Out[21]: 0.0

In [22]: np.sqrt(-0.0)
Out[22]: -0.0

and so on.  One reasons it's good to get in the habit (and I admit I'm lazy
scientific code so that it's stored as a float, and have the code convert to
integers where it's appropriate to use integers.

Erik

> On Aug 10, 2015, at 6:00 PM, Erik Bray <embray at stsci.edu> wrote:
>
>>>> You can instantiate an Angle array using a generator, so you could probably just
>>>> slurp in the data using a generator expression, allowing you to transform the
>>>> values one a time while creating the Angle rather than transforming the table
>>>> all at once first (please bear with the LISPiness of this example):
>>>>
>>>> dec = Angle(((int(row[0] + str(row[1])), row[2], row[3])
>>>>                for row in table['DE-', 'DEd', 'DEm', 'DEs'))
>>>>
>>>>
>>>> # (Note: originally I used row[2:] above, but there seems to be an unrelated bug
>>>> involved in taking slices of rows...I'll report on that.)
>>>
>>> In case you want to do this without loops, np.char.add can be used to
>>> concatenate string arrays element-wise. So for instance you could
>>> concatenate the sign column and the degree column of the declination with
>>>
>>>
>>> then you would end up with three arrays instead of four.
>>
>> This doesn't work because t['DE-'] is a string column, and t['DEd'] is a
>>
>> In any case, doing a row-wise transformation allows doing this with one fewer loop.
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>

```