2021-01-01から1年間の記事一覧

Streamlit: Using cache not for performance but for repeatability

I came up with using random module for random selection from initial item of multi selectbox. But my first implementation like below did not work well. import random import streamlit as st def genRandIntWithoutCache(): return random.randin…

Testing numpy array

I tried to test below. But 4th assertion could not be passed. import numpy as np def test__sigmoid(): assert round(sigmoid(-5), 7) == (0.0066929) assert round(sigmoid(0), 5) == (0.5000000) assert round(sigmoid(5), 5) == (0.99331) assert (s…

Sort multi edge nodes with networkx in python

import import networkx as nx import numpy as np Create multi graph G = nx.MultiGraph() G.add_nodes_from(["A", "B", "C", "D", "E", "F"]) G.add_edges_from([("A", "B"), ("B", "C"), ("B", "D"), ("C", "D"), ("A", "E"), ("C", "E"), ("C", "F"), (…