anchor.diff:    # Crosstalk-adaptive layout pass
   , withCrosstalkPass ? false
   , z3
  -  # Classical function -> Quantum Circuit compiler
  -, withClassicalFunctionCompiler ? true
  -, tweedledum
     # test requirements
   , ddt
   , hypothesis
  
positive.code:     seaborn
    ];
    crosstalkPackages = [ z3 ];
    classicalCompilerPackages = [ tweedledum ];
  in
  
  buildPythonPackage rec {
    pname = "qiskit-terra";
    version = "0.17.4";
  
    disabled = pythonOlder "3.6";
  
  
negative.code: 
    disabledTestPaths = [
      "test/randomized/test_transpiler_equivalence.py" # collection requires qiskit-aer, which would cause circular dependency
      # These tests are nondeterministic and can randomly fail.
      # We ignore them here for deterministic building.
      "test/randomized/"
      # These tests consistently fail on GitHub Actions build
      "test/python/quantum_info/operators/test_random.py"
    ];
    pytestFlagsArray = [ "--durations=10" ];
    disabledTests = [
      # Flaky tests
      "test_pulse_limits" # Fails on GitHub Actions, probably due to minor floating point arithmetic error.
      "test_cx_equivalence"  # Fails due to flaky test
      "test_two_qubit_synthesis_not_pulse_optimal" # test of random circuit, seems to randomly fail depending on seed
      "test_qv_natural" # fails due to sign error. Not sure why
    ] ++ lib.optionals (lib.versionAtLeast matplotlib.version "3.4.0") [
      "test_plot_circuit_layout"
    ]
    # Disabling slow tests for build constraints
    ++ [
  