Skip to content

Instantly share code, notes, and snippets.

View Midnighter's full-sized avatar

Moritz E. Beber Midnighter

View GitHub Profile
@Midnighter
Midnighter / resilient_tree_copy.py
Created May 19, 2024 06:39
A simple CLI to copy directory trees and keep trying upon errors.
#!/usr/bin/env python3
# Copyright (c) 2020, Moritz E. Beber.
"""Copy entire directory trees and keep trying on errors."""
import argparse
import logging
@Midnighter
Midnighter / gpr_to_dnf.py
Created March 26, 2021 12:32
Convert all gene-protein-reaction (GPR) associations of a metabolic model defined in SBML to disjunctive normal form (DNF).
#!/usr/bin/env python
# Copyright (c) 2021 Moritz E. Beber
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
@Midnighter
Midnighter / libsbml_nm.txt
Last active March 24, 2021 16:38
Shared symbols exported by libsbml and symengine
U acos
0000000000ae1fc0 T adler32
0000000000ae2450 T adler32_combine
0000000000925fd0 T AlgebraicRule_clone
0000000000925ea0 T AlgebraicRule_create
0000000000925f30 T AlgebraicRule_createWithNS
0000000000925fb0 T AlgebraicRule_free
0000000000926010 T AlgebraicRule_getFormula
0000000000925ff0 T AlgebraicRule_getMath
0000000000926170 T AlgebraicRule_hasRequiredAttributes
@Midnighter
Midnighter / summaries.ipynb
Last active August 19, 2020 20:42
COBRApy Summaries
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Midnighter
Midnighter / single_multi_index.ipynb
Last active August 9, 2020 10:35
Return value of a MultiIndex with a single level
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Midnighter
Midnighter / watch_this.py
Last active August 7, 2020 19:20 — forked from mikeckennedy/watch_this.py
Add C# += / -= event subscriptions to Python using the Events package
import functools
from events import Events # Note you must pip install events
class set_event:
"""Define a class-based setter method decorator."""
def __init__(self, func, event):
super().__init__()
@Midnighter
Midnighter / httpx_gcr.ipynb
Created May 27, 2020 20:31
Proof of concept interaction with the Google Container Registry.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Midnighter
Midnighter / test_benchmark_pyparsing.py
Created August 18, 2019 20:32
Benchmark different unicode-content parsing expressions using pyparsing.
# Copyright 2011-2019 Moritz Emanuel Beber
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
@Midnighter
Midnighter / README.md
Last active September 8, 2019 13:24
How to make autodoc recognize any Python module.

How to Auto Document Your Pytest Test Suite

Triggered by this recent tweet advertising a new pytest plugin that can document itself, I want to briefly describe how you can get sphinx-autodoc to recognize and document the tests.

It is slightly more work since you have to tell Sphinx to auto-document each individual module manually. At least, I haven't yet spent the time to os.walk the test directory and document each one. Assuming the following project

@Midnighter
Midnighter / Pipfile
Created September 2, 2018 22:00
Perform a single gene deletion study using COBRApy and record the flux distributions.
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
cobra = "*"
python-libsbml = "*"
optlang = "*"
pandas = "*"