Skip to content

Instantly share code, notes, and snippets.

@MSeifert04
MSeifert04 / ndmeta.py
Created December 23, 2015 02:04
Using dynamically generated subclasses.
class MetaMixinBase(object):
# This will be overwritten by the type-creator
_base = 'test'
def propagate_add(self, other, kw):
'''
Empty for now but later this might contain the propagation of meta in addition.
'''
self._propagate_possible(other)
return None
@MSeifert04
MSeifert04 / ndmeta2.py
Created December 23, 2015 02:26
Using wrapper implementing getter/setter
class MetaWrapperBase(object):
def __init__(self, data):
self.data = data
def propagate_add(self, other, kw):
self._propagate_possible(other)
return None
def _propagate_possible(self, other):
if self.data.__class__.__name__ != other.data.__class__.__name__:
@MSeifert04
MSeifert04 / ndmeta3.py
Created December 23, 2015 02:28
Using invisible wrapper
class MetaWrapperBase(object):
def __init__(self, data):
self.data = data
def propagate_add(self, other, kw):
self._propagate_possible(other)
return None
def _propagate_possible(self, other):
if self.data.__class__.__name__ != other.data.__class__.__name__:
import numpy as numpy
from astropy.io import fits
from scipy.ndimage.filters import uniform_filter
#Directory: /Users/UCL_Astronomy/Documents/UCL/PHASG199/M33_UVOT_sum/UVOTIMSUM/M33_sum_epoch1_um2_norm.img
with fits.open('...') as ima_norm_um2:
#Open UVOTIMSUM file once and close it after extracting the relevant values:
ima_norm_um2_hdr = ima_norm_um2[0].header
ima_norm_um2_data = ima_norm_um2[0].data
#Individual dimensions for number of x pixels and number of y pixels:
@MSeifert04
MSeifert04 / bool.py
Last active March 12, 2016 03:58
bool evaluation
class Test(object):
def __init__(self, var):
self.var = var
def __bool__(self):
print 'called it.'
return bool(self.var)
a = Test(10)
[work] C:\Users\-\GIT\asv>python setup.py test
running test
running egg_info
writing requirements to asv.egg-info\requires.txt
writing top-level names to asv.egg-info\top_level.txt
writing entry points to asv.egg-info\entry_points.txt
writing asv.egg-info\PKG-INFO
writing dependency_links to asv.egg-info\dependency_links.txt
reading manifest file 'asv.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
[work] C:\Users\-\GIT\asv>python setup.py test
running test
running egg_info
writing asv.egg-info\PKG-INFO
writing top-level names to asv.egg-info\top_level.txt
writing requirements to asv.egg-info\requires.txt
writing dependency_links to asv.egg-info\dependency_links.txt
writing entry points to asv.egg-info\entry_points.txt
reading manifest file 'asv.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
============================= test session starts =============================
platform win32 -- Python 2.7.11, pytest-2.8.3, py-1.4.30, pluggy-0.3.1
benchmark: 3.0.0 (defaults: timer=time.clock disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Running tests with astroquery version 0.3.3.dev3307.
Running tests in lib.win-amd64-2.7\astroquery docs.
Date: 2016-06-21T11:29:25
Platform: Windows-10-10.0.10586
C:\-\astroquery>python setup.py test --remote-data
astroquery\sdss\setup_package.py:2: RuntimeWarning: Parent module 'astroquery.sdss' not found while handling absolute import
import os
running test
running build
running build_py
running egg_info
writing requirements to astroquery.egg-info\requires.txt
writing astroquery.egg-info\PKG-INFO
writing top-level names to astroquery.egg-info\top_level.txt
================================== 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,