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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:28:25+00:00 2026-06-10T20:28:25+00:00

I have defined a list of ball tree objects as below, where input1 is

  • 0

I have defined a list of ball tree objects as below, where input1 is a NumPy array with shape (100, 320).

bt = []
bt.append(BallTree(input1)) 

I take one of the elements of input1 as a sample query, where sample_index is assumed to be within bounds.

sample_query = input1[sample_index,:]

# Find nearest neighbour and compute distance and index
distance, index = bt[0].query(sample_query,1)

Here, distance[0] is 0 as expected given that ‘sample_query’ is a member of input1.

# Adding another BallTree instance to the list
#input2 is a numpy array with shape (70,320)  
bt.append(BallTree(input2))
distance, index = bt[0].query(sample_query,1)
print distance[0]
# Output here is NOT zero (NOT expected!!)

Why would the nearest neighbour distance change for ‘sample_query’ and bt[0] when I append one more Ball tree object to the Ball tree list ‘bt’? I would expect the object bt[0] to be unmodified when I append one more object to the list bt. Is my expectation correct?

  • 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-10T20:28:25+00:00Added an answer on June 10, 2026 at 8:28 pm

    I found a gap in my understanding of BallTree with this example.

    After a bit of digging, I now understand that (borrowing from the notation in the question) bt[0].data actually points to the input numpy array rather than it being a copy. I was re-using the input numpy array for creating further ball trees and hence the data as seen by bt[0] kept getting clobbered everytime.

    If I ensure that the numpy array gets created (or allocated in ‘C-speak’) for each ball tree instance, ball tree query results are consistent.

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

Sidebar

Related Questions

I have defined a List View in xml as below <ListView android:id=@+id/mylist android:layout_width=fill_parent android:layout_height=wrap_content
I have defined a custom list template type for SharePoint . I install it
I have defined a drop down list in html as follows. I have appended
I have a class Bar that has a user-defined list of config keys and
I have two polygons which are defined by a list of points: x1,y1; x2,y2;
I have a singly linked list with node and list structs defined as: typedef
I have a button defined inside of a DataTemplate for my list box. <phone:PhoneApplicationPage.Resources>
I have a list iteration in python defined like this: for i in range(5):
I have the following function defined inside my linked list class. The declaration in
I have a List<ParentObject> where ParentObject is defined as: public class ParentObject { ChildObject

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.