Skip to content

Instantly share code, notes, and snippets.

View drorata's full-sized avatar

Dror Atariah drorata

View GitHub Profile
@drorata
drorata / test.py
Last active September 28, 2017 12:28
Problem with 2nd-dependent option using click
"""
Following on the answer: https://stackoverflow.com/a/46451650/671013
Fix of version https://gist.github.com/drorata/1fa68b477d94aea5d37e87aa56e09295/6678ad2056edc60ee77a4e986c626f5dcb662a2a
"""
import click
class OptionRequiredIf(click.Option):
@drorata
drorata / example.ipynb
Created October 4, 2017 13:36
Sequential aggregations using Pandas
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drorata
drorata / foo.sh
Created November 1, 2017 15:49
Batch removing conda environments
for i in `conda env list | grep test | cut -d" " -f1`;
do
conda env remove -n $i
done
@drorata
drorata / Chi squared example.ipynb
Last active February 9, 2018 07:57
Reproducing a blog post
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am drorata on github.
  • I am drorata (https://keybase.io/drorata) on keybase.
  • I have a public key ASAZL79Xn8nWNG3itxSCpryTA_ClCeZuZlxRei2CYvJpHQo

To claim this, I am signing this object:

@drorata
drorata / average_neighbor_degree_ex.ipynb
Created August 8, 2018 18:42
Example of average_neighbor_degree
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drorata
drorata / foo.py
Created September 28, 2018 15:01
Nested groups using click
import click
@click.group()
def app():
pass
@app.command()
@click.option('-x')
@drorata
drorata / test_env_vars.py
Created November 1, 2018 12:48
Minimal example of mocking environment variables using PyTest
def test_example(monkeypatch):
# Print the value of $FOO. If not defined will be None
print("FOO = %s" % os.getenv('FOO'))
monkeypatch.setenv('FOO', '3.14')
print("FOO = %s" % os.getenv('FOO')) # Expected result: FOO = 3.14
with monkeypatch.context() as m:
m.setenv('FOO', '2.71')
print("FOO = %s" % os.getenv('FOO')) # Expected result: FOO = 2.71
print("FOO = %s" % os.getenv('FOO')) # Expected result: FOO = 3.14
@drorata
drorata / example.ipynb
Last active November 15, 2018 08:01
How to use a scikit-learn transform to create a new feature from two columns of a data frame
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.