Skip to content

EnsemblePosterior.map(x=..., individually=True) fails with a deprecation error #2121

Closed

Description

@janfb

Bug description

EnsemblePosterior.map() takes an observation x. The joint MAP uses it. With individually=True, the ensemble passes x on to the map() of each component. All other posteriors deprecated x in map() in favour of set_default_x(), so this call always fails.

Minimal code example

ensemble = EnsemblePosterior([posterior_1, posterior_2])
ensemble.map(x=x_o)                     # works
ensemble.map(x=x_o, individually=True)  # raises ValueError

Error message or traceback

ValueError: Passing `x` directly to `.map()` has been deprecated.Use `.self_default_x()` to set `x`, and then run `.map()`

The message also has two typos: a missing space after "deprecated." and .self_default_x() instead of .set_default_x().

Proposed fix

I think EnsemblePosterior.map() should deprecate x as well, like all other posteriors. set_default_x() on the ensemble already sets the observation on every component, so both paths then behave the same. The fix should also correct the message.

sbi version

main (2026-10-29)

Activity

  1. added
    bug
    on Oct 29, 2026
  2. BHARATH0153 commented on Oct 29, 2026

    @BHARATH0153
    Contributor

    Ran into this while checking the ensemble MAP individually=True just forwards x into
    each component's map() and every other posterior already dropped x in favour of
    set_default_x(), so that path always raised I deprecated x in EnsemblePosterior.map()
    as well — set_default_x() already pushes the observation down to all components, so the
    joint and individual MAP now go through the same code Moved the check into one helper
    on NeuralPosterior and reused it in VectorFieldPosterior which also removes the
    duplicated block and fixes the two typos in the message Test covers individual + joint
    MAP from a default x plus both x= paths raising ruff pyright and the ensemble tests
    pass

  3. added 7 commits that reference this issue on Oct 29, 2026
    1383097
    0ef4125
    c968963
    d61ccd4
    ec549d5
    91c231a
    2fdc245
  4. added a commit that references this issue on Nov 15, 2026
    799e324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions