Skip to content

Instantly share code, notes, and snippets.

View arvidfm's full-sized avatar

Arvid Fahlström Myrman arvidfm

  • Foundry
  • Manchester, UK
View GitHub Profile
@arvidfm
arvidfm / mypy_after.txt
Created January 4, 2024 23:30
textual worker typing
> poetry run mypy --strict worker_typing.py
worker_typing.py:10: error: Value of type variable "NodeType" of function cannot be "int" [type-var]
worker_typing.py:17: error: Value of type variable "NodeType" of function cannot be "NotAWidget" [type-var]
worker_typing.py:28: error: Argument 1 has incompatible type "Callable[[MyWidget, float], set[str]]"; expected "Callable[[MyWidget, float], Coroutine[None, None, Never]]" [arg-type]
worker_typing.py:28: note: This is likely because "blocking_local_worker of MyWidget" has named arguments: "self". Consider marking them positional-only
worker_typing.py:41: error: Argument 1 to "work" has incompatible type "Callable[[MyWidget, float], int]"; expected "Callable[[MyWidget, float], Coroutine[None, None, Never]]" [arg-type]
worker_typing.py:41: note: This is likely because "blocking_simple_decorator of MyWidget" has named arguments: "self". Consider marking them positional-only
worker_typing.py:51: error: Missing positional arguments "arg1", "arg2" in call to "my_
$ pyright --version
pyright 1.1.329
$ pyright test.py
/tmp/test.py
/tmp/test.py:1395:1 - warning: Unsupported escape sequence in string literal (reportInvalidStringEscapeSequence)
0 errors, 1 warning, 0 informations
import timeit
import numpy as np
import theano
import theano.tensor as T
x = theano.shared(np.random.rand(500, 100).astype(theano.config.floatX))
W = theano.shared(np.random.rand(10, 100, 50).astype(theano.config.floatX))
y = theano.shared(np.random.randint(0, 10, 500).astype(theano.config.floatX))
Traceback (most recent call last):
File ".../.venv/lib/python3.5/site-packages/theano/gof/link.py", line 1012, in f
wrapper(i, node, *thunks)
File ".../.venv/lib/python3.5/site-packages/theano/compile/nanguardmode.py", line 307, in nan_check
do_check_on(x[0], node, fn, False)
File ".../.venv/lib/python3.5/site-packages/theano/compile/nanguardmode.py", line 272, in do_check_on
raise AssertionError(msg)
AssertionError: NaN detected
NanGuardMode found an error in the output of a node in this variable:
Elemwise{true_div} [id A] ''
@arvidfm
arvidfm / kth-course-list.py
Last active March 23, 2016 20:50
Fetch course lists from kth.se
import argparse
import asyncio
import re
import sys
import aiohttp
import lxml.html
async def get_periods(session, course):
@arvidfm
arvidfm / anthy.pro
Created November 9, 2014 19:13
anthy test case
######################################################################
# Automatically generated by qmake (3.0) Sun Nov 9 18:05:54 2014
######################################################################
TEMPLATE = app
TARGET = anthy-testcase
INCLUDEPATH += .
QT -= gui
LIBS += -lanthy
CONFIG += debug
@arvidfm
arvidfm / boku (candidate 0)
Created November 5, 2014 02:26
anthy logs
anthy_set_string(this->context, "b")
anthy_get_stat(this->context, &this->conv_stat) -> 1 (conv_stat.nr_segment)
anthy_get_segment(this->context, 0, 0, buf, 1000) -> "B" (buf)
anthy_get_stat(this->context, &this->conv_stat) -> 1 (conv_stat.nr_segment)
anthy_get_segment_stat(this->context, 0, &this->segment_stat) -> 4 (segment_stat.nr_candidate)
anthy_get_segment(this->context, 0, 0, buf, 1000) -> "B" (buf)
anthy_get_segment(this->context, 0, 1, buf, 1000) -> "B" (buf)
anthy_get_segment(this->context, 0, 2, buf, 1000) -> "b" (buf)
anthy_get_segment(this->context, 0, 3, buf, 1000) -> "b" (buf)
anthy_set_prediction_string(this->context, "b")
@arvidfm
arvidfm / asyncio-tornado.py
Last active December 4, 2018 12:56
Running Tornado on asyncio's event loop, including 'yield from' support in request handlers
import asyncio
import tornado.concurrent
import tornado.ioloop
import tornado.web
import tornado.platform.asyncio
import tornado.httpclient
class ReqHandler(tornado.web.RequestHandler):
async def get(self):
TEMPLATE = lib
TARGET = keepaliveplugin
TARGET = $$qtLibraryTarget($$TARGET)
QT += dbus qml
CONFIG += debug plugin
INCLUDEPATH += nemo-keepalive/lib
PROJECT = PROJECT_NAME_HERE
TARGET_PATH = /usr/share/harbour-$$PROJECT/harbour/$$PROJECT/keepalive