Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap overflow breaks on 0.0 value #85

Open
sjgallagher2 opened this issue Sep 8, 2023 · 1 comment
Open

Wrap overflow breaks on 0.0 value #85

sjgallagher2 opened this issue Sep 8, 2023 · 1 comment
Labels
Numpy:LargePrecision Issue when numpy has to deal with large precision OS:Windows Issue when running in Windows
Milestone

Comments

@sjgallagher2
Copy link

fxpmath.version = 0.4.8
Windows 10, 64-bit
Python 3.11.4

The following unexpected behavior occurs:

from fxpmath import Fxp as fi
dt = 'fxp-s32/16'
x = fi(0,dtype=dt)  # => Success
x = fi(0.0, dtype=dt)  # => Success
x = fi(0, dtype=dt, overflow='wrap')  # => Success
x = fi(0.0, dtype=dt, overflow='wrap')  #  EXCEPTION

Full exception trace:

Traceback (most recent call last):

  Cell In[10], line 1
    x = fi(0.0, dtype=dt, overflow='wrap')

  File ~\.conda\envs\default\Lib\site-packages\fxpmath\objects.py:237 in __init__
    self.set_val(val, raw=raw)

  File ~\.conda\envs\default\Lib\site-packages\fxpmath\objects.py:815 in set_val
    new_val = self._overflow_action(new_val, val_min, val_max)

  File ~\.conda\envs\default\Lib\site-packages\fxpmath\objects.py:1059 in _overflow_action
    val = utils.wrap(new_val, self.signed, self.n_word)

  File ~\.conda\envs\default\Lib\site-packages\fxpmath\utils.py:352 in wrap
    x = np.array(x).astype(dtype) & (m - 1)

TypeError: unsupported operand type(s) for &: 'float' and 'int'

Expected behavior: No exception raised, Fxp created as expected

@francof2a francof2a added OS:Windows Issue when running in Windows Numpy:LargePrecision Issue when numpy has to deal with large precision labels Dec 22, 2023
@francof2a
Copy link
Owner

solved in v0.4.9 for linux and mac.
Support for windows is under review.

@francof2a francof2a added this to the v0.4.10 milestone Feb 8, 2024
francof2a added a commit that referenced this issue Feb 10, 2024
This fix #73 #76 and #85 in windows OS using numpy 32 bit integer type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Numpy:LargePrecision Issue when numpy has to deal with large precision OS:Windows Issue when running in Windows
Projects
None yet
Development

No branches or pull requests

2 participants