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
import numpy as np | |
def np_z_trim(x, threshold=10, axis=0): | |
""" Replace outliers in numpy ndarray along axis with min or max values | |
within the threshold along this axis, whichever is closer.""" | |
mean = np.mean(x, axis=axis, keepdims=True) | |
std = np.std(x, axis=axis, keepdims=True) | |
masked = np.where(np.abs(x - mean) < threshold * std, x, np.nan) | |
min = np.nanmin(masked, axis=axis, keepdims=True) |
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
from joblib import Parallel, delayed, effective_n_jobs | |
import pandas as pd | |
def gen_even_slices(n, n_packs, *, n_samples=None): | |
"""Generator to create n_packs slices going up to n. | |
Parameters | |
---------- | |
n : int | |
n_packs : int |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/bin/bash | |
# Calculate lines of code in all *.py files excepting folders containig 'site-packages' in names | |
cat `find -name '*.py' ! -path '*site-packages*'` | wc -l - |
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
from django.db import models | |
from typing import Iterable | |
class ListField(models.TextField): | |
""" | |
A custom Django field to represent lists as comma separated strings | |
""" | |
def __init__(self, *args, **kwargs): | |
self.token = kwargs.pop('token', ',') |
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
#!/usr/bin/env python2 | |
""" | |
Solar Analytics code assignment | |
""" | |
from __future__ import print_function | |
__author__ = "Yaroslav Hovorunov" | |
__version__ = "0.1.0" | |
__license__ = "MIT" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.