Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 52 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ permissions:
contents: read

jobs:
buid-and-test:
runs-on: ubuntu-24.04

strategy:
fail-fast: false

code-health:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Expand Down Expand Up @@ -66,6 +62,26 @@ jobs:

- name: Check modified protos
run: ci/build_changed_protos.sh origin/main

build-and-test-correctness:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-24.04", "ubuntu-24.04-arm", "macos-13", "macos-14"]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Set up Python 3.12
uses: actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # v3
with:
python-version: '3.12'

- name: Install Dependencies
run: |
pip install -r dev_tools/dev.env.txt
#
# Install
Expand All @@ -75,14 +91,40 @@ jobs:
run: |
pip install . --user
- name: pytest
run: ci/pytest_unit.sh

- name: test performance
run: ci/pytest_perf.sh

- name: test compatibility with Cirq
run: |
pip install cirq-core
pytest test/* -m cirq
build-and-test-performance:
strategy:
fail-fast: false

runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Set up Python 3.12
uses: actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # v3
with:
python-version: '3.12'

- name: Install Dependencies
run: |
pip install -r dev_tools/dev.env.txt
#
# Install
#

- name: install
run: |
pip install . --user
- name: test performance
run: ci/pytest_perf.sh
2 changes: 1 addition & 1 deletion test_perf/test_value_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_perf_repr(a: Value) -> str:
return repr(a)


@perf_goal(avg_nanos=830)
@perf_goal(avg_nanos=850)
def test_perf_parse_atom() -> Value:
return Value(1, 'kilogram')

Expand Down
9 changes: 4 additions & 5 deletions tunits/core/cython/frac.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
cimport cython
from libc.math cimport floor as c_floor, pow as c_pow


# A ratio that should always be canonicalized into least terms with the sign
# on the numerator.
cdef struct frac:
Expand Down Expand Up @@ -85,10 +84,10 @@ cpdef frac float_to_twelths_frac(a) except *:
return frac_least_terms(a, 1)

cdef double d = float(a)
cdef long long x = <long long>c_floor(12*d + 0.5)
if abs(12*d - x) > 1e-5:
raise ValueError("Not a twelfth.")

cdef double raised_d = 12.0*d
cdef long long x = <long long>c_floor(raised_d + 0.5)
if not (-1e-5 < raised_d - x < 1e-5):
raise ValueError(f"{a} with 12*a={raised_d} Not a twelfth.")
return frac_least_terms(x, 12)


Expand Down
Loading