pixelogik / NearPy

Python framework for fast (approximated) nearest neighbour search in large, high-dimensional data sets using different locality-sensitive hashes.
MIT License
759 stars 152 forks source link

Removed mutable default arguments #28

Closed ogh closed 9 years ago

ogh commented 9 years ago

The default arguments of the Engine __init__ function were mutable. That means, they are shared across all instances of Engine. See here for details on this property of python.

I noticed this when creating multiple instances of Engine. Since I didn't specify any argument for storage, it defaulted to MemoryStorage(). Because MemoryStorage() is specified in the function arguments there was only one storage instance shared by all the engines that I created. Every time I queried nearest neighbors, they were retrieved from all the datasets in all my engines, the datasets were not separated as I intended.

I added a quick fix following a style that is recommended by most articles about the mutual default argument matter.

pixelogik commented 9 years ago

Hi there,

thanks for pointing that out and doing the pull request! I will merge it in soon.

Cheers Ole

ogh commented 9 years ago

Great, thanks!