Skip to content

Instantly share code, notes, and snippets.

View cgranade's full-sized avatar

Cassandra Granade cgranade

View GitHub Profile
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "feedgen",
# "click",
# "gevent",
# "flask",
# "gusmobile @ git+https://git.sr.ht/~rwa/gusmobile#egg=0.4.0"
# ]
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.12"
# dependencies = ["htpy", "click"]
# ///
"""
This is a terrible tool, make your peace with that first and foremost.
Still here? OK, this tool reads all gemtext files (*.gmi) in a given
directory, makes HTML out of them by using a terrible template, then
# NB: This sample uses features from Python 3.10,
# in particular the match statement.
# If you get a syntax error, you may need a more
# recent version of Python.
from __future__ import annotations
from dataclasses import dataclass
class ExprBase:
def __add__(self, other: Expr) -> Expr:
return PlusExpr(self, other)
name: repo2docker-repro
dependencies:
- notebook
- python
- numpy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cgranade
cgranade / qutip-operator-sum-design.md
Last active September 25, 2021 02:01
Operator Sum support for QuTiP

Operator Sum representation support for QuTiP

Abstract

When working with quantum objects in QuTiP, the library provides the concept of a kind, allowing the use of state vectors, dual vectors, density operators, unitary operators, and superoperators all in unified fashion. Currently, however, this support does not include representations of operator-sum decompositions of channels or instruments. For example, qt.to_kraus returns a list of Qobj instances, which then has no further metadata nor any way of enforcing that each consituent Qobj instance agrees in dimensions and other metadata. Similarly, instruments can commonly be represented by a decomposition into a sum of completely positive trace non-increasing channels, but there is no current reflection of this structure in QuTiP. This design document describes a modification to QuTiP to enable first-class support for operator-sum decompositions.

Dimensions

In general, QuTiP differentiates between kinds by using decompositions of array sh

@cgranade
cgranade / ApplyCZPow.ipynb
Created September 4, 2020 16:53
qcstackexchange-13581
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

DISCLAIMER: This post is still in a draft!

Falsehoods programmers believe about quantum computing

Preamble

Quantum computing has captured broad attention and fascination over the past few years, but with that interest has come a large number of well-intentioned misunderstandings. In this post, I'll lay out a few of these falsehoods in the tradition of other wonderful falsehood lists, and in the hopes of spurring more exploration into this new and fascinating way of solving hard problems.

As a brief housekeeping note, these falsehoods are ordered by theme and topic, not in order of complexity, so don't worry if some of these points seem a bit intimidating. If you're looking to learn more about quantum computing in the first place, check out Learn Quantum Computing with Python and Q# (Manning Publications, October 2020) by Sarah Kaiser and myself.

Special thanks to everyone that made

@cgranade
cgranade / Dockerfile
Last active March 14, 2020 20:23
Values in Q#
FROM mcr.microsoft.com/quantum/iqsharp-base:0.10.2002.2610
ENV IQSHARP_HOSTING_ENV=dev-to-sckaiser-arrays
# Make sure the contents of our repo are in ${HOME}.
# These steps are required for use on mybinder.org.
USER root
COPY . ${HOME}
RUN chown -R ${USER} ${HOME}
# While root, upgrade the .NET Core SDK.