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

handle xarrs with quantities in places they were raising issues #389

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

keflavich
Copy link
Collaborator

Glen Langston reported that this example:
https://pyspeckit.readthedocs.io/en/latest/example_continuum_fromscratch.html
was failing with the following traceback:

Traceback (most recent call last):
  File "<ipython-input-1-dca5499ff34c>", line 29, in <module>
    sp.specfit(fittype='polycontinuum', guesses=(0,0), exclude=[30, 70])
  File "/home/adam/repos/pyspeckit/pyspeckit/config.py", line 145, in decorator
    f(self, *args, **new_kwargs)
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/fitters.py", line 344, in __call__
    self.multifit(show_components=show_components, verbose=verbose,
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/fitters.py", line 822, in multifit
    self.plot_fit(annotate=annotate,
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/fitters.py", line 1145, in plot_fit
    self._full_model()
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/fitters.py", line 1035, in _full_model
    self.fullmodel = self.get_full_model(debug=debug,**kwargs)
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/fitters.py", line 1040, in get_full_model
    return self.get_model(self.Spectrum.xarr, debug=debug,**kwargs)
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/fitters.py", line 1045, in get_model
    return self.get_model_frompars(xarr=xarr, pars=self.parinfo,
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/fitters.py", line 1057, in get_model_frompars
    return (self.fitter.n_modelfunc(pars,
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/models/model.py", line 402, in L
    v += self.modelfunc(x, *parvals[lower_parind:upper_parind], **kwargs)
  File "/home/adam/repos/pyspeckit/pyspeckit/spectrum/models/polynomial_continuum.py", line 24, in polymodel
    return numpy.polyval(pars,x)
  File "<__array_function__ internals>", line 180, in polyval
TypeError: no implementation found for 'numpy.polyval' on types that implement __array_function__: [<class 'pyspeckit.spectrum.units.SpectroscopicAxis'>]

This is caused by some change in how Quantities behave wrt numpy functions. This PR implements some workarounds that strip quantity properties where they might cause problems.

@keflavich keflavich merged commit 403cae6 into pyspeckit:master Aug 9, 2023
keflavich added a commit to keflavich/pyspeckit that referenced this pull request Aug 9, 2023
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

Successfully merging this pull request may close these issues.

1 participant