Skip to content

Commit

Permalink
allow compatibility with all sub -versions of 3.11 (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
wakamex authored Mar 4, 2024
1 parent 3427fe4 commit fffb115
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions fixedpointmath/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for doing special math"""

# Modules imported here are simply for easier namespace resolution, e.g.,
# from fixedpointmath import FixedPoint
# instead of
Expand Down
1 change: 1 addition & 0 deletions fixedpointmath/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Define Python user-defined exceptions"""

from __future__ import annotations


Expand Down
1 change: 1 addition & 0 deletions fixedpointmath/fixed_point.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixed point datatype & arithmetic"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions fixedpointmath/fixed_point_integer_math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixed Point Integer math library"""

from __future__ import annotations

from . import errors
Expand Down
1 change: 1 addition & 0 deletions fixedpointmath/fixed_point_math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Math library wrappers that support FixedPoint number format"""

from __future__ import annotations

import math
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
]
description = "Fixed-point arithmetic and type that mirrors popular Solidity implementations"
readme = "README.md"
requires-python = ">=3.8, <=3.11"
requires-python = ">=3.8, <3.12"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_fp_arithmetic_sugar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for arethmetic syntax sugar with the FixedPoint class"""

import unittest

from fixedpointmath import errors
Expand All @@ -24,6 +25,7 @@ class TestFixedPoint(unittest.TestCase):
Instead, `fp(1) == 1e-18`, while `fp(1.0) == 1e18`.
"""

ZERO = FixedPoint("0.0")
ONE = FixedPoint("1.0")
NEG_ONE = FixedPoint("-1.0")
Expand Down Expand Up @@ -294,9 +296,7 @@ def test_divide(self):
assert float(FixedPoint("6.0") / FixedPoint("100.0")) == 0.06
assert float(FixedPoint("0.006") / FixedPoint("0.001")) == 6
# div rounding
assert FixedPoint(scaled_value=2 * 10**18) / FixedPoint(scaled_value=1 * 10**37) == FixedPoint(
scaled_value=0
)
assert FixedPoint(scaled_value=2 * 10**18) / FixedPoint(scaled_value=1 * 10**37) == FixedPoint(scaled_value=0)
assert FixedPoint(scaled_value=2 * 10**18).div_up(FixedPoint(scaled_value=1 * 10**37)) == FixedPoint(
scaled_value=1
)
Expand Down
1 change: 1 addition & 0 deletions tests/test_fp_class.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the FixedPoint class methods"""

import math
import unittest
from decimal import Decimal
Expand Down
1 change: 1 addition & 0 deletions tests/test_fp_integer_math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""FixedPoint integer math tests inspired from solidity hyperdrive implementation"""

import math
import unittest

Expand Down
1 change: 1 addition & 0 deletions tests/test_fp_math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""FixedPoint class math tests inspired from solidity hyperdrive implementation"""

import math
import unittest

Expand Down
2 changes: 2 additions & 0 deletions tests/test_fp_nonfinite_checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for non-finite (inf or nan) operations with the FixedPoint datatype"""

import unittest

from fixedpointmath import FixedPoint
Expand All @@ -9,6 +10,7 @@ class TestFixedPointNonFinite(unittest.TestCase):
Unlike normal integers, the FixedPoint type
"""

ZERO = FixedPoint("0.0")
ONE = FixedPoint("1.0")
NEG_ONE = FixedPoint("-1.0")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fp_relational_sugar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for relational (comparison) syntax sugar with the FixedPoint class"""

import unittest

from fixedpointmath import FixedPoint
Expand All @@ -11,6 +12,7 @@ class TestFixedPointNonFinite(unittest.TestCase):
Unlike normal integers, the FixedPoint type
"""

ONE = FixedPoint("1.0")
NEG_ONE = FixedPoint("-1.0")
ODD_FINITE = FixedPoint("9.0")
Expand Down

0 comments on commit fffb115

Please sign in to comment.