sightmachine/SimpleCV

API change: Image.find* functions should return an empty list when no results are found

Closed this issue · 2 comments

As of right now, all methods of the Image class that "find" certain features return None when no such feature has been found, leading to a lot of type checking boilerplate. For example:

blobs = img.findBlobs()
if blobs is not None:
    for blob in blobs:
        blob.show()

This is awkward, unpythonic, and frankly a huge pain to work with. The API could be much improved by having methods such as Image.findBlobs return an empty list when no features are found. Consider this:

for blob in img.findBlobs():
    blob.show()

I would be happy to help rewrite the code, but since this would break backwards compatibility, I thought I would bring up the issue before making a pull request.

This was the plan to do explicitly in the rework of SimpleCV (2.0). There will be a complete rewrite as there are a lot of bad architecture decisions made with 1.x that we want to fix in 2.0 (which is expected in 2014):

https://github.com/sightmachine/SimpleCV/wiki/SimpleCV-2.0-Notes
https://github.com/sightmachine/SimpleCV/wiki/SimpleCV-2.0-Planning

Great news, thanks!

Sent from my iPhone

On Nov 26, 2013, at 4:06 PM, Anthony Oliver notifications@github.com wrote:

Closed #599.


Reply to this email directly or view it on GitHub.