0

I have been trying to declare a three dimensional array with the following constraints using numpy in Python 2.7.3:

1.) MyArray(First, Second, Third)

2.) First has 11 elements

3.) Second has 14 elements

4.a) The Third dimension varies in size depending on the element of the First dimension

4.b) If First=8 then Third=988

4.c) Else if First=10 or First=11 then Third=640

4.d) Else Third=494

Is this possible with arrays or should I be using structures?

Thank you in advance,

3
  • according to the documentation, Several algorithms in NumPy work on arbitrarily strided arrays. However, some algorithms require single-segment arrays. When an irregularly strided array is passed in to such algorithms, a copy is automatically made.
    – Fabricator
    Commented Jul 25, 2014 at 0:51
  • @Fabricator - "Irregularly strided" doesn't mean that the shape can vary along an axis. (It's a bit too much to explain in a comment, but strides refers to how many memory steps to take to increment along a given axis.) Numpy arrays must have a regular shape. They can't be "ragged" (not counting object arrays, anyway). Commented Jul 25, 2014 at 2:07
  • @JoeKington, thanks for the correction. Can you explain what is an irregularly strided array here?
    – Fabricator
    Commented Jul 25, 2014 at 2:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.