File tree Expand file tree Collapse file tree 3 files changed +57
-16
lines changed
Expand file tree Collapse file tree 3 files changed +57
-16
lines changed Original file line number Diff line number Diff line change @@ -33,12 +33,8 @@ permissions:
3333 contents : read
3434
3535jobs :
36- buid-and-test :
37- runs-on : ubuntu-24.04
38-
39- strategy :
40- fail-fast : false
41-
36+ code-health :
37+ runs-on : ubuntu-24.04
4238 steps :
4339 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
4440
6662
6763 - name : Check modified protos
6864 run : ci/build_changed_protos.sh origin/main
65+
66+ build-and-test-correctness :
67+ strategy :
68+ fail-fast : false
69+ matrix :
70+ os : ["ubuntu-24.04", "ubuntu-24.04-arm", "macos-13", "macos-14"]
71+
72+ runs-on : ${{ matrix.os }}
73+
74+ steps :
75+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
76+
77+ - name : Set up Python 3.12
78+ uses : actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # v3
79+ with :
80+ python-version : ' 3.12'
81+
82+ - name : Install Dependencies
83+ run : |
84+ pip install -r dev_tools/dev.env.txt
6985
7086 #
7187 # Install
@@ -75,14 +91,40 @@ jobs:
7591 run : |
7692 pip install . --user
7793
78-
7994 - name : pytest
8095 run : ci/pytest_unit.sh
8196
82- - name : test performance
83- run : ci/pytest_perf.sh
84-
8597 - name : test compatibility with Cirq
8698 run : |
8799 pip install cirq-core
88100 pytest test/* -m cirq
101+
102+
103+ build-and-test-performance :
104+ strategy :
105+ fail-fast : false
106+
107+ runs-on : ubuntu-24.04
108+
109+ steps :
110+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
111+
112+ - name : Set up Python 3.12
113+ uses : actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # v3
114+ with :
115+ python-version : ' 3.12'
116+
117+ - name : Install Dependencies
118+ run : |
119+ pip install -r dev_tools/dev.env.txt
120+
121+ #
122+ # Install
123+ #
124+
125+ - name : install
126+ run : |
127+ pip install . --user
128+
129+ - name : test performance
130+ run : ci/pytest_perf.sh
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ def test_perf_repr(a: Value) -> str:
7474 return repr (a )
7575
7676
77- @perf_goal (avg_nanos = 830 )
77+ @perf_goal (avg_nanos = 850 )
7878def test_perf_parse_atom () -> Value :
7979 return Value (1 , 'kilogram' )
8080
Original file line number Diff line number Diff line change 1515cimport cython
1616from libc.math cimport floor as c_floor, pow as c_pow
1717
18-
1918# A ratio that should always be canonicalized into least terms with the sign
2019# on the numerator.
2120cdef struct frac:
@@ -85,10 +84,10 @@ cpdef frac float_to_twelths_frac(a) except *:
8584 return frac_least_terms(a, 1 )
8685
8786 cdef double d = float (a)
88- cdef long long x = < long long > c_floor( 12 * d + 0.5 )
89- if abs ( 12 * d - x) > 1e-5 :
90- raise ValueError ( " Not a twelfth. " )
91-
87+ cdef double raised_d = 12.0 * d
88+ cdef long long x = < long long > c_floor(raised_d + 0.5 )
89+ if not ( - 1e-5 < raised_d - x < 1e-5 ):
90+ raise ValueError (f " {a} with 12*a={raised_d} Not a twelfth. " )
9291 return frac_least_terms(x, 12 )
9392
9493
You can’t perform that action at this time.
0 commit comments