This file contains 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
================================== FAILURES =================================== | |
______________________ TestSDSSRemote.test_sdss_specobj _______________________ | |
self = <astroquery.sdss.tests.test_sdss_remote.TestSDSSRemote object at 0x000001F802A543C8> | |
def test_sdss_specobj(self): | |
colnames = ['ra', 'dec', 'objid', 'run', 'rerun', 'camcol', 'field', | |
'z', 'plate', 'mjd', 'fiberID', 'specobjid', 'run2d', | |
'instrument'] | |
dtypes = [float, float, int, int, int, int, int, float, int, int, int, |
This file contains 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 | |
a = np.arange(1000000, dtype=float).reshape(1000, 1000) | |
a[100, 100] = np.nan | |
%timeit np.nanmedian(a, axis=None) | |
%timeit np.ma.median(np.ma.masked_invalid(a), axis=None) | |
%timeit np.nanmedian(a, axis=0) | |
%timeit np.ma.median(np.ma.masked_invalid(a), axis=0) | |
%timeit np.nanmedian(a, axis=1) |
This file contains 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 | |
# ============================================================================= | |
# | |
# Implementations | |
# | |
# Wrapped inside functions so the benchmark fails during setup not completly | |
# if library with this version or Python2 doesn't support this | |
# | |
# ============================================================================= |
This file contains 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 iteration_utilities import all_monotone | |
from itertools import tee | |
import operator | |
def is_sorted_by_alexandre(iterable, compare=operator.le): | |
a, b = tee(iterable) | |
next(b, None) | |
return all(map(compare, a, b)) |
This file contains 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
/* Helper to warn about deprecated tp_compare return values. Return: | |
-2 for an exception; | |
-1 if v < w; | |
0 if v == w; | |
1 if v > w. | |
(This function cannot return 2.) | |
*/ | |
static int | |
adjust_tp_compare(int c) | |
{ |
This file contains 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 itertools import groupby | |
import math | |
import numpy as np | |
import numba as nb | |
def Divakar(a): | |
# Mask of NaNs | |
mask = np.concatenate(([False],np.isnan(a),[False])) |
This file contains 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
class Streams(object): | |
def _initialize_attributes(self): | |
try: | |
from IPython import get_ipython | |
except ImportError: | |
pass | |
try: | |
get_ipython() | |
except NameError: | |
self._OutStream = None |
This file contains 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
# explicit loops | |
l = [] | |
for a in x: | |
for b in a: | |
if b == k: | |
l.append(b) | |
# list-comprehension | |
[b | |
for a in x |
This file contains 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 iteration_utilities import roundrobin | |
from itertools import chain, cycle, islice | |
def shuffle_mseifert(L): | |
return list(roundrobin(L[:len(L)//2], L[len(L)//2:])) | |
def shuffle_mitch(l): | |
return list(chain.from_iterable(zip(l[:len(l)//2], l[len(l)//2:]))) |
This file contains 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
%load_ext cython | |
%%cython | |
from cpython.sequence cimport PySequence_Check | |
def is_sequence(val): | |
return PySequence_Check(val) | |
class A(object): |