Compare commits
5 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 08e16ac68d | |||
| b11a0c814e | |||
| dd76e0a45e | |||
| 3ed20aefea | |||
| c7eed9d36c |
5 changed files with 50 additions and 44 deletions
34
.github/workflows/build.yml
vendored
34
.github/workflows/build.yml
vendored
|
|
@ -17,11 +17,11 @@ jobs:
|
||||||
- name: Translate Repo Name For Build Tools filename_prefix
|
- name: Translate Repo Name For Build Tools filename_prefix
|
||||||
id: repo-name
|
id: repo-name
|
||||||
run: |
|
run: |
|
||||||
echo ::set-output name=repo-name::$(
|
echo repo-name=$(
|
||||||
echo ${{ github.repository }} |
|
echo ${{ github.repository }} |
|
||||||
awk -F '\/' '{ print tolower($2) }' |
|
awk -F '\/' '{ print tolower($2) }' |
|
||||||
tr '_' '-'
|
tr '_' '-'h
|
||||||
)
|
)>> $GITHUB_OUTPUTS
|
||||||
- name: Set up Python 3.x
|
- name: Set up Python 3.x
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v1
|
||||||
with:
|
with:
|
||||||
|
|
@ -52,27 +52,8 @@ jobs:
|
||||||
- name: Pre-commit hooks
|
- name: Pre-commit hooks
|
||||||
run: |
|
run: |
|
||||||
pre-commit run --all-files
|
pre-commit run --all-files
|
||||||
- name: Clone and build circuitpython unix port
|
- name: Test in circuitpython
|
||||||
run: |
|
run: ./build-test-cp.sh
|
||||||
set -e
|
|
||||||
[ -e circuitpython/py/py.mk ] || (git clone --depth=1 https://github.com/adafruit/circuitpython && cd circuitpython && git fetch --tags --recurse-submodules=no --shallow-since="2021-07-01" https://github.com/adafruit/circuitpython HEAD)
|
|
||||||
[ -e circuitpython/lib/libffi/autogen.sh ] || (cd circuitpython && git submodule update --init lib/libffi lib/axtls lib/berkeley-db-1.xx tools/huffman lib/uzlib extmod/ulab)
|
|
||||||
[ -x circuitpython/ports/unix/micropython ] || (
|
|
||||||
make -C circuitpython/mpy-cross -j$(nproc)
|
|
||||||
make -C circuitpython/ports/unix -j$(nproc) deplibs
|
|
||||||
make -C circuitpython/ports/unix -j$(nproc) DEBUG=1 STRIP=:
|
|
||||||
)
|
|
||||||
- name: Unit Test
|
|
||||||
run: |
|
|
||||||
python -m jepler_udecimal.test
|
|
||||||
if ! env MICROPYPATH=. PYTHONPATH=. MICROPY_MICROPYTHON=circuitpython/ports/unix/micropython circuitpython/tests/run-tests.py -d examples; then
|
|
||||||
for exp in *.exp; do
|
|
||||||
testbase=$(basename $exp .exp);
|
|
||||||
echo -e "\nFAILURE $testbase";
|
|
||||||
diff -u $testbase.exp $testbase.out;
|
|
||||||
done
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- name: Build assets
|
- name: Build assets
|
||||||
run: circuitpython-build-bundles --package_folder_prefix jepler --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
|
run: circuitpython-build-bundles --package_folder_prefix jepler --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
|
||||||
- name: Build docs
|
- name: Build docs
|
||||||
|
|
@ -83,12 +64,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: bundles
|
name: bundles
|
||||||
path: ${{ github.workspace }}/bundles/
|
path: ${{ github.workspace }}/bundles/
|
||||||
- name: Check For setup.py
|
|
||||||
id: need-pypi
|
|
||||||
run: |
|
|
||||||
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
|
|
||||||
- name: Build Python package
|
- name: Build Python package
|
||||||
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
|
|
||||||
run: |
|
run: |
|
||||||
pip install --upgrade setuptools wheel twine readme_renderer testresources
|
pip install --upgrade setuptools wheel twine readme_renderer testresources
|
||||||
python setup.py sdist
|
python setup.py sdist
|
||||||
|
|
|
||||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
|
|
@ -19,11 +19,11 @@ jobs:
|
||||||
- name: Translate Repo Name For Build Tools filename_prefix
|
- name: Translate Repo Name For Build Tools filename_prefix
|
||||||
id: repo-name
|
id: repo-name
|
||||||
run: |
|
run: |
|
||||||
echo ::set-output name=repo-name::$(
|
echo repo-name=$(
|
||||||
echo ${{ github.repository }} |
|
echo ${{ github.repository }} |
|
||||||
awk -F '\/' '{ print tolower($2) }' |
|
awk -F '\/' '{ print tolower($2) }' |
|
||||||
tr '_' '-'
|
tr '_' '-'h
|
||||||
)
|
)>> $GITHUB_OUTPUTS
|
||||||
- name: Set up Python 3.7
|
- name: Set up Python 3.7
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v1
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
21
build-test-cp.sh
Executable file
21
build-test-cp.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# SPDX-FileCopyrightText: 2022 Jeff Epler
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
|
set -e
|
||||||
|
TAG=8.0.0-beta.4
|
||||||
|
if ! [ -e circuitpython/py/py.mk ]; then
|
||||||
|
git clone -b $TAG --depth=1 https://github.com/adafruit/circuitpython
|
||||||
|
fi
|
||||||
|
|
||||||
|
(cd circuitpython && git submodule update --init lib/libffi lib/axtls lib/berkeley-db-1.xx tools/huffman extmod/ulab)
|
||||||
|
|
||||||
|
if ! [ -x circuitpython/ports/unix/micropython ]; then
|
||||||
|
make -C circuitpython/ports/unix -j$(nproc) DEBUG=1 STRIP=:
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! MICROPYPATH=. PYTHONPATH=. MICROPY_MICROPYTHON=circuitpython/ports/unix/micropython circuitpython/tests/run-tests.py -d examples; then
|
||||||
|
circuitpython/tests/run-tests.py --print-failures
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
@ -50,19 +50,19 @@ with localcontext():
|
||||||
print(neginf * inf)
|
print(neginf * inf)
|
||||||
try:
|
try:
|
||||||
print(dig / 0)
|
print(dig / 0)
|
||||||
except Exception as e:
|
except ZeroDivisionError as e:
|
||||||
print("Division by zero")
|
print("Division by zero")
|
||||||
getcontext().traps[DivisionByZero] = 1
|
getcontext().traps[DivisionByZero] = 1
|
||||||
try:
|
try:
|
||||||
print(dig / 0)
|
print(dig / 0)
|
||||||
except Exception as e:
|
except DivisionByZero as e:
|
||||||
print("Division by zero")
|
print("Division by zero")
|
||||||
c = Context()
|
c = Context()
|
||||||
c.traps[InvalidOperation] = 0
|
|
||||||
print(+c.flags[InvalidOperation])
|
print(+c.flags[InvalidOperation])
|
||||||
|
c.traps[InvalidOperation] = 0
|
||||||
try:
|
try:
|
||||||
c.divide(Decimal(0), Decimal(0))
|
c.divide(Decimal(0), Decimal(0))
|
||||||
except Exception as e:
|
except ZeroDivisionError as e:
|
||||||
print("Division by zero")
|
print("Division by zero")
|
||||||
c.traps[InvalidOperation] = 1
|
c.traps[InvalidOperation] = 1
|
||||||
print(+c.flags[InvalidOperation])
|
print(+c.flags[InvalidOperation])
|
||||||
|
|
@ -70,17 +70,18 @@ with localcontext():
|
||||||
print(+c.flags[InvalidOperation])
|
print(+c.flags[InvalidOperation])
|
||||||
try:
|
try:
|
||||||
print(c.divide(Decimal(0), Decimal(0)))
|
print(c.divide(Decimal(0), Decimal(0)))
|
||||||
except Exception as e:
|
except InvalidOperation as e:
|
||||||
print("Division by zero")
|
print("InvalidOperation")
|
||||||
print(+c.flags[InvalidOperation])
|
print(+c.flags[InvalidOperation])
|
||||||
try:
|
try:
|
||||||
print(c.divide(Decimal(0), Decimal(0)))
|
print(c.divide(Decimal(0), Decimal(0)))
|
||||||
except Exception as e:
|
except InvalidOperation as e:
|
||||||
print("Division by zero")
|
print("InvalidOperation")
|
||||||
print(+c.flags[InvalidOperation])
|
print(+c.flags[InvalidOperation])
|
||||||
|
|
||||||
import jepler_udecimal.utrig
|
import jepler_udecimal.utrig
|
||||||
from jepler_udecimal import Decimal
|
from jepler_udecimal import Decimal
|
||||||
|
from jepler_udecimal import InvalidOperation
|
||||||
|
|
||||||
print(Decimal(".7").atan())
|
print(Decimal(".7").atan())
|
||||||
print(Decimal(".1").acos())
|
print(Decimal(".1").acos())
|
||||||
|
|
@ -96,12 +97,12 @@ print(Decimal("NaN").tan())
|
||||||
print(Decimal("NaN").sin())
|
print(Decimal("NaN").sin())
|
||||||
try:
|
try:
|
||||||
print(Decimal("2").acos())
|
print(Decimal("2").acos())
|
||||||
except Exception as e:
|
except InvalidOperation as e:
|
||||||
print("exception")
|
print("InvalidOperation")
|
||||||
try:
|
try:
|
||||||
print(Decimal("2").asin())
|
print(Decimal("2").asin())
|
||||||
except Exception as e:
|
except InvalidOperation as e:
|
||||||
print("exception")
|
print("InvalidOperation")
|
||||||
print(Decimal("2").atan())
|
print(Decimal("2").atan())
|
||||||
print(Decimal("1").asin())
|
print(Decimal("1").asin())
|
||||||
print(Decimal("-1").asin())
|
print(Decimal("-1").asin())
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,10 @@ class DivisionByZero(DecimalException):
|
||||||
The result of the operation is [sign,inf], where sign is the exclusive
|
The result of the operation is [sign,inf], where sign is the exclusive
|
||||||
or of the signs of the operands for divide, or is 1 for an odd power of
|
or of the signs of the operands for divide, or is 1 for an odd power of
|
||||||
-0, for power.
|
-0, for power.
|
||||||
|
|
||||||
|
Due to technical limitations in MicroPython, this exception does not
|
||||||
|
inherit from ZeroDivisionError, an incompatibility with standard Python's
|
||||||
|
Decimal library.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def handle(self, context, sign, *args):
|
def handle(self, context, sign, *args):
|
||||||
|
|
@ -425,6 +429,10 @@ class FloatOperation(DecimalException):
|
||||||
|
|
||||||
Otherwise (the signal is trapped), only equality comparisons and explicit
|
Otherwise (the signal is trapped), only equality comparisons and explicit
|
||||||
conversions are silent. All other mixed operations raise FloatOperation.
|
conversions are silent. All other mixed operations raise FloatOperation.
|
||||||
|
|
||||||
|
Due to technical limitations in MicroPython, this exception does not
|
||||||
|
inherit from TypeError, an incompatibility with standard Python's
|
||||||
|
Decimal library.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue