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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:43:33+00:00 2026-06-06T22:43:33+00:00

I want to mark all maxima along a given axis of an array (which

  • 0

I want to mark all maxima along a given axis of an array (which shape may be n-dimensional), this works fine along the first one, but for the rest I can’t figure it out. I don’t want to iterate over axis, because there can be arbritarily many of them.

>>> A = range(5)*3
>>> A = array(a).reshape([3,5], order='F')
>>> A
array([[0, 3, 1, 4, 2],
       [1, 4, 2, 0, 3],
       [2, 0, 3, 1, 4]])
>>> B = amax(A, axis= 0)
>>> C = amax(A, axis= 1)
>>> B == A
array([[False, False, False,  True, False],
       [False,  True, False, False, False],
       [ True, False,  True, False,  True]], dtype=bool)

This is what I want it to do for:

>>> C == A
False

but (of course) it does not.

How to get this working?

  • 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-06T22:43:37+00:00Added an answer on June 6, 2026 at 10:43 pm

    I finally came up with:

    def tiletuple(t,axis):
      m = [1]*t.ndim
      m[axis] = t.shape[axis]
      return m
    
    ax = 1
    tile(expand_dims(amax(A, axis=ax), axis=ax), tiletuple(A, ax)) == A
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Pylons with Mako templates and I want to avoid typing this all
HI ALL, I have one Big pdf file.Now i want to mark some important
To improve performance of our MVC3 application we want to mark some Controller's to
my problem is: I have an image and want to mark some areas over
Suppose you have a module that you know is safe. You want to mark
The mark in Vim takes you to your last cursor position. I want to
How can i mark menuitem in Application Bar. I want to get, for example,
I want to mark checkboxes if they have been selected via existing data from
In Python 2.x when you want to mark a method as abstract, you can
I have a select form field that I want to mark as readonly, as

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.