Skip to content

Instantly share code, notes, and snippets.

@jenshnielsen
jenshnielsen / pyright_conditional.py
Created December 25, 2022 11:23
some experimentation with pyright
# https://github.com/microsoft/pyright/issues/219
def test_conditional(
z: str | bool,
) -> None:
z_is_stringy = isinstance(z, str)
if z_is_stringy:
z_upper = z.upper()
if z_is_stringy:
❯ pip install spyder==5.0.0 decorator==5.0.5
Collecting spyder==5.0.0
Using cached spyder-5.0.0-py3-none-any.whl (10.6 MB)
Collecting decorator==5.0.5
Using cached decorator-5.0.5-py3-none-any.whl (8.8 kB)
Collecting cookiecutter>=1.6.0
Using cached cookiecutter-1.7.2-py2.py3-none-any.whl (34 kB)
Collecting keyring>=17.0.0
Using cached keyring-23.0.1-py3-none-any.whl (33 kB)
Collecting psutil>=5.3
from ctypes import byref, windll
from ctypes.wintypes import PULONG, LONG
import time
MinimumResolution = LONG()
MaximumResolution = LONG()
CurrentResolution = LONG()
windll.ntdll.NtQueryTimerResolution(byref(MinimumResolution), byref(MaximumResolution), byref(CurrentResolution))
print(f"Minimum {MinimumResolution}, "
f"Maximum {MaximumResolution}, "
f"Current {CurrentResolution}")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Update a simple plot as rapidly as possible to measure speed.
"""
## Add path to library (just for examples; you do not need this)
import initExample
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jenshnielsen
jenshnielsen / fitGlyRke4.py clang run 1 double
Last active February 12, 2016 14:51
fitGlyRke4.py experiments
Data loaded from file: ../../DCPYPS/dcpyps/samples/glydemo/keA.scn
Concentration of agonist = 300.000 microMolar
Resolution for HJC calculations = 40.0 microseconds
Critical gap length to define end of group (tcrit) = 0.600 milliseconds
(defined so that all openings in a group prob come from same channel)
Initial and final vectors for bursts calculated asin Colquhoun, Hawkes & Srodzinski, (1996, eqs 5.8, 5.11).
Number of resolved intervals = 11662
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
568/1 0.015 0.000 406.373 406.373 {built-in method builtins.exec}
1 0.000 0.000 406.373 406.373 fitGlyR4.py:1(<module>)
1 0.000 0.000 405.144 405.144 _minimize.py:36(minimize)
1 0.257 0.257 405.144 405.144 optimize.py:390(_minimize_neldermead)
5759 0.248 0.000 404.773 0.070 fitGlyR4.py:83(dcprogslik)
5758 0.018 0.000 404.721 0.070 optimize.py:283(function_wrapper)
23036 0.040 0.000 400.698 0.017 likelihood.py:1245(__call__)
407795 function calls (397558 primitive calls) in 1.787 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
569/1 0.016 0.000 1.788 1.788 {built-in method builtins.exec}
1 0.000 0.000 1.788 1.788 fitAChR1.py:4(<module>)
1 0.000 0.000 1.210 1.210 _minimize.py:36(minimize)
1 0.010 0.010 1.210 1.210 optimize.py:390(_minimize_neldermead)
468 0.002 0.000 1.195 0.003 fitAChR1.py:18(dcprogslik)