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

  • Home
  • SEARCH
  • 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 8813635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:54:20+00:00 2026-06-14T03:54:20+00:00

The numpy polynomial fit function for masked arrays, ma.polyfit , crashes on integer iput:

  • 0

The numpy polynomial fit function for masked arrays, ma.polyfit, crashes on integer iput:

import numpy.ma as ma
x = ma.arange(2)
y = ma.arange(2)
p1 = ma.polyfit(np.float32(x), y, deg=1)
p2 = ma.polyfit(           x , y, deg=1)

The last line results in an error:

ValueError: data type <type 'numpy.int64'> not inexact

Why can’t I fit data with integer x-values (it’s no problem with the normal numpy.polyfit function), is this a (known) bug?

  • 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-14T03:54:21+00:00Added an answer on June 14, 2026 at 3:54 am

    It is indeed a bug from numpy.ma : the rcond (a parameter to exclude some values ) takes len(x)*np.finfo(x.dtypes).eps as a default value, and np.int32 does not have any epsfield (because an int does not have a relative precision).

    import numpy.ma as ma
    eps = np.finfo(np.float32).eps 
    
    x = ma.arange(2)
    y = ma.arange(2)
    p1 = ma.polyfit(np.float32(x), y, deg=1, rcond = len(x)*eps)
    p2 = ma.polyfit(           x , y, deg=1, rcond = len(x)*eps)
    

    I’ve looked quickly into numpy’s issues, and this bug does not seems to figured there. It might be a good idea to raise a new issue : New Issue

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

Sidebar

Related Questions

How do I fit a 2D surface z=f(x,y) with a polynomial in numpy with
Example: import numpy print numpy.polydiv.__doc__ output: Returns the quotient and remainder of polynomial division...
In numpy there is a function that makes arrays print prettier. set_printoptions(suppress = True)
import numpy as np a = np.arange(1000000).reshape(1000,1000) print(a**2) With this code I get this
How to write multiple numpy arrays into one csv file in multiple columns? import
I've been using the numpy.polyfit function to do some forecasting. If I put in
The numpy.equal function does not work if a list or array contains strings: >>>
import numpy a = numpy.array([20090913, 20101020, 20110125]) Can you explain why numpy.datetime64(a.astype(S8).tolist()) converts correctly
I have two numpy arrays that define the x and y axes of a
I want to access a C function that returns a struct containing double arrays

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.