Skip to content

Instantly share code, notes, and snippets.

@appleby
appleby / paulis-mypy-number.diff
Created November 18, 2019 16:10
Possible patch for paulis.py to resolve mypy + Number difficulties
diff --git a/pyquil/paulis.py b/pyquil/paulis.py
index fc312677..c167a279 100644
--- a/pyquil/paulis.py
+++ b/pyquil/paulis.py
@@ -89,7 +89,7 @@ class PauliTerm(object):
if not _valid_qubit(index):
raise ValueError(f"{index} is not a valid qubit")
self._ops[index] = op
- if not isinstance(coefficient, Number):
+ if not isinstance(coefficient, (Number, int, float, complex)):
@appleby
appleby / 2011_us_ag_exports.csv
Last active April 19, 2018 03:57
2011 US agriculture exports by state
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 17 columns, instead of 9 in line 9.
code,state,category,total exports,beef,pork,poultry,dairy,fruits fresh,fruits proc,total fruits,veggies fresh,veggies proc,total veggies,corn,wheat,cotton
AL,Alabama,state,1390.63,34.40,10.60,481.00,4.06,8.00,17.10,25.11,5.50,8.90,14.33,34.90,70.00,317.61
AK,Alaska,state,13.31,0.20,0.10,0.00,0.19,0.00,0.00,0.00,0.60,1.00,1.56,0.00,0.00,0.00
AZ,Arizona,state,1463.17,71.30,17.90,0.00,105.48,19.30,41.00,60.27,147.50,239.40,386.91,7.30,48.70,423.95
AR,Arkansas,state,3586.02,53.20,29.40,562.90,3.53,2.20,4.70,6.88,4.40,7.10,11.45,69.50,114.50,665.44
CA,California,state,16472.88,228.70,11.10,225.40,929.95,2791.80,5944.60,8736.40,803.20,1303.50,2106.79,34.60,249.30,1064.95
CO,Colorado,state,1851.33,261.40,66.00,14.00,71.94,5.70,12.20,17.99,45.10,73.20,118.27,183.20,400.50,0.00
CT,Connecticut,state,259.62,1.10,0.10,6.90,9.49,4.20,8.90,13.10,4.30,6.90,11.16,0.00,0.00,0.00
DE,Delaware,state,282.19,0.40,0.60,114.70,2.30,0.50,1.00,1.53,7.60,12.40,20.03,26.90,22.90,0.00
FL,Florida,state,3764.09,42.60,0.90,56.90,66.31,438.2
@appleby
appleby / ma-learning-rate-test-overview.ipynb
Last active June 29, 2017 02:01
Overview section from ma-learning-rate-test.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@appleby
appleby / golang-http2-changelist-29243-patch-set-10-race-report
Created June 23, 2017 18:24
golang-http2-changelist-29243-patch-set-10-race-report
[ma@march http2]? go test -run '^TestTransportChecksRequestHeaderListSize$' -race
==================
WARNING: DATA RACE
Write at 0x00c42017a038 by goroutine 7:
golang.org/x/net/http2.TestTransportChecksRequestHeaderListSize()
/home/ma/opt/godev/src/golang.org/x/net/http2/transport_test.go:1575 +0x99c
testing.tRunner()
/home/ma/src/repos/go/src/testing/testing.go:754 +0x16c
Previous read at 0x00c42017a038 by goroutine 13:

Keybase proof

I hereby claim:

  • I am appleby on github.
  • I am appleby (https://keybase.io/appleby) on keybase.
  • I have a public key ASBQJVgyWd_PVhsKIb8ZFfNjAAkfKXUPiINy5d0-EY4QQgo

To claim this, I am signing this object:

@appleby
appleby / benchcmp-results.txt
Created September 18, 2016 18:44
Benchmark results for patch set 3 WITHOUT normalizing user-agent key
## Tip vs Patch set 3 w/o normalization
[ma@march benchcmp]? benchcmp http2-req-orig.txt http2-req-patch-set-3-no-ToLower.txt
benchmark old ns/op new ns/op delta
BenchmarkClientRequestHeaders/___0_Headers-4 253637 260675 +2.77%
BenchmarkClientRequestHeaders/__10_Headers-4 302833 312667 +3.25%
BenchmarkClientRequestHeaders/_100_Headers-4 771251 743664 -3.58%
BenchmarkClientRequestHeaders/1000_Headers-4 7970480 7716502 -3.19%
benchmark old allocs new allocs delta
BenchmarkClientRequestHeaders/___0_Headers-4 53 60 +13.21%
@appleby
appleby / Patch set 8
Last active December 2, 2016 18:07
Benchmark results for patch sets of https://go-review.googlesource.com/#/c/29243/1
## Tip vs Patch set 8
? benchcmp http2-tip-97edce-all.txt http2-patch-set-8-all.txt
benchmark old ns/op new ns/op delta
BenchmarkServerGets-4 175988 193697 +10.06%
BenchmarkServerPosts-4 221945 237721 +7.11%
BenchmarkServer_GetRequest-4 219048 216868 -1.00%
BenchmarkServer_PostRequest-4 252486 249143 -1.32%
BenchmarkClientRequestHeaders/___0_Headers-4 246203 245802 -0.16%
BenchmarkClientRequestHeaders/__10_Headers-4 293774 296449 +0.91%
BenchmarkClientRequestHeaders/_100_Headers-4 705337 723839 +2.62%
func benchSimpleRoundTrip(b *testing.B, nHeaders int) {
defer disableGoroutineTracking()()
b.ReportAllocs()
st := newServerTester(b,
func(w http.ResponseWriter, r *http.Request) {
},
optOnlyServer,
optQuiet,
)
defer st.Close()