Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

# 

# LSST Data Management System 

# Copyright 2008, 2009, 2010 LSST Corporation. 

# 

# This product includes software developed by the 

# LSST Project (http://www.lsst.org/). 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the LSST License Statement and 

# the GNU General Public License along with this program. If not, 

# see <http://www.lsstcorp.org/LegalNotices/>. 

# 

 

""" 

Tests for pickles of some afw types 

""" 

 

import unittest 

import pickle 

 

import lsst.daf.base as dafBase 

import lsst.utils.tests 

import lsst.geom 

import lsst.afw.geom as afwGeom 

import lsst.afw.geom.ellipses as geomEllip 

 

 

class PickleBase: 

"""A test case for pickles""" 

 

def setUp(self): 

raise NotImplementedError( 

"Need to inherit and create the 'data' element.") 

 

def tearDown(self): 

del self.data 

 

def assertPickled(self, new): 

"""Assert that the pickled data is the same as the original 

 

Subclasses should override this method if the particular data 

doesn't support the == operator. 

""" 

self.assertEqual(new, self.data) 

 

def testPickle(self): 

"""Test round-trip pickle""" 

pickled = pickle.dumps(self.data) 

newData = pickle.loads(pickled) 

self.assertPickled(newData) 

 

 

class AngleTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

self.data = 1.0*lsst.geom.degrees 

 

 

class QuadrupoleTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

ixx, iyy, ixy = 1.0, 1.0, 0.0 

self.data = afwGeom.Quadrupole(ixx, iyy, ixy) 

 

 

class AxesTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

a, b, theta = 1.0, 1.0, 0.0 

self.data = geomEllip.Axes(a, b, theta) 

 

 

class Point2DTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

x, y = 1.0, 1.0 

self.data = lsst.geom.Point2D(x, y) 

 

 

class Point2ITestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

x, y = 1, 1 

self.data = lsst.geom.Point2I(x, y) 

 

 

class Point3DTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

x, y, z = 1.0, 1.0, 1.0 

self.data = lsst.geom.Point3D(x, y, z) 

 

 

class Point3ITestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

x, y, z = 1, 1, 1 

self.data = lsst.geom.Point3I(x, y, z) 

 

 

class Extent2DTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

x, y = 1.0, 1.0 

self.data = lsst.geom.Extent2D(x, y) 

 

 

class Extent3DTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

x, y, z = 1, 1, 1 

self.data = lsst.geom.Extent3D(x, y, z) 

 

 

class Extent2ITestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

x, y = 1, 1 

self.data = lsst.geom.Extent2I(x, y) 

 

 

class Extent3ITestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

x, y, z = 1, 1, 1 

self.data = lsst.geom.Extent3I(x, y, z) 

 

 

class Box2DTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

p, e = lsst.geom.Point2D(1.0, 1.0), lsst.geom.Extent2D(0.5, 0.5) 

self.data = lsst.geom.Box2D(p, e) 

 

 

class Box2ITestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

p, e = lsst.geom.Point2I(1, 2), lsst.geom.Extent2I(1, 1) 

self.data = lsst.geom.Box2I(p, e) 

 

 

class AffineTransformTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

scale = 2.2 

linear = lsst.geom.LinearTransform().makeScaling(scale) 

dx, dy = 1.1, 3.3 

trans = lsst.geom.Extent2D(dx, dy) 

self.data = lsst.geom.AffineTransform(linear, trans) 

 

def assertPickled(self, new): 

self.assertListEqual(new.getMatrix().flatten().tolist(), 

self.data.getMatrix().flatten().tolist()) 

 

 

class LinearTransformTestCase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

scale = 2.0 

self.data = lsst.geom.LinearTransform().makeScaling(scale) 

 

def assertPickled(self, new): 

self.assertListEqual(new.getMatrix().flatten().tolist(), 

self.data.getMatrix().flatten().tolist()) 

 

 

class WcsPickleBase(PickleBase, unittest.TestCase): 

 

def setUp(self): 

# define a TAN-SIP WCS 

hdr = dafBase.PropertyList() 

hdr.add("NAXIS", 2) 

hdr.add("EQUINOX", 2000.0000000000) 

hdr.add("RADESYS", "FK5") 

hdr.add("CRPIX1", 947.04531175212) 

hdr.add("CRPIX2", -305.70042176782) 

hdr.add("CD1_1", -5.6081060666063e-05) 

hdr.add("CD1_2", 1.1941349711530e-10) 

hdr.add("CD2_1", 1.1938226362497e-10) 

hdr.add("CD2_2", 5.6066392248206e-05) 

hdr.add("CRVAL1", 5.5350859380564) 

hdr.add("CRVAL2", -0.57805534748292) 

hdr.add("CUNIT1", "deg") 

hdr.add("CUNIT2", "deg") 

hdr.add("A_ORDER", 3) 

hdr.add("A_0_0", -3.4299726900155e-05) 

hdr.add("A_0_2", 2.9999243742039e-08) 

hdr.add("A_0_3", 5.3160367322875e-12) 

hdr.add("A_1_0", -1.1102230246252e-16) 

hdr.add("A_1_1", 1.7804837804549e-07) 

hdr.add("A_1_2", -3.9117665277930e-10) 

hdr.add("A_2_0", 1.2614116305773e-07) 

hdr.add("A_2_1", 2.4753748298399e-12) 

hdr.add("A_3_0", -4.0559790823371e-10) 

hdr.add("B_ORDER", 3) 

hdr.add("B_0_0", -0.00040333633853922) 

hdr.add("B_0_2", 2.7329405108287e-07) 

hdr.add("B_0_3", -4.1945333823804e-10) 

hdr.add("B_1_1", 1.0211300606274e-07) 

hdr.add("B_1_2", -1.1907781112538e-12) 

hdr.add("B_2_0", 7.1256679698479e-08) 

hdr.add("B_2_1", -4.0026664120969e-10) 

hdr.add("B_3_0", 7.2509034631981e-14) 

hdr.add("AP_ORDER", 5) 

hdr.add("AP_0_0", 0.065169424373537) 

hdr.add("AP_0_1", 3.5323035231808e-05) 

hdr.add("AP_0_2", -2.4878457741060e-08) 

hdr.add("AP_0_3", -1.4288745247360e-11) 

hdr.add("AP_0_4", -2.0000000098183) 

hdr.add("AP_0_5", 4.3337569354109e-19) 

hdr.add("AP_1_0", 1.9993638555698) 

hdr.add("AP_1_1", -2.0722860000493e-07) 

hdr.add("AP_1_2", 4.7562056847339e-10) 

hdr.add("AP_1_3", -8.5172068319818e-06) 

hdr.add("AP_1_4", -1.3242986537057e-18) 

hdr.add("AP_2_0", -1.4594781790233e-07) 

hdr.add("AP_2_1", -2.9254828606617e-12) 

hdr.add("AP_2_2", -2.7203380713516e-11) 

hdr.add("AP_2_3", 1.5030517486646e-19) 

hdr.add("AP_3_0", 4.7856034999197e-10) 

hdr.add("AP_3_1", 1.5571061278960e-15) 

hdr.add("AP_3_2", -3.2422164667295e-18) 

hdr.add("AP_4_0", 5.8904402441647e-16) 

hdr.add("AP_4_1", -4.5488928339401e-20) 

hdr.add("AP_5_0", -1.3198044795585e-18) 

hdr.add("BP_ORDER", 5) 

hdr.add("BP_0_0", 0.00025729974056661) 

hdr.add("BP_0_1", -0.00060857907313083) 

hdr.add("BP_0_2", -3.1283728005742e-07) 

hdr.add("BP_0_3", 5.0413932972962e-10) 

hdr.add("BP_0_4", -0.0046142128142681) 

hdr.add("BP_0_5", -2.2359607268985e-18) 

hdr.add("BP_1_0", 0.0046783112625990) 

hdr.add("BP_1_1", -1.2304042740813e-07) 

hdr.add("BP_1_2", -2.3756827881344e-12) 

hdr.add("BP_1_3", -3.9300202582816e-08) 

hdr.add("BP_1_4", -9.7385290942256e-21) 

hdr.add("BP_2_0", -6.5238116398890e-08) 

hdr.add("BP_2_1", 4.7855579009100e-10) 

hdr.add("BP_2_2", -1.2297758131839e-13) 

hdr.add("BP_2_3", -3.0849793267035e-18) 

hdr.add("BP_3_0", -9.3923321275113e-12) 

hdr.add("BP_3_1", -1.3193479628568e-17) 

hdr.add("BP_3_2", 2.1762350028059e-19) 

hdr.add("BP_4_0", -5.9687252632035e-16) 

hdr.add("BP_4_1", -1.4096893423344e-18) 

hdr.add("BP_5_0", 2.8085458107813e-19) 

hdr.add("CTYPE1", "RA---TAN-SIP") 

hdr.add("CTYPE2", "DEC--TAN-SIP") 

self.data = afwGeom.makeSkyWcs(hdr) 

 

 

class TestMemory(lsst.utils.tests.MemoryTestCase): 

pass 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

271 ↛ 272line 271 didn't jump to line 272, because the condition on line 271 was never trueif __name__ == "__main__": 

lsst.utils.tests.init() 

unittest.main()