Skip to content

TypeError: bad operand type for unary ~: 'NoneType' in _loadWeights_handler during Predict-only mode #59

@flomertens

Description

@flomertens

DDFacet crashes when running in --Output-Mode=Predict with --CF-wmax set to non-zero.

Traceback

File "ClassVisServer.py", line 951, in _loadWeights_handler
uvmax_wavelengths = abs(uv[~rowflags,:]).max() * msfreqs.max() / _cc
TypeError: bad operand type for unary ~: 'NoneType'

Root cause

The bug is a chain of steps:

  1. Predict-only mode triggers IgnoreWeights(), setting _ignore_vis_weights=True (this also requires --CF-wmax to be non-zero, as the code explicitly skips IgnoreWeights() when wmax==0)
  2. This causes wmax_only=True to be passed to _loadWeights_handler
  3. Which passes uvw_only=True to readWeights
  4. readWeights has already computed rowflags from the FLAG column, but discards it in the uvw_only early return:
if uvw_only:
    return uvw, None, None, None  # rowflags is thrown away
  1. Back in _loadWeights_handler, uvw is valid so the if uvw is None guard is not triggered, and the code crashes on ~rowflags

This affects any dataset with at least one unflagged row, i.e. essentially all real datasets running in Predict mode.

potential Fix?

One line change in readWeights:

if uvw_only:
    return uvw, None, rowflags, None

To reproduce

Any DDF Predict run with non-zero --CF-wmax, e.g.:

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