Skip to content

Commit

Permalink
Merge pull request #150 from brian-rose/fix-is
Browse files Browse the repository at this point in the history
Replace is with == for all literal comparisons
  • Loading branch information
brian-rose committed May 13, 2021
2 parents 3ea369a + 69b8345 commit 044b8f9
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion climlab/convection/akmaev_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def convective_adjustment_direct(p, T, c, lapserate=6.5):
def Akmaev_adjustment_multidim(theta, q, beta, n_k, theta_k, s_k, t_k):
num_lev = theta.shape[-1] # number of vertical levels
otherdims = theta.shape[:-1] # everything except last dimension, which we assume is vertical
if otherdims is not ():
if otherdims != ():
othersize = np.prod(otherdims)
theta_reshape = theta.reshape((othersize, num_lev))
q_reshape = q.reshape((othersize, num_lev))
Expand Down
2 changes: 1 addition & 1 deletion climlab/convection/emanuel_convection.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def __init__(self,
# Define inputs and diagnostics
surface_shape = self.state['Tatm'][...,0].shape
# Hack to handle single column and multicolumn
if surface_shape is ():
if surface_shape == ():
init = np.atleast_1d(np.zeros(surface_shape))
self.multidim=False
else:
Expand Down
4 changes: 2 additions & 2 deletions climlab/domain/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ def __getitem__(self, indx):
# But for now we're just going to "try" to slice to avoid
# some failures
for key, value in self.__dict__.items():
if key is 'heat_capacity':
if key == 'heat_capacity':
try:
dout.heat_capacity = self.heat_capacity[indx]
except:
dout.heat_capacity = self.heat_capacity
elif key is 'shape':
elif key == 'shape':
try:
dout.shape = self.heat_capacity[indx].shape
except:
Expand Down
2 changes: 1 addition & 1 deletion climlab/domain/initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def column_state(num_lev=30,
if lev is not None:
num_lev = np.array(lev).size

if num_lat is 1:
if num_lat == 1:
sfc, atm = domain.single_column(water_depth=water_depth,
num_lev=num_lev,
lev=lev)
Expand Down
2 changes: 1 addition & 1 deletion climlab/process/time_dependent_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def compute(self):
self_tend = self._compute()
# Adjustment processes _compute method returns absolute adjustment
# Needs to be converted to rate of change
if self.time_type is 'adjustment':
if self.time_type == 'adjustment':
for varname, adj in self_tend.items():
self_tend[varname] /= self.timestep
for varname, tend in self_tend.items():
Expand Down
4 changes: 2 additions & 2 deletions climlab/radiation/greygas.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def absorptivity(self, value):
except:
axis = self.Tatm.domain.axis_index['lev']
# if a single scalar is given, broadcast that to all levels
if len(np.shape(np.array(value))) is 0:
if len(np.shape(np.array(value))) == 0:
value = np.ones_like(self.Tatm) * value
elif value.shape != self.Tatm.shape:
raise ValueError('absorptivity must be a Field, a scalar, or match atm grid dimensions')
Expand Down Expand Up @@ -111,7 +111,7 @@ def reflectivity(self, value):
except:
axis = self.Tatm.domain.axis_index['lev']
# if a single scalar is given, broadcast that to all levels
if len(np.shape(np.array(value))) is 0:
if len(np.shape(np.array(value))) == 0:
value = np.ones_like(self.Tatm) * value
elif value.shape != self.Tatm.shape:
raise ValueError('reflectivity must be a Field, a scalar, or match atm grid dimensions')
Expand Down
2 changes: 1 addition & 1 deletion climlab/radiation/nband.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _compute_optical_path(self):
self.absorption_cross_section['CO2'])
for gas, vmr in self.absorber_vmr.items():
# convert to mass of absorber per unit total mass
if gas is 'H2O': # H2O is stored as specific humidity, not VMR
if gas == 'H2O': # H2O is stored as specific humidity, not VMR
q = vmr
else:
q = vmr / (1.+vmr)
Expand Down

0 comments on commit 044b8f9

Please sign in to comment.