Skip to content

Instantly share code, notes, and snippets.

View noskill's full-sized avatar

Anatoly Belikov noskill

  • SingularityNet
  • Russia, Chekhov
View GitHub Profile
@noskill
noskill / example.py
Last active February 26, 2020 14:22
multiindex dataframe in pandas
import pandas as pd
from pandas.core.indexes.api import ensure_index_from_sequences
col_dict = {'FrameId':(0,), 'Id':(1,), 'X': (321.89,), 'Y': (381.81,), 'Width': (39.45,), 'Height': (49.45,), 'ClassId': (-1,), 'Visibility': (-1,), 'unused': (-1,)}
names = ['X', 'Y', 'Width', 'Height', 'Confidence', 'ClassId', 'Visibility', 'unused']
arrays = col_dict['FrameId'], col_dict['Id']
@noskill
noskill / converter.py
Last active February 18, 2020 13:40
GQA to logic
import re
from collections import defaultdict
import json
two_args_re = re.compile('^([\w\s]+)\((\d+)\)')
two_args_re_no = re.compile('^([\w\s]+)\((-)\)')
many_objects = re.compile('^(\w+)\s\((\d+(\,\d+)+)\)')
one_word = re.compile('^(\w+)($)')
s_re = re.compile('([s|o])\s\((.*)\)')
@noskill
noskill / sinkhorn_test.py
Last active February 10, 2023 16:49
sinkhorn algorithm with pytorch and numpy
import torch
import numpy
np = numpy
from geomloss import SamplesLoss # See also ImagesLoss, VolumesLoss
# preferences, need to be converted to costs
# row i = cost of moving each item from c to place i
# making cost non-negative will not changes solution matrix P
preference = numpy.asarray([[2, 2, 1 , 0 ,0],
@noskill
noskill / main.cpp
Last active December 6, 2019 14:42
embed python with console
#include <Python.h>
#include <iostream>
// adapted from https://github.com/guowei8412/upp-mirror/blob/0325a2fab45b0b65b8bda7d293d4e03412145826/bazaar/PyTest/main.cpp
void SimpleCall()
{
std::cout << "Invoking a python statement:" << std::endl;
PyRun_SimpleString( "from time import time,ctime\n"
"print('Today is',ctime(time()))\n");
@noskill
noskill / load_db.py
Last active October 17, 2019 10:27
load_db
from gremlin_python import statics
from opencog.atomspace import AtomSpace, types
from opencog.scheme_wrapper import scheme_eval
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.driver import client
@noskill
noskill / log.txt
Last active August 7, 2019 09:29
snetd segfault
time="2019-08-07T09:27:30Z" level=info msg="Cobra initialized"
time="2019-08-07T09:27:30Z" level=info msg="Using configuration file" configFile=snetd.config.json
time="2019-08-07T09:27:30Z" level=info PaymentChannelStorageServer="&{ID:storage-1 Scheme:http Host:127.0.0.1 ClientPort:2389 PeerPort:2390 Token:unique-token Cluster:storage-1=http://127.0.0.1:2390 StartupTimeout:1m0s Enabled:true DataDir:/opt/singnet/etcd/ropsten/storage-data-dir-1.etcd LogLevel:info}"
time="2019-08-07T09:27:30Z" level=info PaymentChannelStorageServer="&{ID:storage-1 Scheme:http Host:127.0.0.1 ClientPort:2389 PeerPort:2390 Token:unique-token Cluster:storage-1=http://127.0.0.1:2390 StartupTimeout:1m0s Enabled:true DataDir:/opt/singnet/etcd/ropsten/storage-data-dir-1.etcd LogLevel:info}"
time="2019-08-07T09:27:30Z" level=info ClientURL="http://127.0.0.1:2389"
time="2019-08-07T09:27:30Z" level=info PeerURL="http://127.0.0.1:2390"
time="2019-08-07T09:27:30Z" level=info msg="[listening for peers on http://127.0.0.1:2390]" pkg=embed
tim
@noskill
noskill / test.py
Last active July 31, 2019 09:47
alpha-equivalence
from opencog.utilities import initialize_opencog, tmp_atomspace
from opencog.type_constructors import *
from opencog.bindlink import execute_atom
def test1():
atomspace = AtomSpace()
initialize_opencog(atomspace)
imp1 = ImplicationLink(
VariableNode("X0"),
@noskill
noskill / glob.py
Created February 27, 2019 14:36
glob example
from opencog.atomspace import AtomSpace, types
from opencog.type_constructors import *
from opencog.atomspace import create_child_atomspace
from opencog.utilities import initialize_opencog, finalize_opencog
from opencog.bindlink import execute_atom, evaluate_atom
a = AtomSpace()
initialize_opencog(a)
@noskill
noskill / config.yml
Last active February 27, 2019 07:48
runnable locally circleci atomspace config
version: 2.0
jobs:
build:
docker:
- image: opencog/opencog-deps
user: root
environment:
PGHOST: opencog-postgres
PGUSER: opencog_test
@noskill
noskill / pyt.py
Created November 26, 2018 14:11
pytorch in execution links
from torch import FloatTensor
from torch.autograd import Variable
from opencog.bindlink import execute_atom, evaluate_atom
from opencog.scheme_wrapper import scheme_eval, scheme_eval_h
from opencog.atomspace import TruthValue
from opencog.backwardchainer import BackwardChainer
from opencog.type_constructors import *
from opencog.utilities import initialize_opencog
from opencog.scheme_wrapper import load_scm
import opencog.logger