This file contains hidden or 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
def wvisibility(x, left, right, i, graph): | |
'''Weighted visibility module of sort and conquer algorithm proposed by Ghosh et al. | |
Parameters: | |
x: numpy.array | |
A 1d time series. | |
left: int | |
Leftmost node connected to current node. | |
right: int | |
Rightmost node connected to current node. |
This file contains hidden or 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
def sort_and_conquer(x): | |
'''Sort and conquer algorithm proposed by Ghosh et al. | |
Parameters: | |
x: numpy.array | |
A 1d time series. | |
''' | |
n = x.size | |
sortd = np.argsort(x)[::-1] | |
graph = sparse.lil_matrix((n, n)) |
This file contains hidden or 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
def get_degree_sequence(graph): | |
'''Get a degree sequence of a graph. | |
Parameters: | |
graph: scipy.sparse.csr.csr_matrix | |
A graph in compressed sparse row format. | |
''' | |
degree_seq = graph.sum(axis=0).A.ravel() | |
return degree_seq |
This file contains hidden or 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
def get_degree_distribution(degseq): | |
'''Get a degree distribution of a graph. | |
Parameters: | |
degseq: numpy.ndarray | |
A sequence of degrees. | |
''' | |
degree, frequency = np.unique(degseq, return_counts=True) | |
distribution = frequency / frequency.sum() | |
return distribution |
This file contains hidden or 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
require('dotenv').config() | |
const config = require('./config') | |
const twit = require('twit') | |
const twitter = new twit(config) |
This file contains hidden or 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
function rogerio_skylab(id_str){ | |
.post( | |
'statuses/destroy/:id', | |
{id: id_str} | |
) | |
.then(result => { | |
console.log(result.data) | |
}) | |
.catch(error => { |
This file contains hidden or 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
.get( | |
'statuses/user_timeline', | |
{screen_name: 'vncsna', | |
count: 200, | |
exclude_replies: true} | |
) | |
.then(result => { | |
tweets = result.data | |
for (let tweet of tweets) { |
This file contains hidden or 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
function follow_user(user_id){ | |
.post( | |
'friendships/create', | |
{user_id: user_id, | |
follow: false} | |
) | |
.then(result => { | |
let tweet_pt = `Seguindo @${result.data.screen_name}!?` | |
let tweet_en = `Following @${result.data.screen_name}!!` |
This file contains hidden or 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
function follow_protocol(number=0){ | |
let query = coin_toss ? 'protocolo' : 'protocol' | |
.get( | |
'users/search', | |
{q: query, | |
page: number, | |
count: 20, | |
include_entities: false} |
This file contains hidden or 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
function post_tweet(tweet){ | |
twitter.post( | |
'statuses/update', | |
{'status': tweet} | |
) | |
} | |
function post_phrase(){ | |
let phrases = require('./scraping/pensador-phrases-2020-12-28.json') | |
let keys = Object.keys(phrases) |
OlderNewer