[Python] Cannot infer type for @indie.param.context [closed]

Discussão em 'Python' iniciado por Stack, Abril 24, 2025.

  1. Stack

    Stack Membro Participativo

    Indie indicator getting this error during compile


    Error: [internal] can not infer type for @indie.param.context, use @indie.param decorator with following types: int, float, string, str, time_frame, source, bool, color
    ​

    This happens when I try to declare ctx as an input parameter using @param.context("ctx"). Here's a minimal reproduction:

    # indie:lang_version = 4
    import math
    from indie import indicator, param, plot, color, SeriesF, MutSeriesF, MainContext
    from indie.algorithms import Sum

    @indicator("Autocorrelation Indicator")
    @param.context("ctx") # !!=ERROR=!!
    @param.source("src", title="Source")
    @param.int("length", default=20, title="Length")
    @param.bool("test_signal", default=False, title="Use test signal")
    class Main(MainContext):
    def __init__(self, ctx: MainContext, src: SeriesF, length: int, test_signal: bool):
    super().__init__(ctx)
    self.src = src
    self.length = length
    self.test_signal = test_signal


    I've Tried:


    1. Removing @param.context("ctx")
      • This fixes the error, but then ctx is not recognized when calling super().__init__(ctx).

    2. Replacing @param.context("ctx") with @param.str("ctx")
      • This fixes the error, but ctx should not be a string—it's the execution context.

    3. Looking for Alternative Context Parameter Declarations
      • The Indie documentation mentions MainContext as the base class but doesn't say if ctx needs to be explicitly decorated.

    Questions:


    1. Is @param.context("ctx") a valid decorator in Indie v4**+**?


    2. If ctx doesn't need to be declared, how do I pass it correctly?


    3. Is there another way to define context-based parameters in Indie?

    Continue reading...

Compartilhe esta Página