2020-04-16 23:18:12 +00:00
{ stdenv
, lib
2020-01-17 02:28:43 +00:00
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, google_api_python_client
, matplotlib
, networkx
, numpy
, pandas
, pythonProtobuf # pythonPackages.protobuf
, requests
, scipy
, sortedcontainers
, sympy
, typing-extensions
# test inputs
, pytestCheckHook
, pytest-benchmark
, ply
, pydot
, pyyaml
, pygraphviz
} :
buildPythonPackage rec {
pname = " c i r q " ;
version = " 0 . 6 . 1 " ;
disabled = pythonOlder " 3 . 5 " ;
src = fetchFromGitHub {
owner = " q u a n t u m l i b " ;
repo = " c i r q " ;
rev = " v ${ version } " ;
sha256 = " 0 l h r 2 d k a 7 v p z 9 x d 6 a k x p h r c v 2 b 3 n i 2 c g j y w p c 1 r 7 q p q a 5 m r q 1 q 7 f " ;
} ;
# Cirq 0.6 requires networkx==2.3 only for optional qiskit dependency/test, disable this to avoid networkx version conflicts. https://github.com/quantumlib/Cirq/issues/2368
# Cirq locks protobuf==3.8.0, but tested working with default pythonPackages.protobuf (3.7). This avoids overrides/pythonPackages.protobuf conflicts
2020-04-16 23:18:12 +00:00
postPatch = ''
2020-01-17 02:28:43 +00:00
substituteInPlace requirements . txt - - replace " n e t w o r k x = = 2 . 3 " " n e t w o r k x " \
- - replace " p r o t o b u f = = 3 . 8 . 0 " " p r o t o b u f "
# Fix sympy 1.5 test failures. Should be fixed in v0.7
substituteInPlace cirq/optimizers/eject_phased_paulis_test.py - - replace " p h a s e _ e x p o n e n t = 0 . 1 2 5 + x / 8 " " p h a s e _ e x p o n e n t = 0 . 1 2 5 + x * 0 . 1 2 5 "
substituteInPlace cirq/contrib/quirk/cells/parse_test.py - - replace " p a r s e _ f o r m u l a ( ' 5 t ' ) = = 5 * t " " p a r s e _ f o r m u l a ( ' 5 t ' ) = = 5 . 0 * t "
2020-04-16 23:18:12 +00:00
# Fix pandas >= 1.0 error, #2886
substituteInPlace cirq/experiments/t1_decay_experiment.py - - replace " d e l t a b . c o l u m n s . n a m e " ' tab . rename_axis ( None , axis = " c o l u m n s " , inplace = True ) '
2020-01-17 02:28:43 +00:00
'' ;
propagatedBuildInputs = [
google_api_python_client
numpy
matplotlib
networkx
pandas
pythonProtobuf
requests
scipy
sortedcontainers
sympy
typing-extensions
] ;
doCheck = true ;
# pythonImportsCheck = [ "cirq" "cirq.Ciruit" ]; # cirq's importlib hook doesn't work here
dontUseSetuptoolsCheck = true ;
checkInputs = [
pytestCheckHook
pytest-benchmark
ply
pydot
pyyaml
pygraphviz
] ;
# TODO: enable op_serializer_test. Error is type checking, for some reason wants bool instead of numpy.bool_. Not sure if protobuf or internal issue
pytestFlagsArray = [
" - - i g n o r e = d e v _ t o o l s " # Only needed when developing new code, which is out-of-scope
" - - i g n o r e = c i r q / g o o g l e / o p _ s e r i a l i z e r _ t e s t . p y " # investigating in https://github.com/quantumlib/Cirq/issues/2727
] ;
2020-04-16 23:18:12 +00:00
disabledTests = [
" t e s t _ c o n v e r t _ t o _ i o n _ g a t e s " # fails due to rounding error, 0.75 != 0.750...2
] ++ lib . optionals stdenv . isAarch64 [
# Seem to fail due to math issues on aarch64?
" e x p e c t a t i o n _ f r o m _ w a v e f u n c t i o n "
" t e s t _ s i n g l e _ q u b i t _ o p _ t o _ f r a m e d _ p h a s e _ f o r m _ o u t p u t _ o n _ e x a m p l e _ c a s e "
] ;
2020-01-17 02:28:43 +00:00
meta = with lib ; {
description = " A f r a m e w o r k f o r c r e a t i n g , e d i t i n g , a n d i n v o k i n g N o i s y I n t e r m e d i a t e S c a l e Q u a n t u m ( N I S Q ) c i r c u i t s . " ;
2020-03-20 12:36:23 +00:00
homepage = " h t t p s : / / g i t h u b . c o m / q u a n t u m l i b / c i r q " ;
2020-01-17 02:28:43 +00:00
license = licenses . asl20 ;
maintainers = with maintainers ; [ drewrisinger ] ;
} ;
}