Skip to content

Instantly share code, notes, and snippets.

View nelimee's full-sized avatar

Adrien Suau nelimee

View GitHub Profile
@nelimee
nelimee / hardware_architecture.py
Last active September 21, 2020 09:22
Implementation proposition for qiskit hardware API simplification
import logging
import pickle
import typing as ty
from pathlib import Path
import networkx as nx
from qiskit.circuit.quantumregister import Qubit
from qiskit.dagcircuit.dagcircuit import DAGNode
logger = logging.getLogger("IBMQHardwareArchitecture")
@nelimee
nelimee / lsp-configuration.el
Created April 17, 2020 19:23
My LSP configuration
(setq lsp-keymap-prefix "C-c s")
(use-package lsp-mode
;;:init
:config
(setq lsp-enable-snippet nil)
;; Python
;; Default pyls server when not given in local variables
(setq lsp-pyls-server-command '("~/.anaconda3/envs/pyls/bin/pyls"))
;; Do not enable the formatters to let pyls use Black!
(setq lsp-pyls-plugins-autopep8-enabled nil)
def normalise(vec: numpy.ndarray) -> numpy.ndarray:
norm = numpy.linalg.norm(vec)
if norm > numpy.finfo(float).eps:
return vec / norm
return vec
def reverse_normalised_kronecker(vec: numpy.ndarray, *sizes: int, under_is_zero: float = 1e-10):
"""Reverse a kronecker product of normalised vectors.
:param vec: The full vector, result of the kronecker product.
gdb sw  140  17:51:14 
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
@nelimee
nelimee / deadd.ini
Last active June 3, 2019 17:53
Partially commented configuration file for deadd. ".ini" extension should be ".conf" on your computer, but is ".ini" here for Github code coloring.
[notification-center]
# Margin at the top of the notification center in pixels.
# This can be used to avoid overlap between the notification center and
# bars such as polybar or i3blocks.
marginTop = 50
# Width of the notification center in pixels.
width = 750
# Monitor on which the notification center will be printed.
# NOTE: is the "0" value special? Because with this setting, the notification
# center appears on the focused monitor.
@nelimee
nelimee / two_qubit_kak_error.py
Created January 11, 2019 16:06
Matrix raising an exception in qiskit.mapper._compiling.two_qubit_kak
import numpy
from qiskit.mapper._compiling import two_qubit_kak
A = numpy.array([[15, 9, 5, -3], [9, 15, 3, -5], [5, 3, 15, -9], [-3, -5, -9, 15]], dtype=numpy.complex) / 4
two_qubit_kak(A)
@nelimee
nelimee / crzz.py
Created January 10, 2019 14:22
Implementation of a controlled Rzz gate in qiskit<0.7
# ======================================================================
# Copyright CERFACS (November 2018)
# Contributor: Adrien Suau (suau@cerfacs.fr)
#
# This software is governed by the CeCILL-B license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/or redistribute the software under the terms of the
# CeCILL-B license as circulated by CEA, CNRS and INRIA at the following
# URL "http://www.cecill.info".
#
@nelimee
nelimee / crzz.py
Created January 10, 2019 14:21
Implementation of a controlled Rzz gate in qiskit<0.7
# ======================================================================
# Copyright CERFACS (November 2018)
# Contributor: Adrien Suau (suau@cerfacs.fr)
#
# This software is governed by the CeCILL-B license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/or redistribute the software under the terms of the
# CeCILL-B license as circulated by CEA, CNRS and INRIA at the following
# URL "http://www.cecill.info".
#
Traceback (most recent call last):
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/application/application.py", line 652, in _run_async2
result = yield f
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 86, in step_next
new_f = coroutine.send(None)
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/application/application.py", line 595, in _run_async
self._redraw()
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/application/application.py", line 444, in _redraw
self.renderer.render(self, self.layout)
File "~/venv/papis/lib64/python3.6/site-packages/prompt_toolkit/renderer.py", line 590, in render
import numpy as np
import scipy.linalg as la
A = .25 * np.array([[15, 9, 5, -3],
[9, 15, 3, -5],
[5, 3, 15, -9],
[-3, -5, -9, 15]])
t0 = 2 * np.pi