Skip to content

Bug with float128 and not with float64? #119

Description

@doronbehar

The following MWE:

from pwlf import PiecewiseLinFit
import numpy as np

fit = PiecewiseLinFit(np.linspace(0, 10, dtype=np.float128), np.random.random(50))
fit.fit(2)
fit.p_values()

Errors for me with:

Traceback (most recent call last):
  File "/home/doron/repos/lab-ion-trap-simulations/./pwfit_float128_bug.py", line 8, in <module>
    print(fit.p_values())
          ^^^^^^^^^^^^^^
  File "/nix/store/8p528p5cji81aidpbpwiyyz5s9nb1lz4-python3-3.12.8-env/lib/python3.12/site-packages/pwlf/pwlf.py", line 1484, in p_values
    p = 2.0 * stats.t.sf(np.abs(t), df=n - k - 1)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/8p528p5cji81aidpbpwiyyz5s9nb1lz4-python3-3.12.8-env/lib/python3.12/site-packages/scipy/stats/_distn_infrastructure.py", line 2203, in sf
    place(output, cond, self._sf(*goodargs))
                        ^^^^^^^^^^^^^^^^^^^
  File "/nix/store/8p528p5cji81aidpbpwiyyz5s9nb1lz4-python3-3.12.8-env/lib/python3.12/site-packages/scipy/stats/_continuous_distns.py", line 7716, in _sf
    return sc.stdtr(df, -x)
           ^^^^^^^^^^^^^^^^
TypeError: ufunc 'stdtr' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

However, without the dtype=np.float64, no error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions