Skip to content

Instantly share code, notes, and snippets.

@metasim
Created July 31, 2019 15:32
Show Gist options
  • Select an option

  • Save metasim/6c487e5cc9f85d3821ef738fa445aa0e to your computer and use it in GitHub Desktop.

Select an option

Save metasim/6c487e5cc9f85d3821ef738fa445aa0e to your computer and use it in GitHub Desktop.
def set_dims(parts):
assert(len(parts) is 2, "Expected dimensions specification to have exactly two components")
assert(all([isinstance(p, int) and p > 0 for p in parts]),
"Expected all components in dimensions to be positive integers")
options.update({
"imageWidth": parts[0],
"imageHeight": parts[1]
})
if raster_dimensions is not None:
if isinstance(raster_dimensions, tuple):
set_dims(raster_dimensions)
elif isinstance(raster_dimensions, str):
p = list(map(lambda s: int(s), raster_dimensions.split(',')))
set_dims(p)
@metasim
Copy link
Author

metasim commented Jul 31, 2019

At line 2 I would probably prefer an equality test rather than is. Not exactly sure why.

I honestly don't know the difference.

@vpipkt
Copy link

vpipkt commented Aug 2, 2019

IDK but maybe this seems correct

is will return True if two variables point to the same object, == if the objects referred to by the variables are equal.

And as I recall there is some interesting things like if i say a=2 and b=2 then a is b is true because both objects will point ot the same underlying object. I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment