Skip to content

Instantly share code, notes, and snippets.

================================== 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,
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)
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
#
# =============================================================================
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))
/* 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)
{
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]))
class Streams(object):
def _initialize_attributes(self):
try:
from IPython import get_ipython
except ImportError:
pass
try:
get_ipython()
except NameError:
self._OutStream = None
# explicit loops
l = []
for a in x:
for b in a:
if b == k:
l.append(b)
# list-comprehension
[b
for a in x
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:])))
%load_ext cython
%%cython
from cpython.sequence cimport PySequence_Check
def is_sequence(val):
return PySequence_Check(val)
class A(object):