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

fix circular import with trace_shifts #2084

Merged
merged 1 commit into from
Aug 1, 2023
Merged

fix circular import with trace_shifts #2084

merged 1 commit into from
Aug 1, 2023

Conversation

segasai
Copy link
Contributor

@segasai segasai commented Jul 22, 2023

When trying to import desispec.trace_shifts
I get the circular import

File ~/pyenv310/lib/python3.10/site-packages/desispec/image_model.py:25
     23 from desispec.qproc.qsky import qproc_sky_subtraction
     24 from desispec.qproc.qfiberflat import qproc_apply_fiberflat
---> 25 from desispec.trace_shifts import compute_dx_from_cross_dispersion_profiles
     27 @numba.jit
     28 def numba_proj(image,x,sigma,flux) :
     29     '''
     30     Add a spectrum to a model of the pixel values in a CCD image assuming a Gaussian cross-dispersion profile.
     31 
   (...)
     36        flux : 1D numpy array of size image.shape[0], quantity to project (for design usage: electrons per pixel) for each CCD row
     37     '''

ImportError: cannot import name 'compute_dx_from_cross_dispersion_profiles' from partially initialized module 'desispec.trace_shifts' (most likely due to a circular import) (/home/koposov/pyenv310/lib/python3.10/site-packages/desispec/trace_shifts.py)

The patch fixes that

@sbailey
Copy link
Contributor

sbailey commented Aug 1, 2023

For the record, desispec.scripts.trace_shifts accidentally avoided this circular import with from desispec.io import read_image before from desispec.trace_shifts import ..., which is why we weren't previously bitten by this.

But I agree that desispec.trace_shifts / desispec.image_model has a circular import and that this PR fixes it. Thanks.

@sbailey sbailey merged commit a22a558 into main Aug 1, 2023
24 checks passed
@sbailey sbailey deleted the fix_circular branch August 1, 2023 22:06
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.

2 participants