import numpy, cdtime, vcs from vcs.testing.common import test_values_setting x=vcs.init() x.drawlogooff() f=x.createfillarea() assert(vcs.queries.isfillarea(f)) test_values_setting(f,"style",[f,0,1,2,3,"hatch","pattern","hallow"],[-1,4,"foo",[],{},(),None]) test_values_setting(f,"index",[None,f,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,],[0,21,"foo",[],(),{}]) test_values_setting(f,"color",range(256)) test_values_setting(f,"color",[f,"red",[2,3,4],[[2,3,4],],[[1,2,3,5],],None],[-1,256,[[2,3,4,6,5],]]) test_values_setting(f,["x","y"],[None,[1,2,3],],[1,"sdf",[1,2,"3"],[[1,2,3],2]]) b = x.createfillarea("test_f_ok",f.name) assert(b.name == "test_f_ok") assert(b.style == ["hallow",]) assert(b.index == [20,]) assert(b.color == [[0.,0.,0.,100.]]) assert(f.x == [1,2,3]) assert(f.y == [1,2,3])
import numpy, cdtime, vcs from vcs.testing.common import test_values_setting x=vcs.init() x.drawlogooff() p=x.createprojection() assert(p.type == "linear") assert(vcs.queries.isprojection(p)) test_values_setting(p, "type", [-1,-2,-3,'linear', 'albers equal area', 'lambert', 'mercator', 'polar', 'polyconic', 'equid conic a', 'transverse mercator', 'stereographic', 'lambert azimuthal', 'azimuthal', 'gnomonic', 'orthographic', 'gen. vert. near per', 'sinusoidal', 'equirectangular', 'miller', 'van der grinten', 'hotin', 'robinson', 'space oblique', 'alaska', 'interrupted goode', 'mollweide', 'interrupted mollweide', 'hammer', 'wagner iv', 'wagner vii', 'oblated', 0, 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,p,"POLAR","leac"," POlyConic ",],["utm","state plane","foo",-4,31,256,[],{},]) b = x.createprojection("test_b_ok",p.name) assert(b.name == "test_b_ok") assert(b.type == "polyconic") ## From vcs validation for t in range(31): good = [] bad =[] pos = [] for param,val in vcs.VCS_validation_functions.proj_ok_parameters.iteritems(): if t in val[0]: good.append(param) pos.append(val[1]) else: bad.append(param) b.type=t b._parameters = [1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20, 1e+20] for i,att in enumerate(good): if (att in ['azimuthalangle','azimuthallongitude','satellite','path',] and (b.parameters[12]==0. or b.parameters[12]==1.e20)) \ or \ ( att=='standardparallel' and b.parameters[8]==1) \
assert b.missing == (0.0, 0.0, 0.0, 100.0) ## Now test setting attributes correctly and incorrectly b.projection = "linear" assert b.projection == "linear" p = x.createprojection("test_bfill") b.projection = p assert b.projection == p.name try: b.projection = "not_a_valid_projection" raise Exception, "Should have been able to set boxfill projection to a projection that does not exists" except: pass test_values_setting( b, ["xticlabels1", "xticlabels2", "xmtics1", "xmtics2", "yticlabels1", "yticlabels2", "ymtics1", "ymtics2"], ["*", "", None, "lon20", {23.0: "Hi"}], ["bla", 10, 10.0, [], ()], ) test_values_setting(b, ["datawc_x1", "datawc_x2", "datawc_y1", "datawc_y2"], [56, 56.7], ["bla", [4, 5, 6], None, {}]) test_values_setting(b, "datawc_timeunits", ["months since 1800", "years since 234"], [1, "bla", 2.0, {}, [], (), None]) test_values_setting( b, "datawc_calendar", [ cdtime.GregorianCalendar, cdtime.JulianCalendar, cdtime.MixedCalendar, cdtime.NoLeapCalendar, cdtime.StandardCalendar, ], [4, "bla", {}, [], (), None],
b.projection = 'linear' assert (b.projection == "linear") p = x.createprojection("test_bfill") b.projection = p assert (b.projection == p.name) try: b.projection = "not_a_valid_projection" raise Exception, "Should have been able to set boxfill projection to a projection that does not exists" except: pass test_values_setting(b, [ "xticlabels1", "xticlabels2", "xmtics1", "xmtics2", "yticlabels1", "yticlabels2", "ymtics1", "ymtics2", ], ["*", "", None, "lon20", { 23.: "Hi", }], ["bla", 10, 10., [], ()]) test_values_setting(b, ["datawc_x1", "datawc_x2", "datawc_y1", "datawc_y2"], [ 56, 56.7, ], ["bla", [4, 5, 6], None, {}]) test_values_setting(b, "datawc_timeunits", [ "months since 1800", "years since 234", ], [1, "bla", 2., {}, [], (), None]) test_values_setting(b, "datawc_calendar", [ cdtime.GregorianCalendar, cdtime.JulianCalendar, cdtime.MixedCalendar,
import numpy, cdtime, vcs from vcs.testing.common import test_values_setting x = vcs.init() x.drawlogooff() f = x.createfillarea() assert (vcs.queries.isfillarea(f)) test_values_setting(f, "style", [f, 0, 1, 2, 3, "hatch", "pattern", "hallow"], [-1, 4, "foo", [], {}, (), None]) test_values_setting(f, "index", [ None, f, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,