-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cdat web plot subsetting #1951
Merged
Merged
Cdat web plot subsetting #1951
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
99d489b
cdscan removed use of old modules string and types
doutriaux1 c9da8fb
cleaned up avariable from using types or string module
doutriaux1 c995667
cleaned up cdmsobj from using types or string module
doutriaux1 fb94809
cleaned up axis.py
doutriaux1 d40cb17
cleaned up cdmsNode
doutriaux1 bf68e04
cleaned up coord
doutriaux1 f570c2c
cleaned up all (most?) files
doutriaux1 05e2675
removed string odule wheen possible
doutriaux1 63b003b
Merge branch 'master' into cdat-web-plot-subsetting
doutriaux1 d5a9a22
Address @danlipsa comments
doutriaux1 4e362a8
Merge branch 'cdat-web-plot-subsetting' of github.com:UV-CDAT/uvcdat …
doutriaux1 6fc54c9
autopep8ed
doutriaux1 751866f
begining of adressing flake8 but giving up
doutriaux1 87f1a8a
merged master in and fixed conflicts
doutriaux1 2d93518
Merge branch 'master' into cdat-web-plot-subsetting
doutriaux1 936600f
Merge branch 'master' into cdat-web-plot-subsetting
doutriaux1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
|
||
"CDMS Variable objects, abstract interface" | ||
import numpy | ||
import types | ||
import string | ||
import re | ||
import warnings | ||
import cdmsNode | ||
|
@@ -404,7 +402,7 @@ def getMissing(self, asarray=0): | |
|
||
if asarray==0 and isinstance(mv, numpy.ndarray): | ||
mv = mv[0] | ||
if type(mv) is types.StringType and self.dtype.char not in ['?','c','O','S']: | ||
if isinstance(mv, basestring) and self.dtype.char not in ['?','c','O','S']: | ||
mv = float(mv) | ||
return mv | ||
|
||
|
@@ -423,17 +421,16 @@ def setMissing(self, value): | |
return | ||
|
||
selftype = self.typecode() | ||
valuetype = type(value) | ||
if valuetype is numpy.ndarray: | ||
if isnstance(value, numpy.ndarray): | ||
value = value.astype(selftype).item() | ||
elif isinstance(value, numpy.floating) or isinstance(value, numpy.integer): | ||
elif isinstance(value, (numpy.floating, numpy.integer)): | ||
value = numpy.array([value], selftype) | ||
elif valuetype in [types.FloatType, types.IntType, types.LongType, types.ComplexType]: | ||
elif isinstance(value, (float, int, long, complex)): | ||
try: | ||
value = numpy.array([value], selftype) | ||
except: # Set fill value when ar[i:j] returns a masked value | ||
value = numpy.array([numpy.ma.default_fill_value(self)], selftype) | ||
elif isinstance(value,(str,numpy.string_,numpy.str,numpy.string0,numpy.str_)) and selftype in ['?','c','O','S']: # '?' for Boolean and object | ||
elif isinstance(value,(basestring,numpy.string_,numpy.str,numpy.string0,numpy.str_)) and selftype in ['?','c','O','S']: # '?' for Boolean and object | ||
pass | ||
else: | ||
raise CDMSError, 'Invalid missing value %s'%`value` | ||
|
@@ -1089,7 +1086,7 @@ def regrid (self, togrid, missing=None, order=None, mask=None, **keywords): | |
|
||
if re.search('^regrid', regridTool, re.I): | ||
if keywords.has_key('diag') and \ | ||
type(keywords['diag']) == types.DictType: | ||
isinstance(keywords['diag'], dict): | ||
keywords['diag']['regridTool'] = 'regrid' | ||
|
||
# the original cdms2 regridder | ||
|
@@ -1206,7 +1203,7 @@ def _single_specs (self, specs): | |
if specs[i] is Ellipsis: | ||
j = myrank - (nsupplied - (i+1)) | ||
else: | ||
if isinstance(specs[i], types.IntType): | ||
if isinstance(specs[i], int): | ||
singles.append(j) | ||
j = j + 1 | ||
i = i + 1 | ||
|
@@ -1227,15 +1224,15 @@ def specs2slices (self, speclist, force=None): | |
slicelist = [] | ||
for i in range(self.rank()): | ||
key = speclist[i] | ||
if isinstance(key, types.IntType): # x[i] | ||
if isinstance(key, int): # x[i] | ||
slicelist.append (slice(key,key+1)) | ||
elif type(key) is types.SliceType: # x[i:j:k] | ||
elif isinstance(key, slice): # x[i:j:k] | ||
slicelist.append(key) | ||
elif key is unspecified or key is None or key == ':': | ||
slicelist.append (slice(0, len(self.getAxis(i)))) | ||
elif key is Ellipsis: | ||
raise CDMSError, "Misuse of ellipsis in specification." | ||
elif type(key) is types.TupleType: | ||
elif sinstance(key, tuple): | ||
slicelist.append(slice(*key)) | ||
else: | ||
raise CDMSError, 'invalid index: %s'% str(key) | ||
|
@@ -1287,13 +1284,13 @@ def reg_specs2slices(self, initspeclist,force=None): | |
|
||
for i in range(self.rank()): | ||
item = speclist[i] | ||
if isinstance(item, types.SliceType): | ||
if isinstance(item, slice): | ||
newitem = item | ||
elif item==':' or item is None or item is unspecified: | ||
axis = self.getAxis(i) | ||
newitem = slice(0,len(axis)) | ||
elif isinstance(item, types.ListType) or \ | ||
isinstance(item, types.TupleType): | ||
elif isinstance(item, list) or \ | ||
isinstance(item, tuple): | ||
axis = self.getAxis(i) | ||
if len(item)==2: # (start,end) | ||
indexInterval = axis.mapIntervalExt(item) | ||
|
@@ -1314,13 +1311,7 @@ def reg_specs2slices(self, initspeclist,force=None): | |
if indexInterval is None: | ||
raise CDMSError, OutOfRange + str(item) | ||
newitem = slice(indexInterval[0],indexInterval[1],indexInterval[2]) | ||
elif isinstance(item, numpy.floating) or \ | ||
isinstance(item, types.FloatType) or \ | ||
isinstance(item, numpy.integer) or \ | ||
isinstance(item, types.IntType) or \ | ||
isinstance(item, types.LongType) or \ | ||
isinstance(item, types.StringType) or \ | ||
type(item) in CdtimeTypes: | ||
elif isinstance(item, (numpy.floating, float, numpy.integer, int, long, basestring)) or type(item) in CdtimeTypes: | ||
axis = self.getAxis(i) | ||
# | ||
# default is 'ccn' in axis.mapIntervalExt | ||
|
@@ -1397,10 +1388,10 @@ def getGridIndices(self): | |
# numpy.ma overrides | ||
|
||
def __getitem__(self, key): | ||
if type(key) is types.TupleType: | ||
if isinstance(key, tuple): | ||
speclist = self._process_specs(key, {}) | ||
else: | ||
if isinstance(key, types.IntType) and key>=len(self): | ||
if isinstance(key, int) and key>=len(self): | ||
raise IndexError, "Index too large: %d"%key | ||
speclist = self._process_specs([key], {}) | ||
|
||
|
@@ -1509,7 +1500,7 @@ def orderparse (order): | |
remaining axes. | ||
(name) meaning an axis whose id is name | ||
""" | ||
if not isinstance(order, types.StringType): | ||
if not isinstance(order, basestring): | ||
raise CDMSError, 'order arguments must be strings.' | ||
pos = 0 | ||
result=[] | ||
|
@@ -1523,8 +1514,8 @@ def orderparse (order): | |
elif r == '...': | ||
r = Ellipsis | ||
elif len(r) == 1: | ||
if r in string.digits: | ||
r = string.atoi(r) | ||
if r in '0123456789': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use r.isdigit() |
||
r = int(r) | ||
result.append(r) | ||
pos = m.end(0) | ||
|
||
|
@@ -1544,9 +1535,9 @@ def order2index (axes, order): | |
remaining axes. | ||
(name) meaning an axis whose id is name | ||
""" | ||
if isinstance(order, types.StringType): | ||
if isinstance(order, basestring): | ||
result = orderparse(order) | ||
elif isinstance(order, types.ListType): | ||
elif isinstance(order, list): | ||
result = order | ||
else: | ||
raise CDMSError, 'order2index, order specified of bad type:' + str(type(order)) | ||
|
@@ -1557,7 +1548,7 @@ def order2index (axes, order): | |
pos = 0 | ||
while j < len(result): | ||
item = result[j] | ||
if isinstance(item, types.StringType): | ||
if isinstance(item, basestring): | ||
if item == 't': | ||
spec = 'time' | ||
elif item == 'x': | ||
|
@@ -1581,7 +1572,7 @@ def order2index (axes, order): | |
break | ||
else: | ||
raise CDMSError, 'No axis matching order spec %s' %str(item) | ||
elif isinstance(item, types.IntType): | ||
elif isinstance(item, int): | ||
if item in permutation: | ||
raise CDMSError, 'Duplicate item in order %s' % order | ||
if item >= n: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isinstance is misspeled here. Would flake8 catch this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep i need to run flake8 on this.