Giter Site home page Giter Site logo

TypeError about anycluster HOT 7 CLOSED

lmorroni avatar lmorroni commented on July 16, 2024
TypeError

from anycluster.

Comments (7)

lmorroni avatar lmorroni commented on July 16, 2024

I may have fixed it although I'm not entirely sure it's the best approach. It seems like clusterer.py is trying to pass back a set for json serialization. I had to change two lines in compareWithCache.

Line 448:
new_clustercells = list(clustercells)-old_cells
Line 453:
clustered_cells = list(clustercells)

It appears that the proper json is now being returned. I'm interested in hearing your opinion on this solution.
Larry

from anycluster.

biodiv avatar biodiv commented on July 16, 2024

Hi Larry,
thank you for your report!
python cannot subtract lists, so we need to use sets. You might get errors when panning the map.
Have you tried to change the following line in views.py :

Line 26:
list(markers)

I think Django changed a few things in geodjango since 1.4. Although at first sight I do not see why 1.6 should be a problem, I will install 1.6 and do tests with your exact setup.
As this might take a few days until I find the time to do it, please try the above first if you get errors when panning.

A further test would be to disable cache when querying: remove the &cache= parameter from the query

If the error goes away, we know it is within compareWithCache.

By the way: I found out out that, although unsurprisingly, an SSD significantly improves the cluster speed.

from anycluster.

lmorroni avatar lmorroni commented on July 16, 2024

biodiv,
Thanks for getting back to me. I am a novice in Python and I am still
learning it so bear with me. I have a programming background so I
understand the principals but I still don't have a firm grasp on syntax
and behavior. That being said, I did try to set things back in
clusterer.py to the way they were and then tried to json.dump
list(markers) instead of just markers but I received the same error.

I am using PyCharm to develop/debug and my tracing abilities are not
great. What I did notice though is that it never makes it to Line 26 in
views.py. It appears that things are crashing out in clusterer.py. I
tested this by simply placing a 1 on line 26 instead of markers. I
still get the same error. If I comment out the two previous calls to:
clustercells, filters =
clusterer.getClusterParameters(request,int(zoom),int(gridSize))

 markers = clusterer.kmeansCluster(clustercells,filters,int(zoom), 

int(gridSize))

...then it runs and returns a 1.

Larry

On 2/5/14, 5:06 AM, biodiv wrote:

Hi Larry,
thank you for your report!
python cannot subtract lists, so we need to use sets. You might get
errors when panning the map.
Have you tried to change the following line in views.py :

Line 26:
list(markers)

I think Django changed a few things in geodjango since 1.4. Although
at first sight I do not see why 1.6 should be a problem, I will
install 1.6 and do tests with your exact setup.
As this might take a few days until I find the time to do it, please
try the above first if you get errors when panning.

A further test would be to disable cache when querying: remove the
&cache= parameter from the query

If the error goes away, we know it is within compareWithCache.

By the way: I found out out that, although unsurprisingly, an SSD
significantly improves the cluster speed.


Reply to this email directly or view it on GitHub
#5 (comment).

from anycluster.

biodiv avatar biodiv commented on July 16, 2024

no problem. I can reproduce your error using django 1.6.1. It has something to do with the way django stores sessions since 1.6. We cant use sets in the session. Furthermore I found another error when detecting the SRID of the database. Hopefully I will be able to provide an update to support django 1.6 very soon.

from anycluster.

biodiv avatar biodiv commented on July 16, 2024

Please try the new version and let me know if it works for you.
The cache is now stored as list:

clustercache['cellIDs'] = list(clustered_cells)

and converted back to a set after retrieving

old_cells = set(clustercache['cellIDs'])

Your first approach was actually very close...

from anycluster.

lmorroni avatar lmorroni commented on July 16, 2024

Hi,
I updated clusterer.py and was getting an error because srid_sb was not
being set. I am using 4326. I tried it with and without adding the new
setting you mentioned in your readme. I made a change and it worked.
Here's what I did on line 876:

     if len(list(srid_db_objs)) > 0:
       srid_db = srid_db_objs[0].st_srid
     else:
         try:
             srid_db = settings.ANYCLUSTER_COORDINATES_COLUMN_SRID
         except:
             srid_db = 4326

Larry

On 2/5/14, 12:15 PM, biodiv wrote:

Please try the new version and let me know if it worked for you


Reply to this email directly or view it on GitHub
#5 (comment).

from anycluster.

biodiv avatar biodiv commented on July 16, 2024

Thanks a lot for the fix :)

btw you can remove the

&time=%3E%3D_2012-02-26&is_doubt=%3D_FALSE

from your javascript query. I should update the javascript soon, too - it has some smaller parts in it that are specific to the original project it was made for.

from anycluster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.