Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The plugin causes a segfault #9

Open
pcav opened this issue Oct 21, 2015 · 6 comments
Open

The plugin causes a segfault #9

pcav opened this issue Oct 21, 2015 · 6 comments

Comments

@pcav
Copy link

pcav commented Oct 21, 2015

Both when writing to memory layer and to a shapefile.
It does not happen on all PCs on a course here, but we had it both on Win and on Debian.

@jdugge
Copy link
Owner

jdugge commented Oct 21, 2015

Could you provide a shapefile and the parameters used to trigger the segfault?

@jdugge
Copy link
Owner

jdugge commented Oct 21, 2015

Maybe this is caused by the iterative method not converging. Could you try replacing the secant method in bufferbypercentage.py with the following:

def secant(func, oldx, x, *args, **kwargs):
    """Find the root of a function"""
    TOL = kwargs.pop('TOL', 1e-6)
    oldf, f = func(oldx, *args), func(x, *args)
    iterations = 0
    if (abs(f) > abs(oldf)):
        oldx, x = x, oldx
        oldf, f = f, oldf
    while iterations < 100:
        dx = f * (x - oldx) / float(f - oldf)
        if abs(dx) < TOL * (1 + abs(x)):
            return x - dx
        oldx, x = x, x - dx
        oldf, f = f, func(x, *args)
        iterations += 1
    print "Maximum number of iterations reached, no convergence."
    return x

@pcav
Copy link
Author

pcav commented Oct 21, 2015

sorry, no zip upload here on GH. I can send it by email if you wish.

@pcav
Copy link
Author

pcav commented Oct 21, 2015

Sorry, I'm on a course now, very limited time to do anything. We'll be happy of testing a new version though.
Thanks.

@jdugge
Copy link
Owner

jdugge commented Oct 22, 2015

I've created a new branch that catches if there's an endless loop and tells the user which feature caused the problem. Could you download the directory as a .zip and put that in the ~/.qgis2/.python/plugins directory (you'll have to rename the folder from BufferByPercentage-limit_iterations to BufferByPercentage) and see if the segfault goes away?

Thanks for your help in this!

@pcav
Copy link
Author

pcav commented Oct 23, 2015

Sorry, 0 time available in this period - just overcommitted.
Thanks for looking into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants