[SciPy-User] fit with 3 parameters ok, fit with 4 is going wrong!

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] fit with 3 parameters ok, fit with 4 is going wrong!

federico vaggi-2
What's happening most likely is that the LM algorithm is suggesting values of d which cause an overflow.  Can you try editing your function to print a message if your expression starts to exceed: 

sys.maxsize

If this is what's happening, try using:


Which is a nice wrapper with a much better UI (and some neat features) around the same LM algorithm, which gives you the option of setting limits on the parameters.

Second point - you are minimizing a function for which you have a symbolic expression.  Why not write out an explicit function for the derivative?  It will be much faster than calculating the derivative numerically with finite element approaches.


On Sun, Feb 2, 2014 at 7:00 PM, <[hidden email]> wrote:
Send SciPy-User mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.scipy.org/mailman/listinfo/scipy-user
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of SciPy-User digest..."


Today's Topics:

   1. AttributeError: 'numpy.float64' object has no     attribute
      '_mask' (Gabriele Brambilla)
   2. fit with 3 parameters ok, fit with 4 is going wrong!
      (Gabriele Brambilla)


----------------------------------------------------------------------

Message: 1
Date: Sat, 1 Feb 2014 22:12:46 -0500
From: Gabriele Brambilla <[hidden email]>
Subject: [SciPy-User] AttributeError: 'numpy.float64' object has no
        attribute '_mask'
To: SciPy Users List <[hidden email]>
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Hi,
i'm trying to do a fit with this code:

 def funky(xo, a, b, c, d):
                return a*((xo)**((-1)*b))*(np.exp(((-1)*xo/c))**d)

        guess = [A, gamma, Ecut, b]



        params, params_covariance = optimize.curve_fit(funky, x, y,
guess)#, errorvector)


        yee = funky(x, params[0], params[1], params[2], params[3])


        fig = plt.figure()

        axes = fig.add_subplot(111)

        im = axes.plot(x, y)#errorbar(x, y, errorvector, zeri)

        im = axes.plot(x, yee)
        axes.set_yscale('log')
        axes.set_xscale('log')
        fig.canvas.draw()

        plt.show()


and I've found also this:
http://mail.scipy.org/pipermail/numpy-discussion/2013-September/067593.html

what could I do?

thanks

Gabriele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20140201/7000cbe6/attachment-0001.html

------------------------------

Message: 2
Date: Sun, 2 Feb 2014 12:38:31 -0500
From: Gabriele Brambilla <[hidden email]>
Subject: [SciPy-User] fit with 3 parameters ok, fit with 4 is going
        wrong!
To: SciPy Users List <[hidden email]>
Message-ID:
        <CABmgkic9P74b=[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

I'm trying to do a fit with scipy optimize.curve_fit

when I define this function omitting the variable d the fit works well:

a*((x)**((-1)*b))*(np.exp(((-1)*x/c)**d))

when I include the d (not only in this line obviously) I get this error:

my1curvefit.py:14: RuntimeWarning: invalid value encountered in power
  return a*((x)**((-1)*b))*(np.exp(((-1)*x/c)**d))
Traceback (most recent call last):
  File "my1curvefit.py", line 37, in <module>
    params, params_covariance = optimize.curve_fit(funky, xa, ye, guess, e)
  File
"C:\Users\Gabriele\Anaconda1\lib\site-packages\scipy\optimize\minpack.py",
line 538, in curve_fit
    raise RuntimeError(msg)
RuntimeError: Optimal parameters not found: Number of calls to function has
reached maxfev = 1000.

could you help me to understand what's happening?and how could I do this
fit?

thanks

Gabriele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20140202/e5530ed3/attachment-0001.html

------------------------------

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user


End of SciPy-User Digest, Vol 126, Issue 2
******************************************


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Gabriele Brambilla
Ok, excuse me but I have not understand some things:

2014-02-02 federico vaggi <[hidden email]>:
What's happening most likely is that the LM algorithm is suggesting values of d which cause an overflow.  Can you try editing your function to print a message if your expression starts to exceed: 


what does it mean that my expression starts to exceed? how could I check it? 
 
sys.maxsize

If this is what's happening, try using:


Which is a nice wrapper with a much better UI (and some neat features) around the same LM algorithm, which gives you the option of setting limits on the parameters.
 
Second point - you are minimizing a function for which you have a symbolic expression.  Why not write out an explicit function for the derivative?  It will be much faster than calculating the derivative numerically with finite element approaches.

ok but how could I use this in the function curve_fit? could you send me an example?

thanks

Gabriele
 

On Sun, Feb 2, 2014 at 7:00 PM, <[hidden email]> wrote:
Send SciPy-User mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.scipy.org/mailman/listinfo/scipy-user
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of SciPy-User digest..."


Today's Topics:

   1. AttributeError: 'numpy.float64' object has no     attribute
      '_mask' (Gabriele Brambilla)
   2. fit with 3 parameters ok, fit with 4 is going wrong!
      (Gabriele Brambilla)


----------------------------------------------------------------------

Message: 1
Date: Sat, 1 Feb 2014 22:12:46 -0500
From: Gabriele Brambilla <[hidden email]>
Subject: [SciPy-User] AttributeError: 'numpy.float64' object has no
        attribute '_mask'
To: SciPy Users List <[hidden email]>
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Hi,
i'm trying to do a fit with this code:

 def funky(xo, a, b, c, d):
                return a*((xo)**((-1)*b))*(np.exp(((-1)*xo/c))**d)

        guess = [A, gamma, Ecut, b]



        params, params_covariance = optimize.curve_fit(funky, x, y,
guess)#, errorvector)


        yee = funky(x, params[0], params[1], params[2], params[3])


        fig = plt.figure()

        axes = fig.add_subplot(111)

        im = axes.plot(x, y)#errorbar(x, y, errorvector, zeri)

        im = axes.plot(x, yee)
        axes.set_yscale('log')
        axes.set_xscale('log')
        fig.canvas.draw()

        plt.show()


and I've found also this:
http://mail.scipy.org/pipermail/numpy-discussion/2013-September/067593.html

what could I do?

thanks

Gabriele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20140201/7000cbe6/attachment-0001.html

------------------------------

Message: 2
Date: Sun, 2 Feb 2014 12:38:31 -0500
From: Gabriele Brambilla <[hidden email]>
Subject: [SciPy-User] fit with 3 parameters ok, fit with 4 is going
        wrong!
To: SciPy Users List <[hidden email]>
Message-ID:
        <CABmgkic9P74b=[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

I'm trying to do a fit with scipy optimize.curve_fit

when I define this function omitting the variable d the fit works well:

a*((x)**((-1)*b))*(np.exp(((-1)*x/c)**d))

when I include the d (not only in this line obviously) I get this error:

my1curvefit.py:14: RuntimeWarning: invalid value encountered in power
  return a*((x)**((-1)*b))*(np.exp(((-1)*x/c)**d))
Traceback (most recent call last):
  File "my1curvefit.py", line 37, in <module>
    params, params_covariance = optimize.curve_fit(funky, xa, ye, guess, e)
  File
"C:\Users\Gabriele\Anaconda1\lib\site-packages\scipy\optimize\minpack.py",
line 538, in curve_fit
    raise RuntimeError(msg)
RuntimeError: Optimal parameters not found: Number of calls to function has
reached maxfev = 1000.

could you help me to understand what's happening?and how could I do this
fit?

thanks

Gabriele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20140202/e5530ed3/attachment-0001.html

------------------------------

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user


End of SciPy-User Digest, Vol 126, Issue 2
******************************************


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Matt Newville



On Thu, Feb 6, 2014 at 9:43 AM, Gabriele Brambilla <[hidden email]> wrote:
Ok, excuse me but I have not understand some things:

2014-02-02 federico vaggi <[hidden email]>:
What's happening most likely is that the LM algorithm is suggesting values of d which cause an overflow.  Can you try editing your function to print a message if your expression starts to exceed: 


what does it mean that my expression starts to exceed? how could I check it? 

I think the recommendation was to print out parameter values (especially for your "c" and "d" parameters which could easily send your function to under/overflow values, and so make it very difficult for the fitting algorithm to figure out how changing the value of the parameter changes the result).
 
sys.maxsize

If this is what's happening, try using:


Which is a nice wrapper with a much better UI (and some neat features) around the same LM algorithm, which gives you the option of setting limits on the parameters.
 
Second point - you are minimizing a function for which you have a symbolic expression.  Why not write out an explicit function for the derivative?  It will be much faster than calculating the derivative numerically with finite element approaches.

ok but how could I use this in the function curve_fit? could you send me an example?

It may not be completely clear from the curve_fit() documentation, but the **kw parameters are passed to leastsq().  So, if you write a function to provide the Jacobian, you can pass function this to curve_fit() with the "Dfun" parameter.
 
Since curve_fit() is a simplified wrapper around leastsq(), once you start doing anything non-simple, you may be better off just using leastsq().  Among other conveniences, the lmfit package add the ability to fix and/or set bounds on the parameters in the model without having to rewrite the objective function, which might be helpful for your problem.

--
--Matt Newville

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Daπid
On 2 February 2014 21:11, federico vaggi <[hidden email]> wrote:
 def funky(xo, a, b, c, d):
                return a*((xo)**((-1)*b))*(np.exp(((-1)*xo/c))**d)

That function is messy! Here is a clean-up:

a * x0**-b * np.exp(-x0 * d / c)

You may notice that d and c are degenerate, so you could just use as a parameter the ratio d/c and remove one parameter.


On 6 February 2014 17:13, Matt Newville <[hidden email]> wrote:
It may not be completely clear from the curve_fit() documentation, but the **kw parameters are passed to leastsq().  So, if you write a function to provide the Jacobian, you can pass function this to curve_fit() with the "Dfun" parameter.
 
Since curve_fit() is a simplified wrapper around leastsq(), once you start doing anything non-simple, you may be better off just using leastsq().  Among other conveniences, the lmfit package add the ability to fix and/or set bounds on the parameters in the model without having to rewrite the objective function, which might be helpful for your problem.

If Scipy is having a hard time and you can afford the dependency, I would consider using iminuit with probfit. It is built on top of CERN's Minuit, that has very powerful minimization algorithms, robust in many dimensions (many > 10). And in my particular case, in its pure python mode is faster than Scipy, and gained a lot of speed when providing a Cython function.


/David.

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Matt Newville



On Thu, Feb 6, 2014 at 10:45 AM, Daπid <[hidden email]> wrote:
On 2 February 2014 21:11, federico vaggi <[hidden email]> wrote:
 def funky(xo, a, b, c, d):
                return a*((xo)**((-1)*b))*(np.exp(((-1)*xo/c))**d)

That function is messy! Here is a clean-up:

a * x0**-b * np.exp(-x0 * d / c)

You may notice that d and c are degenerate, so you could just use as a parameter the ratio d/c and remove one parameter.

Ah.. good catch!  I didn't even bother parsing all the extra parens.  Readability definitely counts!   Gabriele, the real answer is that your function only has 3 unique variables.
 

On 6 February 2014 17:13, Matt Newville <[hidden email]> wrote:
It may not be completely clear from the curve_fit() documentation, but the **kw parameters are passed to leastsq().  So, if you write a function to provide the Jacobian, you can pass function this to curve_fit() with the "Dfun" parameter.
 
Since curve_fit() is a simplified wrapper around leastsq(), once you start doing anything non-simple, you may be better off just using leastsq().  Among other conveniences, the lmfit package add the ability to fix and/or set bounds on the parameters in the model without having to rewrite the objective function, which might be helpful for your problem.

If Scipy is having a hard time and you can afford the dependency, I would consider using iminuit with probfit. It is built on top of CERN's Minuit, that has very powerful minimization algorithms, robust in many dimensions (many > 10). And in my particular case, in its pure python mode is faster than Scipy, and gained a lot of speed when providing a Cython function
 
I'm interested, but slightly confused.   Iminuit / probfit is described as BSD, but depends on (and includes?) Minuit - isn't that GPL?

We've been trying (but slowly) to add some simpler modelling functionality to lmfit, but it looks like probfit has many more functions available. But providing higher level modeling functions seems somewhat separate to me than the details of the underlying fitting algorithm.    Am I missing some important aspect of iminuit / probfit?  Can you elaborate on the speed comparison?

--
--Matt Newville

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Gabriele Brambilla
In reply to this post by Daπid



2014-02-06 Daπid <[hidden email]>:
On 2 February 2014 21:11, federico vaggi <[hidden email]> wrote:
 def funky(xo, a, b, c, d):
                return a*((xo)**((-1)*b))*(np.exp(((-1)*xo/c))**d)

That function is messy! Here is a clean-up:

a * x0**-b * np.exp(-x0 * d / c)

You may notice that d and c are degenerate, so you could just use as a parameter the ratio d/c and remove one parameter.


No, written in this way it is wrong. In the exponential I need: (-x0/c)**d ; NOT (-x0/c)*d. Maybe I'm writing it in the wrong way in Python...I attach an image with the function I want to write. 
 

On 6 February 2014 17:13, Matt Newville <[hidden email]> wrote:
It may not be completely clear from the curve_fit() documentation, but the **kw parameters are passed to leastsq().  So, if you write a function to provide the Jacobian, you can pass function this to curve_fit() with the "Dfun" parameter.
 
Since curve_fit() is a simplified wrapper around leastsq(), once you start doing anything non-simple, you may be better off just using leastsq().  Among other conveniences, the lmfit package add the ability to fix and/or set bounds on the parameters in the model without having to rewrite the objective function, which might be helpful for your problem.

If Scipy is having a hard time and you can afford the dependency, I would consider using iminuit with probfit. It is built on top of CERN's Minuit, that has very powerful minimization algorithms, robust in many dimensions (many > 10). And in my particular case, in its pure python mode is faster than Scipy, and gained a lot of speed when providing a Cython function.


/David.

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user

function.jpg (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Daπid
On 6 February 2014 20:00, Gabriele Brambilla <[hidden email]> wrote:
No, written in this way it is wrong. In the exponential I need: (-x0/c)**d ; NOT (-x0/c)*d. Maybe I'm writing it in the wrong way in Python...I attach an image with the function I want to write. 

Then, your function has a misplaced parenthesis. Usually, IDEs can tell you which parenthesis closes which one, so you can see if you are writing what you want. (See attached a couple of examples with vi).

See if this fixes your original problem:

a * x0**-b * np.exp(-(x0 / c)**d)

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user

parenthesis.png (3K) Download Attachment
parenthesisII.png (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Eric Hermes


On Thursday, February 06, 2014 2:10:16 PM, Daπid wrote:

> On 6 February 2014 20:00, Gabriele Brambilla
> <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     No, written in this way it is wrong. In the exponential I need:
>     (-x0/c)**d ; NOT (-x0/c)*d. Maybe I'm writing it in the wrong way
>     in Python...I attach an image with the function I want to write.
>
>
> Then, your function has a misplaced parenthesis. Usually, IDEs can
> tell you which parenthesis closes which one, so you can see if you are
> writing what you want. (See attached a couple of examples with vi).
>
> See if this fixes your original problem:
>
> a * x0**-b * np.exp(-(x0 / c)**d)

This is also not the same as Gabriele's original expression.  Observe
that (-x0/c)**d != -(x0/c)**d.  The former case is the original
expression, which is complex when x0/c is positive and d is
non-integer.  This is the root cause of Gabriele's issue.

Eric

>
>
> _______________________________________________
> SciPy-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/scipy-user

--
Eric Hermes
J.R. Schmidt Group
Chemistry Department
University of Wisconsin - Madison
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Daπid
In reply to this post by Matt Newville
On 6 February 2014 18:55, Matt Newville <[hidden email]> wrote:
I'm interested, but slightly confused.   Iminuit / probfit is described as BSD, but depends on (and includes?) Minuit - isn't that GPL?

The license says iminuit is MIT, but Minuit is GPLv2. So, the Python part, that wraps the C code is MIT. One could deattach it and use a different algorithm, or a Minuit implementation under another license.

Probfit provides convenience functions to do regressions and plotting. For example, chi2 = Chi2Regression(fun, x, y) creates a callable object that calculates the chi2 for the function and the defined data, but has methods like chi2.draw to plot it, and it can obtain the plotting parameters from an iminuit object (the dictionary Minuit.values), but could work perfectly well with some other object presenting the same interface.

I am currently using it to fit a lorentzian curve to a noisy profile. I have fairly nice approximations to the actual values (looking at the maximum, for example), and speed is critical, so I tried a few approaches and iminuit + probfit were the fastest, by 20 to 50%.


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user

figure_1.png (79K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Matt Newville
Hi David,


On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
On 6 February 2014 18:55, Matt Newville <[hidden email]> wrote:
I'm interested, but slightly confused.   Iminuit / probfit is described as BSD, but depends on (and includes?) Minuit - isn't that GPL?

The license says iminuit is MIT, but Minuit is GPLv2. So, the Python part, that wraps the C code is MIT.

The way I understand it, code that wraps GPLv2 code is required to use GPL, and so propagate the license to all code using it. That would mean that code that uses Minuit cannot be something other than GPL.   Perhaps I am not understanding something.
 
One could deattach it and use a different algorithm, or a Minuit implementation under another license.

 Does such an implementation exist?

Probfit provides convenience functions to do regressions and plotting. For example, chi2 = Chi2Regression(fun, x, y) creates a callable object that calculates the chi2 for the function and the defined data, but has methods like chi2.draw to plot it, and it can obtain the plotting parameters from an iminuit object (the dictionary Minuit.values), but could work perfectly well with some other object presenting the same interface.

I am currently using it to fit a lorentzian curve to a noisy profile. I have fairly nice approximations to the actual values (looking at the maximum, for example), and speed is critical, so I tried a few approaches and iminuit + probfit were the fastest, by 20 to 50%.

OK.   Code that can quickly and accurately fit lorentzians and other basic curves to noisy 1-d data sets is important to me too. Ultimate speed could depend greatly on initial values and whether analytic derivatives can be used as well as fitting algorithm used.  In lmfit, we've tried to make it easy to switch fitting algorithms without having to change the objective function, but with bounded and possibly constrained parameter values, it's more challenging to use analytic derivatives.

--Matt Newville

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Gabriele Brambilla
In reply to this post by Daπid
Hi guys! now it works (not perfectly but there has been a lot of progress!)
first the expression I wrote was wrong for the reason outlined by Eric Hermes, now I use: -(x0/c)**d.
Second I've tried a way to give to the fit a more precise start point.

thank you all

Gabriele



2014-02-06 Daπid <[hidden email]>:
On 6 February 2014 18:55, Matt Newville <[hidden email]> wrote:
I'm interested, but slightly confused.   Iminuit / probfit is described as BSD, but depends on (and includes?) Minuit - isn't that GPL?

The license says iminuit is MIT, but Minuit is GPLv2. So, the Python part, that wraps the C code is MIT. One could deattach it and use a different algorithm, or a Minuit implementation under another license.

Probfit provides convenience functions to do regressions and plotting. For example, chi2 = Chi2Regression(fun, x, y) creates a callable object that calculates the chi2 for the function and the defined data, but has methods like chi2.draw to plot it, and it can obtain the plotting parameters from an iminuit object (the dictionary Minuit.values), but could work perfectly well with some other object presenting the same interface.

I am currently using it to fit a lorentzian curve to a noisy profile. I have fairly nice approximations to the actual values (looking at the maximum, for example), and speed is critical, so I tried a few approaches and iminuit + probfit were the fastest, by 20 to 50%.


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Daπid
In reply to this post by Matt Newville
On 6 February 2014 22:20, Matt Newville <[hidden email]> wrote:
On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
On 6 February 2014 18:55, Matt Newville <[hidden email]> wrote:
I'm interested, but slightly confused.   Iminuit / probfit is described as BSD, but depends on (and includes?) Minuit - isn't that GPL?

The license says iminuit is MIT, but Minuit is GPLv2. So, the Python part, that wraps the C code is MIT.

The way I understand it, code that wraps GPLv2 code is required to use GPL, and so propagate the license to all code using it. That would mean that code that uses Minuit cannot be something other than GPL.   Perhaps I am not understanding something.

That is a good point.

Reading the licenses, it is completely unclear to my interpretation. GNU says that the whole package has to be compatible with GPL [1], and MIT, as well as the revised BSD [2], are.

Regarding the implementations, to my knowledge, the closest thing is taking it from a ROOT distribution, that is LGPL [3].

I admit I did not include lmfit in my benchmarks, I should give it a try. After a quick look, the interface looks clumsier to write, but much nicer to deal with programatically (ie, fitting an arbitrary number of parameters), and a sure plus is the arbitrarily complex constrains and bounds.


/David.


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Robert Kern-2
In reply to this post by Matt Newville
On Thu, Feb 6, 2014 at 9:20 PM, Matt Newville
<[hidden email]> wrote:

> Hi David,
>
>
> On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
>>
>> On 6 February 2014 18:55, Matt Newville <[hidden email]>
>> wrote:
>>>
>>> I'm interested, but slightly confused.   Iminuit / probfit is described
>>> as BSD, but depends on (and includes?) Minuit - isn't that GPL?
>>
>>
>> The license says iminuit is MIT, but Minuit is GPLv2. So, the Python part,
>> that wraps the C code is MIT.
>
> The way I understand it, code that wraps GPLv2 code is required to use GPL,
> and so propagate the license to all code using it. That would mean that code
> that uses Minuit cannot be something other than GPL.   Perhaps I am not
> understanding something.

GPLed code can be combined with code under a different license as long
as that other license imposes no conditions more restrictive than
those in the GPL. The MIT license is one such license. This is all
perfectly above board.

That said, as a practical matter, for a package that mostly just wraps
the functionality of the internal GPLed component, licensing that
wrapper under the MIT license leads to confusion, as we have seen.

--
Robert Kern
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

hari-2
In reply to this post by Gabriele Brambilla

From: [hidden email]
Sent: ‎2/‎6/‎2014 6:14 PM
To: [hidden email]
Subject: Re: [SciPy-User] fit with 3 parameters ok, fit with 4 is going wrong!

On Thu, Feb 6, 2014 at 9:20 PM, Matt Newville
<[hidden email]> wrote:

> Hi David,
>
>
> On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
>>
>> On 6 February 2014 18:55, Matt Newville <[hidden email]>
>> wrote:
>>>
>>> I'm interested, but slightly confused.   Iminuit / probfit is described
>>> as BSD, but depends on (and includes?) Minuit - isn't that GPL?
>>
>>
>> The license says iminuit is MIT, but Minuit is GPLv2. So, the Python part,
>> that wraps the C code is MIT.
>
> The way I understand it, code that wraps GPLv2 code is required to use GPL,
> and so propagate the license to all code using it. That would mean that code
> that uses Minuit cannot be something other than GPL.   Perhaps I am not
> understanding something.

GPLed code can be combined with code under a different license as long
as that other license imposes no conditions more restrictive than
those in the GPL. The MIT license is one such license. This is all
perfectly above board.

That said, as a practical matter, for a package that mostly just wraps
the functionality of the internal GPLed component, licensing that
wrapper under the MIT license leads to confusion, as we have seen.

--
Robert Kern
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Matt Newville
In reply to this post by Robert Kern-2

 
On Feb 6, 2014 5:14 PM, "Robert Kern" <[hidden email]> wrote:
>
> On Thu, Feb 6, 2014 at 9:20 PM, Matt Newville
> <[hidden email]> wrote:
> > Hi David,
> >
> >
> > On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
> >>
> >> On 6 February 2014 18:55, Matt Newville <[hidden email]>
> >> wrote:
> >>>
> >>> I'm interested, but slightly confused.   Iminuit / probfit is described
> >>> as BSD, but depends on (and includes?) Minuit - isn't that GPL?
> >>
> >>
> >> The license says iminuit is MIT, but Minuit is GPLv2. So, the Python part,
> >> that wraps the C code is MIT.
> >
> > The way I understand it, code that wraps GPLv2 code is required to use GPL,
> > and so propagate the license to all code using it. That would mean that code
> > that uses Minuit cannot be something other than GPL.   Perhaps I am not
> > understanding something.
>
> GPLed code can be combined with code under a different license as long
> as that other license imposes no conditions more restrictive than
> those in the GPL. The MIT license is one such license. This is all
> perfectly above board.

Unless I am mistaken (not without precedent), the resulting mixed code must use the GPL. If library "M" is GPL and package "Mwrapper" calls it, "Mwrapper" must be GPL.   This license propagation is the distinguishing characteristic of GPL, and what differentiates it from LGPL and BSD/MIT.  Do you disagree?

> That said, as a practical matter, for a package that mostly just wraps
> the functionality of the internal GPLed component, licensing that
> wrapper under the MIT license leads to confusion, as we have seen.

I think this does not lead to confusion, but to a license violation.  The GPL is wordy, but not confusing.  If your code wraps (uses, links to, imports, or calls) GPL code, your code must use the GPL.  Not MIT.

Then again, maybe something has changed and Minuit is not actually GPL anymore.  My recollection is that Minuit and Root have been GPL forever.  I've just ignored these tools, but I now see that parts of Root are now LGPL (not the core math routines, including the minimization code, which is based on GSL, and so GPL).   Perhaps Minuit was abandoned by the CERN folks and the license was changed?   I downloaded the Minuit package from http://www.cern.ch/mathlibs/sw/5_34_14/Minuit2/Minuit2-5.34.14.tar.gz  but see no mention of any license anywhere in the source or documentation there -- perhaps I missed it.  Is Minuit being developed separately now?

--Matt


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Robert Kern-2
On Fri, Feb 7, 2014 at 1:03 PM, Matt Newville
<[hidden email]> wrote:

>
> On Feb 6, 2014 5:14 PM, "Robert Kern" <[hidden email]> wrote:
>>
>> On Thu, Feb 6, 2014 at 9:20 PM, Matt Newville
>> <[hidden email]> wrote:
>> > Hi David,
>> >
>> >
>> > On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
>> >>
>> >> On 6 February 2014 18:55, Matt Newville <[hidden email]>
>> >> wrote:
>> >>>
>> >>> I'm interested, but slightly confused.   Iminuit / probfit is
>> >>> described
>> >>> as BSD, but depends on (and includes?) Minuit - isn't that GPL?
>> >>
>> >>
>> >> The license says iminuit is MIT, but Minuit is GPLv2. So, the Python
>> >> part,
>> >> that wraps the C code is MIT.
>> >
>> > The way I understand it, code that wraps GPLv2 code is required to use
>> > GPL,
>> > and so propagate the license to all code using it. That would mean that
>> > code
>> > that uses Minuit cannot be something other than GPL.   Perhaps I am not
>> > understanding something.
>>
>> GPLed code can be combined with code under a different license as long
>> as that other license imposes no conditions more restrictive than
>> those in the GPL. The MIT license is one such license. This is all
>> perfectly above board.
>
> Unless I am mistaken (not without precedent), the resulting mixed code must
> use the GPL. If library "M" is GPL and package "Mwrapper" calls it,
> "Mwrapper" must be GPL.   This license propagation is the distinguishing
> characteristic of GPL, and what differentiates it from LGPL and BSD/MIT.  Do
> you disagree?

Yes. The combined work must be distributed under the GPL license. But
each component can have a non-GPL-but-GPL-compatible license, like the
MIT license. The parts of "Mwrapper" that are not "M" itself do not
need to be GPLed. "Mwrapper+M" is GPLed. "Mwrapper" itself does not
need to be (provided they are licensed compatibly).

This is why I say that the *practical effect* of saying that
"Mwrapper" is BSD-licensed is confusing. Users grab "Mwrapper+M" under
the impression that "Mwrapper"'s license is the only one, when it is
not.

>> That said, as a practical matter, for a package that mostly just wraps
>> the functionality of the internal GPLed component, licensing that
>> wrapper under the MIT license leads to confusion, as we have seen.
>
> I think this does not lead to confusion, but to a license violation.  The
> GPL is wordy, but not confusing.  If your code wraps (uses, links to,
> imports, or calls) GPL code, your code must use the GPL.  Not MIT.

You have misread the GPL. Please consult the FSF's information about
mixing code with GPL-compatible licenses. The propagation applies to
the combined work as a whole, not every single piece of code in the
combined work.

--
Robert Kern
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Matt Newville



On Fri, Feb 7, 2014 at 7:22 AM, Robert Kern <[hidden email]> wrote:
On Fri, Feb 7, 2014 at 1:03 PM, Matt Newville
<[hidden email]> wrote:
>
> On Feb 6, 2014 5:14 PM, "Robert Kern" <[hidden email]> wrote:
>>
>> On Thu, Feb 6, 2014 at 9:20 PM, Matt Newville
>> <[hidden email]> wrote:
>> > Hi David,
>> >
>> >
>> > On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
>> >>
>> >> On 6 February 2014 18:55, Matt Newville <[hidden email]>
>> >> wrote:
>> >>>
>> >>> I'm interested, but slightly confused.   Iminuit / probfit is
>> >>> described
>> >>> as BSD, but depends on (and includes?) Minuit - isn't that GPL?
>> >>
>> >>
>> >> The license says iminuit is MIT, but Minuit is GPLv2. So, the Python
>> >> part,
>> >> that wraps the C code is MIT.
>> >
>> > The way I understand it, code that wraps GPLv2 code is required to use
>> > GPL,
>> > and so propagate the license to all code using it. That would mean that
>> > code
>> > that uses Minuit cannot be something other than GPL.   Perhaps I am not
>> > understanding something.
>>
>> GPLed code can be combined with code under a different license as long
>> as that other license imposes no conditions more restrictive than
>> those in the GPL. The MIT license is one such license. This is all
>> perfectly above board.
>
> Unless I am mistaken (not without precedent), the resulting mixed code must
> use the GPL. If library "M" is GPL and package "Mwrapper" calls it,
> "Mwrapper" must be GPL.   This license propagation is the distinguishing
> characteristic of GPL, and what differentiates it from LGPL and BSD/MIT.  Do
> you disagree?

Yes. The combined work must be distributed under the GPL license. But
each component can have a non-GPL-but-GPL-compatible license, like the
MIT license. The parts of "Mwrapper" that are not "M" itself do not
need to be GPLed. "Mwrapper+M" is GPLed. "Mwrapper" itself does not
need to be (provided they are licensed compatibly).


The parts of Mwrapper that use M must be GPL.
 
This is why I say that the *practical effect* of saying that
"Mwrapper" is BSD-licensed is confusing. Users grab "Mwrapper+M" under
the impression that "Mwrapper"'s license is the only one, when it is
not.

>> That said, as a practical matter, for a package that mostly just wraps
>> the functionality of the internal GPLed component, licensing that
>> wrapper under the MIT license leads to confusion, as we have seen.
>
> I think this does not lead to confusion, but to a license violation.  The
> GPL is wordy, but not confusing.  If your code wraps (uses, links to,
> imports, or calls) GPL code, your code must use the GPL.  Not MIT.

You have misread the GPL. Please consult the FSF's information about
mixing code with GPL-compatible licenses. The propagation applies to
the combined work as a whole, not every single piece of code in the
combined work.

Perhaps this is a bit off-topic, but I believe that I have not misread the GPL. I do agree that it does not apply to every single piece of code in the combined work.  But I believe (and, sorry but I am not convinced by you saying otherwise, without strong evidence) it does apply to every piece of code that **uses** the GPL code, including making library calls.  That is, a wrapper that does
    import gpl_licensed_lib
    gpl_licensed_lib.function()

must use the GPL.  For sure, it can also do
    import bsd_licensed_lib
    import lgpl_licensed_lib

without requiring the code in those other libraries to change to use GPL. Indeed, BSD code can be and is regularly used by GPL code.  But if one is distributing a script or module that imports gpl_licensed_lib (which,effectively links to it), that script or module is required to be GPL.  That script or module is "the combined work as a whole" -- it is what is being distributed for others to use.

The language on compatible licenses from the FSF is discussing what licenses are compatible with GPL in the sense that "it is OK to include BSD licensed code (eg, X11) in GPL code".  It most certainly does not grant permission to distribute code under a BSD license if that code calls a GPL library.  The LGPL does allow that, but not the GPL.

Sorry to be off-topic and slightly ranty, but this is an important (if subtle) distinction.

--Matt


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Robert Kern-2
On Fri, Feb 7, 2014 at 9:42 PM, Matt Newville
<[hidden email]> wrote:

>
> On Fri, Feb 7, 2014 at 7:22 AM, Robert Kern <[hidden email]> wrote:
>>
>> On Fri, Feb 7, 2014 at 1:03 PM, Matt Newville
>> <[hidden email]> wrote:
>> >
>> > On Feb 6, 2014 5:14 PM, "Robert Kern" <[hidden email]> wrote:
>> >>
>> >> On Thu, Feb 6, 2014 at 9:20 PM, Matt Newville
>> >> <[hidden email]> wrote:
>> >> > Hi David,
>> >> >
>> >> >
>> >> > On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
>> >> >>
>> >> >> On 6 February 2014 18:55, Matt Newville <[hidden email]>
>> >> >> wrote:
>> >> >>>
>> >> >>> I'm interested, but slightly confused.   Iminuit / probfit is
>> >> >>> described
>> >> >>> as BSD, but depends on (and includes?) Minuit - isn't that GPL?
>> >> >>
>> >> >>
>> >> >> The license says iminuit is MIT, but Minuit is GPLv2. So, the Python
>> >> >> part,
>> >> >> that wraps the C code is MIT.
>> >> >
>> >> > The way I understand it, code that wraps GPLv2 code is required to
>> >> > use
>> >> > GPL,
>> >> > and so propagate the license to all code using it. That would mean
>> >> > that
>> >> > code
>> >> > that uses Minuit cannot be something other than GPL.   Perhaps I am
>> >> > not
>> >> > understanding something.
>> >>
>> >> GPLed code can be combined with code under a different license as long
>> >> as that other license imposes no conditions more restrictive than
>> >> those in the GPL. The MIT license is one such license. This is all
>> >> perfectly above board.
>> >
>> > Unless I am mistaken (not without precedent), the resulting mixed code
>> > must
>> > use the GPL. If library "M" is GPL and package "Mwrapper" calls it,
>> > "Mwrapper" must be GPL.   This license propagation is the distinguishing
>> > characteristic of GPL, and what differentiates it from LGPL and BSD/MIT.
>> > Do
>> > you disagree?
>>
>> Yes. The combined work must be distributed under the GPL license. But
>> each component can have a non-GPL-but-GPL-compatible license, like the
>> MIT license. The parts of "Mwrapper" that are not "M" itself do not
>> need to be GPLed. "Mwrapper+M" is GPLed. "Mwrapper" itself does not
>> need to be (provided they are licensed compatibly).
>>
>
> The parts of Mwrapper that use M must be GPL.
>
>>
>> This is why I say that the *practical effect* of saying that
>> "Mwrapper" is BSD-licensed is confusing. Users grab "Mwrapper+M" under
>> the impression that "Mwrapper"'s license is the only one, when it is
>> not.
>>
>> >> That said, as a practical matter, for a package that mostly just wraps
>> >> the functionality of the internal GPLed component, licensing that
>> >> wrapper under the MIT license leads to confusion, as we have seen.
>> >
>> > I think this does not lead to confusion, but to a license violation.
>> > The
>> > GPL is wordy, but not confusing.  If your code wraps (uses, links to,
>> > imports, or calls) GPL code, your code must use the GPL.  Not MIT.
>>
>> You have misread the GPL. Please consult the FSF's information about
>> mixing code with GPL-compatible licenses. The propagation applies to
>> the combined work as a whole, not every single piece of code in the
>> combined work.
>
> Perhaps this is a bit off-topic, but I believe that I have not misread the
> GPL. I do agree that it does not apply to every single piece of code in the
> combined work.  But I believe (and, sorry but I am not convinced by you
> saying otherwise, without strong evidence) it does apply to every piece of
> code that **uses** the GPL code, including making library calls.

Section 7 of the GPLv3:

"""
You may place additional permissions on material, added by you to a
covered work, for which you have or can give appropriate copyright
permission.
"""

Applying the BSD license to the portions of the code that you wrote is
providing just such additional permissions.

--
Robert Kern
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Matt Newville
On Sat, Feb 8, 2014 at 5:01 AM, Robert Kern <[hidden email]> wrote:

>
> On Fri, Feb 7, 2014 at 9:42 PM, Matt Newville
> <[hidden email]> wrote:
> >
> > On Fri, Feb 7, 2014 at 7:22 AM, Robert Kern <[hidden email]> wrote:
> >>
> >> On Fri, Feb 7, 2014 at 1:03 PM, Matt Newville
> >> <[hidden email]> wrote:
> >> >
> >> > On Feb 6, 2014 5:14 PM, "Robert Kern" <[hidden email]> wrote:
> >> >>
> >> >> On Thu, Feb 6, 2014 at 9:20 PM, Matt Newville
> >> >> <[hidden email]> wrote:
> >> >> > Hi David,
> >> >> >
> >> >> >
> >> >> > On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
> >> >> >>
> >> >> >> On 6 February 2014 18:55, Matt Newville <[hidden email]>
> >> >> >> wrote:
> >> >> >>>
> >> >> >>> I'm interested, but slightly confused.   Iminuit / probfit is
> >> >> >>> described
> >> >> >>> as BSD, but depends on (and includes?) Minuit - isn't that GPL?
> >> >> >>
> >> >> >>
> >> >> >> The license says iminuit is MIT, but Minuit is GPLv2. So, the Python
> >> >> >> part,
> >> >> >> that wraps the C code is MIT.
> >> >> >
> >> >> > The way I understand it, code that wraps GPLv2 code is required to
> >> >> > use
> >> >> > GPL,
> >> >> > and so propagate the license to all code using it. That would mean
> >> >> > that
> >> >> > code
> >> >> > that uses Minuit cannot be something other than GPL.   Perhaps I am
> >> >> > not
> >> >> > understanding something.
> >> >>
> >> >> GPLed code can be combined with code under a different license as long
> >> >> as that other license imposes no conditions more restrictive than
> >> >> those in the GPL. The MIT license is one such license. This is all
> >> >> perfectly above board.
> >> >
> >> > Unless I am mistaken (not without precedent), the resulting mixed code
> >> > must
> >> > use the GPL. If library "M" is GPL and package "Mwrapper" calls it,
> >> > "Mwrapper" must be GPL.   This license propagation is the distinguishing
> >> > characteristic of GPL, and what differentiates it from LGPL and BSD/MIT.
> >> > Do
> >> > you disagree?
> >>
> >> Yes. The combined work must be distributed under the GPL license. But
> >> each component can have a non-GPL-but-GPL-compatible license, like the
> >> MIT license. The parts of "Mwrapper" that are not "M" itself do not
> >> need to be GPLed. "Mwrapper+M" is GPLed. "Mwrapper" itself does not
> >> need to be (provided they are licensed compatibly).
> >>
> >
> > The parts of Mwrapper that use M must be GPL.
> >
> >>
> >> This is why I say that the *practical effect* of saying that
> >> "Mwrapper" is BSD-licensed is confusing. Users grab "Mwrapper+M" under
> >> the impression that "Mwrapper"'s license is the only one, when it is
> >> not.
> >>
> >> >> That said, as a practical matter, for a package that mostly just wraps
> >> >> the functionality of the internal GPLed component, licensing that
> >> >> wrapper under the MIT license leads to confusion, as we have seen.
> >> >
> >> > I think this does not lead to confusion, but to a license violation.
> >> > The
> >> > GPL is wordy, but not confusing.  If your code wraps (uses, links to,
> >> > imports, or calls) GPL code, your code must use the GPL.  Not MIT.
> >>
> >> You have misread the GPL. Please consult the FSF's information about
> >> mixing code with GPL-compatible licenses. The propagation applies to
> >> the combined work as a whole, not every single piece of code in the
> >> combined work.
> >
> > Perhaps this is a bit off-topic, but I believe that I have not misread the
> > GPL. I do agree that it does not apply to every single piece of code in the
> > combined work.  But I believe (and, sorry but I am not convinced by you
> > saying otherwise, without strong evidence) it does apply to every piece of
> > code that **uses** the GPL code, including making library calls.
>
> Section 7 of the GPLv3:
>
> """
> You may place additional permissions on material, added by you to a
> covered work, for which you have or can give appropriate copyright
> permission.
> """
>
> Applying the BSD license to the portions of the code that you wrote is
> providing just such additional permissions.

I'm pretty sure that would actually violate the GPL.  This is a bit
off-topic, and can be a politically-charged topic.  Truly, I mean no
ill-will, am not looking for an argument, and would be willing to end
the discussion.   My initial reaction on reading this is that I have
been dealing with this issue for well over a decade, and am really
very certain that I understand these licenses, and that your reading
is dangerously mistaken.  But, I've also been doing science and
software long enough to see my own certainty as a red flag -- being
dead certain is the first sign of being dead wrong.  So, as you
suggest, let's look only to texts from the gnu.org sites.  Evidence
and explanations at wikipedia, stackexchange, and the like are often
in plainer language, and uniformly come to a common conclusion: code
that links to a GPL library is derived work, and is required to use
the GPL.  But, let's call that as hearsay, and re-read the writings
from gnu.org with open minds, looking for clarification.

For example, https://www.gnu.org/licenses/gpl-faq.html#GPLStaticVsDynamic

    Q: Does the GPL have different requirements for statically vs
dynamically linked modules with a covered work?
    A: No. Linking a GPL covered work statically or dynamically with
other modules is making a combined work based
    on the GPL covered work. Thus, the terms and conditions of the GNU
General Public License cover the whole combination.

For myself, that is clear enough to effectively end the discussion:
linking to a GPL library makes the work GPL.  A python script that has
"import pygsl", "import pyfftw" or "import PyQ4t" is lining to one of
those GPL libraries, and so is required to use the GPL.

If that is not yet clear enough, consider why the LGPL exists at all.
From the preamble of the LGPL
(http://www.gnu.org/licenses/lgpl-2.1.html), describing this very
subject:

    When a program is linked with a library, whether statically or
using a shared library, the combination of the two is legally speaking
    a combined work, a derivative of the original library. The
ordinary General Public License therefore permits such linking only if
the
    entire combination fits its criteria of freedom. The Lesser
General Public License permits more lax criteria for linking other
code
    with the library.

Here, of course, 'fits its criteria of freedom' means 'uses the GPL'.
The point being made here is to explain that the purpose of the LGPL
is to relax the strict requirement of license propagation that does
exist for the GPL.  You can also read the entirety of
http://www.gnu.org/philosophy/why-not-lgpl.html, which explains
clearly that code that links to a GPL library must use the GPL, and
that the purpose of the LGPL is to relax this requirement.

For completeness,  this point is succinctly if tortuously stated in
the GPL itself, GPLv3  section 5c (similar wording exists in GPLv2
section 2c) reads:

    You may convey a work based on the Program, or the modifications
to produce it from the Program, in the form of source
    code under the terms of section 4, provided that you also meet all
of these conditions:

    c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
    License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

The intent seems clear enough to me.  Do you read this differently?
Earlier, you correctly said "The propagation [of GPL] applies to the
combined work as a whole", as this section states rather clearly.  A
python module or script is a "combined work" or "program" here --
copyrightable source code that can be run and distributed.  By
importing a GPL covered module, one is dynamically linking to it, and
the GPL used by the imported library applies to the importing
program/script/module.   To be sure, any code that might also be used
in said script but which does not directly import/link to a GPL
library does not need to be GPLed.  But the calling script (the
equivalent of main() -- the "combined work") most certainly does.

You quoted from Section 7 of the GPL, but I believe you misunderstood
"for which you have or can give appropriate copyright permission".
You (generally speaking)  do not have copyright permission needed to
be able to change the license under which you use the library that you
are linking to.  And the license for linking to that library requires
that your work use the GPL.

This section  is new to GPLv3.    According to
https://www.gnu.org/licenses/quick-guide-gplv3.html, the license
compatibility language was clarified in GPLv3:

    Clarifying License Compatibility

    If you found some code and wanted to incorporate it into a GPLed
project, GPLv2 said that the license on the other
    code was not allowed to have any restrictions that were not
already in GPLv2. As long as that was the case, we said
    the license was GPL-compatible.

    However, some licenses had requirements that weren't really
restrictive, because they were so easy to comply with. For
    example, some licenses say that they don't give you permission to
use certain trademarks. That's not really an additional
    restriction: if that clause wasn't there, you still wouldn't have
permission to use the trademark. We always said those licenses
    were compatible with GPLv2, too.

    Now, GPLv3 explicitly gives everyone permission to use code that
has requirements like this. These new terms should help
    clear up misunderstandings about which licenses are
GPL-compatible, why that is, and what you can do with GPL-compatible
    code.

Again, the sense of "compatible" here is to say what code is allowed
to be used by GPL code, not what license one may choose for derived
work.  It is not granting one the right to use a BSD license for code
that links to a GPL library.

The propagation of the GPL to calling code is the essence of the GPL,
and the distinguishing characteristic between GPL, LGPL and the
BSD/MIT licenses.   Happily, the scipy pages on license compatibility
are clear about *not* including GPL (or even LGPL) code in scipy.

Trying to come back on topic, I still can't figure out what license
Minuit actually uses.  The iminuit package describes it one place as
LGPL, but I don't see that in Minuit itself.

Sorry this was so long and slightly off topic. Really, I am not
looking for an argument, but getting this right (as scipy does) is
important.

--
--Matt Newville
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: fit with 3 parameters ok, fit with 4 is going wrong!

Robert Kern-2
On Mon, Feb 10, 2014 at 3:14 AM, Matt Newville
<[hidden email]> wrote:

> On Sat, Feb 8, 2014 at 5:01 AM, Robert Kern <[hidden email]> wrote:
>>
>> On Fri, Feb 7, 2014 at 9:42 PM, Matt Newville
>> <[hidden email]> wrote:
>> >
>> > On Fri, Feb 7, 2014 at 7:22 AM, Robert Kern <[hidden email]> wrote:
>> >>
>> >> On Fri, Feb 7, 2014 at 1:03 PM, Matt Newville
>> >> <[hidden email]> wrote:
>> >> >
>> >> > On Feb 6, 2014 5:14 PM, "Robert Kern" <[hidden email]> wrote:
>> >> >>
>> >> >> On Thu, Feb 6, 2014 at 9:20 PM, Matt Newville
>> >> >> <[hidden email]> wrote:
>> >> >> > Hi David,
>> >> >> >
>> >> >> >
>> >> >> > On Thu, Feb 6, 2014 at 2:20 PM, Daπid <[hidden email]> wrote:
>> >> >> >>
>> >> >> >> On 6 February 2014 18:55, Matt Newville <[hidden email]>
>> >> >> >> wrote:
>> >> >> >>>
>> >> >> >>> I'm interested, but slightly confused.   Iminuit / probfit is
>> >> >> >>> described
>> >> >> >>> as BSD, but depends on (and includes?) Minuit - isn't that GPL?
>> >> >> >>
>> >> >> >>
>> >> >> >> The license says iminuit is MIT, but Minuit is GPLv2. So, the Python
>> >> >> >> part,
>> >> >> >> that wraps the C code is MIT.
>> >> >> >
>> >> >> > The way I understand it, code that wraps GPLv2 code is required to
>> >> >> > use
>> >> >> > GPL,
>> >> >> > and so propagate the license to all code using it. That would mean
>> >> >> > that
>> >> >> > code
>> >> >> > that uses Minuit cannot be something other than GPL.   Perhaps I am
>> >> >> > not
>> >> >> > understanding something.
>> >> >>
>> >> >> GPLed code can be combined with code under a different license as long
>> >> >> as that other license imposes no conditions more restrictive than
>> >> >> those in the GPL. The MIT license is one such license. This is all
>> >> >> perfectly above board.
>> >> >
>> >> > Unless I am mistaken (not without precedent), the resulting mixed code
>> >> > must
>> >> > use the GPL. If library "M" is GPL and package "Mwrapper" calls it,
>> >> > "Mwrapper" must be GPL.   This license propagation is the distinguishing
>> >> > characteristic of GPL, and what differentiates it from LGPL and BSD/MIT.
>> >> > Do
>> >> > you disagree?
>> >>
>> >> Yes. The combined work must be distributed under the GPL license. But
>> >> each component can have a non-GPL-but-GPL-compatible license, like the
>> >> MIT license. The parts of "Mwrapper" that are not "M" itself do not
>> >> need to be GPLed. "Mwrapper+M" is GPLed. "Mwrapper" itself does not
>> >> need to be (provided they are licensed compatibly).
>> >>
>> >
>> > The parts of Mwrapper that use M must be GPL.
>> >
>> >>
>> >> This is why I say that the *practical effect* of saying that
>> >> "Mwrapper" is BSD-licensed is confusing. Users grab "Mwrapper+M" under
>> >> the impression that "Mwrapper"'s license is the only one, when it is
>> >> not.
>> >>
>> >> >> That said, as a practical matter, for a package that mostly just wraps
>> >> >> the functionality of the internal GPLed component, licensing that
>> >> >> wrapper under the MIT license leads to confusion, as we have seen.
>> >> >
>> >> > I think this does not lead to confusion, but to a license violation.
>> >> > The
>> >> > GPL is wordy, but not confusing.  If your code wraps (uses, links to,
>> >> > imports, or calls) GPL code, your code must use the GPL.  Not MIT.
>> >>
>> >> You have misread the GPL. Please consult the FSF's information about
>> >> mixing code with GPL-compatible licenses. The propagation applies to
>> >> the combined work as a whole, not every single piece of code in the
>> >> combined work.
>> >
>> > Perhaps this is a bit off-topic, but I believe that I have not misread the
>> > GPL. I do agree that it does not apply to every single piece of code in the
>> > combined work.  But I believe (and, sorry but I am not convinced by you
>> > saying otherwise, without strong evidence) it does apply to every piece of
>> > code that **uses** the GPL code, including making library calls.
>>
>> Section 7 of the GPLv3:
>>
>> """
>> You may place additional permissions on material, added by you to a
>> covered work, for which you have or can give appropriate copyright
>> permission.
>> """
>>
>> Applying the BSD license to the portions of the code that you wrote is
>> providing just such additional permissions.
>
> I'm pretty sure that would actually violate the GPL.  This is a bit
> off-topic, and can be a politically-charged topic.  Truly, I mean no
> ill-will, am not looking for an argument, and would be willing to end
> the discussion.   My initial reaction on reading this is that I have
> been dealing with this issue for well over a decade,

Me too!

> and am really
> very certain that I understand these licenses, and that your reading
> is dangerously mistaken.  But, I've also been doing science and
> software long enough to see my own certainty as a red flag -- being
> dead certain is the first sign of being dead wrong.  So, as you
> suggest, let's look only to texts from the gnu.org sites.  Evidence
> and explanations at wikipedia, stackexchange, and the like are often
> in plainer language, and uniformly come to a common conclusion: code
> that links to a GPL library is derived work, and is required to use
> the GPL.  But, let's call that as hearsay, and re-read the writings
> from gnu.org with open minds, looking for clarification.
>
> For example, https://www.gnu.org/licenses/gpl-faq.html#GPLStaticVsDynamic
>
>     Q: Does the GPL have different requirements for statically vs
> dynamically linked modules with a covered work?
>     A: No. Linking a GPL covered work statically or dynamically with
> other modules is making a combined work based
>     on the GPL covered work. Thus, the terms and conditions of the GNU
> General Public License cover the whole combination.
>
> For myself, that is clear enough to effectively end the discussion:
> linking to a GPL library makes the work GPL.  A python script that has
> "import pygsl", "import pyfftw" or "import PyQ4t" is lining to one of
> those GPL libraries, and so is required to use the GPL.

All of these statements are about whether or not the terms of the GPL
apply at all. The terms do apply to these situations. They *don't*
apply if one uses stdin/stdout to communicate with the GPLed
component, and there are *no* restrictions on the licensing of the
outer component in that case. One cannot write a program that imports
a GPLed component that places restrictions beyond the GPL (to use
GPLv2 terminology). However, one of the *explicit* terms of the GPL
lets you grant *additional permissions* to the code that you wrote
(but *not* the third-party GPLed code that you used).

> If that is not yet clear enough, consider why the LGPL exists at all.
> From the preamble of the LGPL
> (http://www.gnu.org/licenses/lgpl-2.1.html), describing this very
> subject:
>
>     When a program is linked with a library, whether statically or
> using a shared library, the combination of the two is legally speaking
>     a combined work, a derivative of the original library. The
> ordinary General Public License therefore permits such linking only if
> the
>     entire combination fits its criteria of freedom. The Lesser
> General Public License permits more lax criteria for linking other
> code
>     with the library.
>
> Here, of course, 'fits its criteria of freedom' means 'uses the GPL'.
> The point being made here is to explain that the purpose of the LGPL
> is to relax the strict requirement of license propagation that does
> exist for the GPL.  You can also read the entirety of
> http://www.gnu.org/philosophy/why-not-lgpl.html, which explains
> clearly that code that links to a GPL library must use the GPL, and
> that the purpose of the LGPL is to relax this requirement.

Actually, I don't think it ever says that, nor does it address the
facts of our case in front of us. My reading of the GPL is consistent
with that manifesto. The two parties contemplated in the manifesto are
"free software developers" and "proprietary software developers". The
FSF considers the BSD a "free software license", just a non-copyleft
one. My reading of the GPL still contains propagation, verbatim from
the library to the work as a whole, and from the library to every
piece of code in the whole independently by way of restricting the
available licenses to those that are GPL-compatible.

> For completeness,  this point is succinctly if tortuously stated in
> the GPL itself, GPLv3  section 5c (similar wording exists in GPLv2
> section 2c) reads:
>
>     You may convey a work based on the Program, or the modifications
> to produce it from the Program, in the form of source
>     code under the terms of section 4, provided that you also meet all
> of these conditions:
>
>     c) You must license the entire work, as a whole, under this
> License to anyone who comes into possession of a copy. This
>     License will therefore apply, along with any applicable section 7
> additional terms, to the whole of the work, and all its parts,
>     regardless of how they are packaged. This License gives no
> permission to license the work in any other way, but it does not
>     invalidate such permission if you have separately received it.
>
> The intent seems clear enough to me.  Do you read this differently?

"as a whole" is the part where we seem to differ. You are making a
claim that there is an essential difference between the act of mixing
a third-party BSD component and a third-party GPL component to make a
GPLed whole and the act of writing a BSD component and using a
third-party GPL component to make a GPLed whole. I believe that there
is no such essential difference in the text of the GPL or the FSF's
interpretation of the GPL. If we are diving back in the GPLv2 to
discern long-term intent:

"These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it."

Applying the BSD license to the iminuit wrapper is exactly that case:
if there are bits from the wrapper that you can use without the GPLed
MINUIT2, then you can extract them and use them under the BSD license.
If those bits still need the GPLed MINUIT2, then you still need to
deal with the MINUIT2 license, as a matter of course. That follows
regardless because you still need to distribute MINUIT2 with those
bits.

> Earlier, you correctly said "The propagation [of GPL] applies to the
> combined work as a whole", as this section states rather clearly.  A
> python module or script is a "combined work" or "program" here --
> copyrightable source code that can be run and distributed.  By
> importing a GPL covered module, one is dynamically linking to it, and
> the GPL used by the imported library applies to the importing
> program/script/module.   To be sure, any code that might also be used
> in said script but which does not directly import/link to a GPL
> library does not need to be GPLed.  But the calling script (the
> equivalent of main() -- the "combined work") most certainly does.
>
> You quoted from Section 7 of the GPL, but I believe you misunderstood
> "for which you have or can give appropriate copyright permission".
> You (generally speaking)  do not have copyright permission needed to
> be able to change the license under which you use the library that you
> are linking to.  And the license for linking to that library requires
> that your work use the GPL.

Your interpretation would make that section entirely inoperable. You
could never "place additional permissions on material, added by you to
a covered work" because the act of adding to a GPLed work in a
meaningful way always means that you never have "appropriate copyright
permission".

> This section  is new to GPLv3.    According to
> https://www.gnu.org/licenses/quick-guide-gplv3.html, the license
> compatibility language was clarified in GPLv3:
>
>     Clarifying License Compatibility
>
>     If you found some code and wanted to incorporate it into a GPLed
> project, GPLv2 said that the license on the other
>     code was not allowed to have any restrictions that were not
> already in GPLv2. As long as that was the case, we said
>     the license was GPL-compatible.
>
>     However, some licenses had requirements that weren't really
> restrictive, because they were so easy to comply with. For
>     example, some licenses say that they don't give you permission to
> use certain trademarks. That's not really an additional
>     restriction: if that clause wasn't there, you still wouldn't have
> permission to use the trademark. We always said those licenses
>     were compatible with GPLv2, too.
>
>     Now, GPLv3 explicitly gives everyone permission to use code that
> has requirements like this. These new terms should help
>     clear up misunderstandings about which licenses are
> GPL-compatible, why that is, and what you can do with GPL-compatible
>     code.
>
> Again, the sense of "compatible" here is to say what code is allowed
> to be used by GPL code, not what license one may choose for derived
> work.  It is not granting one the right to use a BSD license for code
> that links to a GPL library.

I believe that you are taking the mode of speech, which implicitly
assumes the most common case (adding other code to a GPLed program)
and the most desirable one (for the FSF) for didactic purposes, as
forbidding the uncommon cases. You may be interested in some of the
FAQs that do address the uncommon cases that are more like ours:

http://www.gnu.org/licenses/gpl-faq.html#GPLModuleLicense

"""
* If I add a module to a GPL-covered program, do I have to use the GPL
as the license for my module?

  The GPL says that the whole combined program has to be released
under the GPL. So your module has to be available for use under the
GPL.

  But you can give additional permission for the use of your code. You
can, if you wish, release your program under a license which is more
lax than the GPL but compatible with the GPL. The license list page
gives a partial list of GPL-compatible licenses.
"""

http://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL

"""
* If a library is released under the GPL (not the LGPL), does that
mean that any software which uses it has to be under the GPL or a
GPL-compatible license? (#IfLibraryIsGPL)

  Yes, because the software as it is actually run includes the library.
"""

Note that for this last question, they explicitly say that the
software using the GPLed library can be under a GPL-compatible
license, not just the GPL itself.

> The propagation of the GPL to calling code is the essence of the GPL,
> and the distinguishing characteristic between GPL, LGPL and the
> BSD/MIT licenses.   Happily, the scipy pages on license compatibility
> are clear about *not* including GPL (or even LGPL) code in scipy.
>
> Trying to come back on topic, I still can't figure out what license
> Minuit actually uses.  The iminuit package describes it one place as
> LGPL, but I don't see that in Minuit itself.

It's a mess. There is precisely one source file in MINUIT2 itself that
includes the standard GPL header (besides all of the autoconf stuff).

> Sorry this was so long and slightly off topic. Really, I am not
> looking for an argument, but getting this right (as scipy does) is
> important.
>
> --
> --Matt Newville
> _______________________________________________
> SciPy-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/scipy-user



--
Robert Kern
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user