Comments (3)
I think this is a bug in lmfit 1.3.0
. The documentation states that additional keywords to Model
are passed to the model function, but this clearly isn't happening based on the following minimal non-working example. I will open an issue on the lmfit
repository
import numpy as np
from lmfit import Model, Parameters
# Define some data
x = np.linspace(0,1,num=10)
data = 10*x+2
# Parameters list with one parameter
params = Parameters()
params.add("b", value=5, vary=True, min=0.5, max=25)
# Dictionary of constants to be passed to model function through **kws
# of `Model`
settings = {'a':2}
# Define a model function that takes the parameters and the settings keyword
def _model(x, settings=None, **params):
# TypeError is raised here because `settings` keyword is not being
# passed through to `_model`, so `settings=None`
a = settings['a']
b = params['b']
return x*b + a
model = Model(
_model,
independent_vars=["x"],
settings=settings,
)
# Try to fit
# This raises an exception
result = model.fit(
data,
params=params,
x=x,
method="leastsq",
)
print(result.best_values)
from plasmapy.
If lmfit
doesn't want to restore this functionality (or it takes a while to get that in their release version), the following fix would work (around line 1007 of thomson.py
). The lambda
function provides a work around way of passing settings
into _spectral_density_model
_spectral_density_model_lambda = lambda wavelengths, **params: _model(wavelengths, settings=settings, **params)
return Model(
_spectral_density_model_lambda,
independent_vars=["wavelengths"],
nan_policy="omit",
)
from plasmapy.
Closed by #2623
from plasmapy.
Related Issues (20)
- Decide on preferred set of `mypy` rules to adopt HOT 5
- Improve Thomson module
- Different return types for `is_category` method of `ParticleList` than `Particle` & `CustomParticle` HOT 3
- Make it so that mypy thinks that `ParticleLike` has the same attributes as `Particle`
- Store downloaded data in `$XDG_DATA_HOME` if that environment variable exists HOT 1
- Multiple density values in `formulary.radiation.thermal_bremsstrahlung` returns `ValueError`
- Make it so that `plasmapy.__version__` uses current date in editable installs
- Verify that files are included or not included in source distributions and wheels
- Show correct version in title of `latest` docs
- Enable weekly tests with the JIT compiler to be added in Python 3.13
- CI codecov bug HOT 2
- Allow ParticleTracker to accept analytical fields (as functions) or lists of currents/charges
- Add helper functionality to plot quantities against temperature with axes labeled in both K and eV HOT 2
- Add `latex_str` attribute to `Particle`
- Add Jupyter notebook that plots reconnection phase diagram
- what is the unit of temperature defined in the Spitzer resistivity HOT 3
- Requirements files need to be rethought HOT 2
- Spin off plasma calculator into separate affiliated package
- Rename `binding_energy` property of `Particle` to `nuclear_binding_energy` and add `electron_binding_energy` based on `ionization_energy`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plasmapy.