This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a work-around around Google Slides' limitation to 1600x1600 pixel images which make full-screen graphics look pixelated | |
# See this thread: https://support.google.com/docs/thread/9031600/how-can-i-stop-google-slides-applying-their-extreme-image-compression-and-resampling?hl=en | |
# requires ImageMagick | |
# Run on image of e.g. 3840x2160 size for 16:9 4K | |
convert YOUR-IMAGE-NAME.png -crop 3x2-0-0@ +repage +adjoin YOUR-IMAGE-NAME-tile-%d.png | |
# This create 2x3 = 6 tiles that can be pasted into Google Slides. They can be grouped and act as one single image which renders sharply. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
def allow_simulate_exception(exception_class=Exception): | |
def _allow_simulate_exception(method): | |
"""Decorator that allows to raise an exception """ | |
@wraps(method) | |
def _raise_exception_if_method_name_fits(self, *method_args, | |
**method_kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cachetools import cached, LRUCache, Cache | |
from cachetools.keys import hashkey | |
from time import sleep | |
| |
class LRUCacheEnsemble: | |
def __init__(self, maxsize_ensemble, maxsize_caches): | |
self.maxsize_ensemble = maxsize_ensemble | |
self.maxsize_caches = maxsize_caches | |
self.caches = LRUCache(maxsize=maxsize_ensemble) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def find_nearest(array, value): | |
array = np.asarray(array) | |
idx = (np.abs(array - value)).argmin() | |
return idx, array[idx] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pypmj as jpy | |
class SimulationSetClean(jpy.SimulationSet): | |
""" Extends `SimulationSet` and simply forces to start with an empty | |
H5-store each time it is initialized. | |
""" | |
def __init__(self, *args, **kwargs): | |
self._start_withclean_H5_store = True |