Skip to content

Data cube with one exposure (i.e. cube.shape[0]==1) causes indexing or division error.  #82

@vandalt

Description

@vandalt

When using a data cube with only one exposure (i.e. cube.shape[0]==1), I encountered two errors in extract_bs():

  • An IndexError if clipping had been done before and rejected the only frame in in the cube and extract_bs() had an empty input.

    Error message
      bs = amical.extract_bs(
      File "/home/vandal/projects/amical/amical/mf_pipeline/bispect.py", line 1138, in extract_bs
        ft_arr, n_ps, npix = _construct_ft_arr(cube)
      File "/home/vandal/projects/amical/amical/mf_pipeline/bispect.py", line 227, in _construct_ft_arr
        n_pix = cube.shape[1]
      IndexError: tuple index out of range
    
  • A ZeroDivisionError if no clipping was done and extract_bs() received a cube with one frame.

    Error message
     bs = amical.extract_bs(
     File "/home/vandal/projects/amical/amical/mf_pipeline/bispect.py", line 1242, in extract_bs
         v2_quantities = _compute_v2_quantities(v2_arr_unbiased, bias_arr, n_blocks)
     File "/home/vandal/projects/amical/amical/mf_pipeline/bispect.py", line 537, in _compute_v2_quantities
         ind2 = (k + 1) * n_ps // (n_blocks - 1)
     ZeroDivisionError: integer division or modulo by zero
    

As discussed with @DrSoulain, this should not occur often and is currently not supported. It might still be worth adding an error to catch these two cases in extract_bs and raise a more informative error message to clarify what is happening.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions