Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6565967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:09:38+00:00 2026-05-25T14:09:38+00:00

I am using numpy and I want to store the result of a calculation

  • 0

I am using numpy and I want to store the result of a calculation inside a three or four-dimensional matrix. I want to do something like this:

result[:, indices, iteration] = some_function()  # won't work

where the dimension is understood from the length of the indices tuple. So if indices equals, say, (6,) or (8, 5) then I want to have the equivalent of

result[:, 6, iteration] = some_function()

or

result[:, 8, 5, iteration] = some_function()

Normally I’d put all of the coordinates into a tuple and use that as an index, but the presence of : prevents me from doing that.

The dimension of result has been set earlier to the correct dimension, so can check it, but it would be nice to only use the length of indices to determine it. Is there some way to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:09:38+00:00Added an answer on May 25, 2026 at 2:09 pm

    Try using result[(slice(None),) + indices + (iteration,)]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Numpy and have a 7x12x12 matrix whose values I would like to
I'm implementing TDMA in Python using NumPy. The tridiagonal matrix is stored in three
I generate data using numpy.genfromtxt like this: ConvertToDate = lambda s:datetime.strptime(s,%d/%m/%Y) data= numpy.genfromtxt(open(PSECSkew.csv, rb),
I want to do a multidimensional array operation using numpy on three arrays, of
I am using numpy. I have a matrix with 1 column and N rows
i am using this: http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html i have an list a that i want to
I want to create a .wav file in Python using the numpy and scipy
I have a very large matrix(10x55678) in numpy matrix format. the rows of this
Using NumPy , a matrix A has n rows and m columns, and I
I'm using numpy to build pixel arrays. An 800x600 image is an 3-dimensional array

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.