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 9154737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:28:32+00:00 2026-06-17T12:28:32+00:00

Is it possible to perform min/max in-place assignment with NumPy multi-dimensional arrays without an

  • 0

Is it possible to perform min/max in-place assignment with NumPy multi-dimensional arrays without an extra copy?

Say, a and b are two 2D numpy arrays and I would like to have a[i,j] = min(a[i,j], b[i,j]) for all i and j.

One way to do this is:

a = numpy.minimum(a, b)

But according to the documentation, numpy.minimum creates and returns a new array:

numpy.minimum(x1, x2[, out])
Element-wise minimum of array elements.
Compare two arrays and returns a new array containing the element-wise minima.

So in the code above, it will create a new temporary array (min of a and b), then assign it to a and dispose it, right?

Is there any way to do something like a.min_with(b) so that the min-result is assigned back to a in-place?

  • 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-06-17T12:28:33+00:00Added an answer on June 17, 2026 at 12:28 pm

    numpy.minimum() takes an optional third argument, which is the output array. You can specify a there to have it modified in place:

    In [9]: a = np.array([[1, 2, 3], [2, 2, 2], [3, 2, 1]])
    
    In [10]: b = np.array([[3, 2, 1], [1, 2, 1], [1, 2, 1]])
    
    In [11]: np.minimum(a, b, a)
    Out[11]: 
    array([[1, 2, 1],
           [1, 2, 1],
           [1, 2, 1]])
    
    In [12]: a
    Out[12]: 
    array([[1, 2, 1],
           [1, 2, 1],
           [1, 2, 1]])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to perform multi-variate regression in Python using NumPy? The documentation here
Is it possible to perform an active wifi scan on android without using the,
is it possible to perform a dynamic role assignment based on a quiz result
Is it possible to perform arithmetic operation on void pointer without the use of
is it possible to perform two actions on onlongclickListener.. below is sample code public
I need to perform a parallel reduction to find the min or max of
Is it even possible to perform a cross-domain POST Ajax request without using proxy?
Is it possible to perform a partial or patch commit in Team Foundation? I
Is it possible to perform query expansion with Lucene 3.6 using any ontology? I've
Is it possible to perform a replace-string operation inside of a rectangular region in

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.