Skip to content

Commit

Permalink
__getitem__ method return a Fxp with raw value as view
Browse files Browse the repository at this point in the history
-  add tests for issues #60 and #62
  • Loading branch information
francof2a committed Apr 24, 2022
1 parent 72eb0d6 commit ec5cf96
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
version 0.4.8
--------------------------------------------------
* Fix value dtype handling for windows OS and uint as 32 bits.
* __getitem__ method return a Fxp with raw value as view (this solve issue #62).
* Add tests for issues #60 and #62.

version 0.4.7
--------------------------------------------------
* Keep val as original_vdtype and not as object when it is convenient (solve issue #60).
Expand Down
2 changes: 1 addition & 1 deletion fxpmath/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.4.8-dev0'
__version__ = '0.4.8'

import sys
import os
Expand Down
5 changes: 4 additions & 1 deletion fxpmath/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,10 @@ def __ge__(self, x):

# indexation
def __getitem__(self, index):
return Fxp(self.val[index], like=self, raw=True)
# return Fxp(self.val[index], like=self, raw=True)
y = Fxp(like=self)
y.val = self.val[index]
return y

def __setitem__(self, index, value):
self.set_val(value, index=index)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,4 @@ def test_issue_62_v0_4_7():

y[0][0] = y[0][0] + 1.0

assert y[0][0]() == 2.0
assert y[0][0]() == 0.0

0 comments on commit ec5cf96

Please sign in to comment.