GithubHelp home page GithubHelp logo

Comments (4)

CJ-Wright avatar CJ-Wright commented on May 26, 2024 1

Just as a heads up, I would not use next as an arg name since it shadows a python builtin.

from streamz.

CJ-Wright avatar CJ-Wright commented on May 26, 2024

Maybe we have an accumulate which takes in two streams, the first has the data and the second exists just to send a reset message (or even a new start value?). This way we could reset based off of some property of the data, eg we reached some threshold (via cyclic graphing) or reset based on something completely different occurring somewhere else in the graph.

from streamz.

mrocklin avatar mrocklin commented on May 26, 2024

Perhaps you can put this logic into your accumulator function?

from streamz.

jrmlhermitte avatar jrmlhermitte commented on May 26, 2024

funny, i was working on this yesterday. What @mrocklin mentioned is what I'm doing. Basically, have an stop condition and initial condition in accumulator:

def acc(prevstate, nextstate):
    # initial condition
    if prevstate is None:
        return nextstate
    # stop condition (reset to initial condition)
    if nextstate is None:
        # if prevstate will get set to None
        return None
    # rest of acc logic

(assumes returns_state=False here)

If you want to be cleaner, prev could be a tuple of mydata, state where state gives information on clearing or not. This ensures more homogeneity downstream.
It's messy, but I feel that enforcing a global clearing mechanism might be too restrictive, considering the stream can already do this. I'd def like to see a use case where it's necessary though. I haven't used this feature so much.

just thoughts, what do you think? I'm interested in exploring more concise methods.
About a stream that resets another, I would vote against that as we'd have to worry about synchronizing yet another stream, when we may not always have to.

EDIT : Changed next to nextstate just to avoid any confusion. thanks @CJ-Wright

from streamz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.