Skip to content

Instantly share code, notes, and snippets.

import sys
from random import randrange
if __name__ == "__main__":
while True:
print("Level: ", end="")
try:
level = int(input())
except ValueError:
level = False
import numpy as np
def weighted_quantile_type_7(a, q, weights=None, axis=None):
def _func_1d(arr, q, weights):
n = len(arr)
if weights is None:
weights = np.repeat(1 / n, n)
else:
@cjauvin
cjauvin / hru_deduping.py
Last active February 13, 2021 15:56
HRU Deduping
In [65]: import pandas as pd
In [66]: a = pd.DataFrame({'hru': [9, 10, 10], 'sub': [100, 100, 100], 'down': [-1, 200, -1]})
In [67]: a
Out[67]:
hru sub down
0 9 100 -1
1 10 100 200
2 10 100 -1
import sqlalchemy as db
from sqlalchemy import Table, Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
engine = db.create_engine("sqlite:///toto.db", echo=True)
@cjauvin
cjauvin / seb.py
Last active November 25, 2018 20:48
from flask import Flask, send_file
from io import BytesIO
app = Flask(__name__)
@app.route('/get_placements')
def get_placements():
placements = '<Placemark>bla</Placemark>' # replace with your own placement creation logic
f = BytesIO() # memory buffer, acting as a file
# f-strings are new in py3.6+
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import tensorflow as tf
N = 5
M = tf.constant(np.arange(N * N).reshape((N, N)), dtype=tf.int32) # N x N tensor, with values from 0 to N-1
# This code implements a fully differentiable summation of all the elements of M where i != j
# inner loop, on columns
def body(i, r):

Concepts de base en prob

Soleil/Pluienonouitotal
oui75277
non101323
total8515100

Il fait soleil 77% du temps, et il pleut 15% du temps (les deux ne sont pas mutuellement exclusifs).