[Numpy-discussion] Re: Format of arrays to facilitate analysis

2025-02-18 Thread Dan Patterson
So from a purely numpy perspective, there is no advantage if one of 
aforementioned coordinate arrangements is used (eg Nx2, ravelled, 2xN).
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Format of arrays to facilitate analysis

2025-02-18 Thread Dan Patterson
I tend to work with Nx2 arrays representing coordinate geometry.
I have examined a number of packages and there is no guidelines as to why a 
certain arrangement is preferred over the other.
For example:  a rectangle, coordinates ordered clockwise with the first and 
last the same to ensure closure of the geometry

as a numpy ndarray
array([[  0.00,   0.00],
  [  0.00,   2.00],
  [  8.00,   2.00],
  [  8.00,   0.00],
  [  0.00,   0.00]])

same, but just ravelled
array([  0.00,   0.00,   0.00,   2.00,   8.00,   2.00,   8.00,   0.00,   0.00,  
 0.00])

How about a T

array([[  0.00,   0.00,   8.00,   8.00,   0.00],
  [  0.00,   2.00,   2.00,   0.00,   0.00]])

and of course there are the python  list equivalents of the above.

Preference/history seems to be the only guiding principle as to one chooses a 
certain coordinate layout over another.
Nx2 for 2D coordinates makes sense to me ( eg X, Y graphs,  Longitude, Latitude)

If I were to profer a reason to another person why I chose a particular format 
over another other than "works for me", would there be any other guiding 
considerations?

In general I:
- work with the coordinates as a pair
- sometimes, just the 'X' or 'Y'
- I save the values to disk on occasion so I can recover a particular entity 
without having to recreate it.

Curious... since I also worked with 3D coordinates (X, Y, Z as position and 
elevation) but I am considering working with temporal representation of 2D and 
3D data.  This is still ndim=2, but adding time as a the 3rd dimension

array([[[  0.00,   0.00],   # locations at time 0
   [  0.00,   2.00],
   [  8.00,   2.00],
   [  8.00,   0.00],
   [  0.00,   0.00]],

   [[ 10.00,  10.00],   # locations at time 2, shifted by 10, 10 in X, and Y
[ 10.00,  12.00],
[ 18.00,  12.00],
[ 18.00,  10.00],
[ 10.00,  10.00]]])
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] StringDType useage and roadmap

2025-02-23 Thread Dan Patterson
StringDType is interesting.  I was just looking for confirmation on a few 
things I have tried.
1.  you can't use the StringDType in structured arrays.
2.  you can't save or savetxt arrays with this dtype

For example, something as simple as this in either scenario produces errors

>>> vals = ['a little string', 'small one', '', None]
>>> dt1 = StringDType(na_object=None)
>>> z = np.array(vals, dtype=dt1)
array(['a little string', 'small one', '', None], 
dtype=StringDType(na_object=None))

>>>z0 = np.asarray(vals)  # -- as expected, an object array)
array(['a little string', 'small one', '', None], dtype=object)

>>> z1 = np.asarray(vals, dtype=[("fld", dt1)])  # -- using the dtype from above
...snip ... errored out with...
TypeError: StringDType is not currently supported for structured dtype fields.

Yes there are other packages one could use, but in those two use cases, I was 
wondering the roadmap is for this dtype, (if any)
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com