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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:30:29+00:00 2026-05-31T08:30:29+00:00

I have a code comprised of two functions one that reads data and the

  • 0

I have a code comprised of two functions one that reads data and the other that counts it. Both functions run properly when run separately, but I get the error when I try to have the counter call the file reader. I would appreciate it if some one could tell me where I am goofing up. Thanks in advance

Error

File "C:\Documents and Settings\Read_File.py", line 50, in counter
Sx = ((25. < Xa) & (Xa < 100.)).sum()    #count what is in x range
TypeError: unorderable types: float() < function()

Code

for line in f:        #Loop Strips empty lines as well as replaces tabs with space
if line !='':    
  line = line.strip()
  line = line.replace('\t',' ')
  columns = line.split()
  for line in range(N):       #Loop number of lines to be counted
   x = columns[8]             # assigns variable to columns
   y = columns[18]
   z = columns[19]
   #vx = columns[]
   #vy = columns[]
   #vz = columns[]
   X.append(x)
   Y.append(y)                #appends data in list
   Z.append(z)
  
 Xa = numpy.array(X, dtype=float)                   #Converts lists to NumPy arrays
 Ya = numpy.array(Y, dtype=float)
 Za = numpy.array(Z, dtype=float)



 return(Xa,Ya,Za)         #returns arrays/print statement to test 
   
 
def counter(Xa):
 Sx = ((25. < Xa) & (Xa < 100.)).sum()    #count what is in x range
 Sy = ((25. < Ya) & (Ya < 100.)).sum()    #count what is in y range
 Sz = ((25. < Za) & (Za < 100.)).sum()    #count what is in z range

 return(print(Sx,Sy,Sz))

read_file(F)                              #function calls 
counter(read_file)

EDit

With the help of Lev and James the first problem was fixed now I get this error

  Sx = ((2. < Xa) & (Xa < 10.)).sum()    #count what is in x range
  TypeError: unorderable types: float() < tuple()

Is this because of the commas in the arrays? And if so how can I get around 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-31T08:30:31+00:00Added an answer on May 31, 2026 at 8:30 am

    You are trying to call counter() on the function read_file(), not on the results of calling read_file(F). You don’t include source for read_file(), but you almost certainly want to do:

    counter(readfile(F))
    

    instead of the last two lines. (By the way, the result(print(...)) in counter() probably doesn’t need the return wrapping round the rest of it.)

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

Sidebar

Related Questions

I have a form with two different UserControls - one that contains a Telerik
I am trying to run these two .data files from my c++ code for
I have a C++ assembly with both managed and umanaged code compiled to a
I have a .NET assembly DLL that is created on-the-fly from pre-compiled code in
I have a DLL that's compiled, and I don't have the source code for
I have some legacy C code that I recently compiled on Linux. On the
I have code that references a web service, and I'd like the address of
I have a DLL with one single function That gets five doubles and one
Does it impact memory if I have two Java classes that have native calls
I have some code that will stream video from a camera at 720p and

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.