Skip to content

Instantly share code, notes, and snippets.

View Uiuran's full-sized avatar
💭
Focus and Flowers

Daniel Penalva Uiuran

💭
Focus and Flowers
View GitHub Profile
@Uiuran
Uiuran / gist:52e1a0a377621522edbc70fbd024e7c9
Created October 7, 2019 01:31
Builder with super function as calling Parent Class
class Person(object):
def __init__(self):
self.name = None
self.position = None
self.date_of_birth = None
def __str__(self):
return '{} born on {} works as a {}'.format(self.name,self.date_of_birth,self.position)
# @staticmethod
# def new():
# return PersonBuilder()
@Uiuran
Uiuran / keras_super_duper_decorator.py
Created September 23, 2019 12:31
Decorator used in keras test methods, ultra xeno though, hard to understand
def run_with_all_model_types(
test_or_class=None,
exclude_models=None):
"""Execute the decorated test with all Keras model types.
This decorator is intended to be applied either to individual test methods in
a `keras_parameterized.TestCase` class, or directly to a test class that
extends it. Doing so will cause the contents of the individual test
method (or all test methods in the class) to be executed multiple times - once
for each Keras model type.
The Keras model types are: ['functional', 'subclass', 'sequential']
@Uiuran
Uiuran / rw2D.py
Last active December 21, 2018 23:14
Metodo monte-carlo
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
dx = 0.001;
dy = 0.001;
alpha = 0.025; # quando alpha e beta != 0 teremos drift, isso eh, ddeslocamento do centro de massa
beta = 0.025; #
a = 0.25; # quando a = b = 1/4, difusao eh homogenea
b = 0.25; #
@Uiuran
Uiuran / kc.py
Last active December 21, 2018 22:43
Simula automata neural de Kinouchi-Copelli
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
def kc( ativos0, num_estados, rede, tempo):
firstN = set();
ativos = set();
ativos.add(ativos0);
firstN.add(ativos0);
@Uiuran
Uiuran / multi_topos.py
Last active January 4, 2016 04:19
This code is to simulate a multi-topology network with homeostatic individuals that are influential on their neighbors. The code is not perfect yet, mnet_pack are networkx, numpy and other necessaries packages to come...
from mnet_pack import *
# Multi topologies network and cyclic Kinouchi-Copelli like automatas
# Copyleft (AA) 2014 ooOOOoooOOOoo8OOOooooOOOOooo8ooOO69
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
@Uiuran
Uiuran / kuramoto.py
Last active December 18, 2015 21:28
deterministic kuramoto models
import numpy as np
from types import *
sin = np.sin
# Deterministic Kuramoto model like functions
# Copyright (C) 2013 \0/\o/\0/\o/\0/
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
'''
@author: Uiuran 2013
'''
from GraphMovie import GraphMovie
import igraph
import numpy as np
import agents0020 as am
if __name__ == "__main__":
@Uiuran
Uiuran / agent0020.py
Last active December 15, 2015 19:49
Preliminar version of random agent in complex network topology simulation AND animation
#agent002, agent simulation in a General Topology with 1 float field for each agent (node) and random sampling of interactions (egdes) between time step, the process evaluation is a adition of the mean interaction to the fields { fieldA[time] =( fieldA[ time-1] + fieldB[time-1])/2 , the same is true for fieldB}, ie homophilic interaction, the agents start with random float number sampled from uniform [0,1). This process prints the visualization of the network.
#import paintGraph as pg
import numpy as np
import networkx as nx
import GraphMovie as gm
import igraph
class AgentModel(object):
'''
@Uiuran
Uiuran / kuramotoGrid.py
Last active December 25, 2018 18:13
Sinusoid coupled functions with natural frequency "w" with eight neighbors coupling Grid (except for the border that behaves like a bi-dimensional Grid)
import numpy as np
import scipy
from scipy.integrate import *
import matplotlib.pyplot as plot
sin = np.sin
def kuramotoGrid(x,t0, K, w):
l = [len(w[1,:]),len(w[:,1])];
x = x.reshape((l[1],l[0]));
# l[0] is horizontal, columns, l[1] is vertical, rows, dimension
@Uiuran
Uiuran / simulateImage.py
Last active December 15, 2015 12:39
Generative texture research
import Image
import numpy as np
import scipy
# To test the codes put a number between [1,2] in the variable do_code
do_code = 2;
if do_code == 1:
import kuramotoGrid as kg
K = 20.0