Giter Club home page Giter Club logo

eventkit's People

Contributors

erdewit avatar stnatter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eventkit's Issues

crash upon simple import within PyCharm under Debug

I came across this trying to use/debug ib-insync, but really believe it is some strange interaction of eventkit, asyncio and PyCharm, which I can not explain nor solve. Could be a PyCharm issue, could be an asyncio issue.
Can't debug ib-insync really ...

Any help is appreciated. Maybe user error ...

create an environment with at least eventkit and numpy.
create 2 liner:

echo "import eventkit; print(eventkit.__version__)" > ev.py 

Works:
python ev.py
result: 0.8.9

Open PyCharm (I have Community Edition 2021.2.3 on OsX)
connect to the correct environment
Run: works: result 0.8.9

Debug: crash upon "import eventkit" with exception within exception
eventkit_pycharm_debug_crash.txt
..

missing py.typed and errors in typing

The package requires a py.typed marker.

After generating stubs with stubgen, mypy reports following errors:

stubs/eventkit/ops/timing.pyi:9: error: Signature of "on_source_error" incompatible with supertype "Op"  [override]
stubs/eventkit/ops/timing.pyi:9: note:      Superclass:
stubs/eventkit/ops/timing.pyi:9: note:          def on_source_error(self, source: Any, error: Any) -> None
stubs/eventkit/ops/timing.pyi:9: note:      Subclass:
stubs/eventkit/ops/timing.pyi:9: note:          def on_source_error(self, error: Any) -> None
stubs/eventkit/ops/misc.pyi:10: error: Signature of "on_source_error" incompatible with supertype "Op"  [override]
stubs/eventkit/ops/misc.pyi:10: note:      Superclass:
stubs/eventkit/ops/misc.pyi:10: note:          def on_source_error(self, source: Any, error: Any) -> None
stubs/eventkit/ops/misc.pyi:10: note:      Subclass:
stubs/eventkit/ops/misc.pyi:10: note:          def on_source_error(self, error: Any) -> None
stubs/eventkit/ops/array.pyi:8: error: Return type "ArrayMin" of "min" incompatible with return type "Min" in supertype "Event"  [override]
stubs/eventkit/ops/array.pyi:9: error: Return type "ArrayMax" of "max" incompatible with return type "Max" in supertype "Event"  [override]
stubs/eventkit/ops/array.pyi:10: error: Signature of "sum" incompatible with supertype "Event"  [override]
stubs/eventkit/ops/array.pyi:10: note:      Superclass:
stubs/eventkit/ops/array.pyi:10: note:          def sum(self, start: int = ...) -> Sum
stubs/eventkit/ops/array.pyi:10: note:      Subclass:
stubs/eventkit/ops/array.pyi:10: note:          def sum(self) -> ArraySum
stubs/eventkit/ops/array.pyi:12: error: Return type "ArrayMean" of "mean" incompatible with return type "Mean" in supertype "Event"  [override]
stubs/eventkit/ops/array.pyi:14: error: Return type "ArrayAny" of "any" incompatible with return type "eventkit.ops.aggregate.Any" in supertype "Event"  [override]
stubs/eventkit/ops/array.pyi:15: error: Return type "ArrayAll" of "all" incompatible with return type "All" in supertype "Event"  [override]
Found 8 errors in 3 files (checked 14 source files)

pytest simulate event

Hi,

Is there a way to simulate the happening of an event in a unit test?
Background: I'm using ib_insync and trying to write unit tests for functions which use the waitOnUpdate() method.

Sorry if the answer is maybe obvious, but I haven't found out how.

Thanks

.map is lost bc of using weak refs

I'm simply setting up a pipeline in a function:

def test():
    def _setup(ev: Event, target: Callable):
        ev2 = ev.map(lambda x: x * 2)
        ev2 += target

    async def atest():
        ev = Event()
        _setup(ev, print)
        print('start')
        ev.emit(1)
        ev.emit(2)

    import asyncio
    asyncio.get_event_loop().run_until_complete(atest())
    # asyncio.run(atest())

I'm expecting to see 2 and 4 printed but I only get 'start'.
It looks like the ev2 is lost as soon as the _setup is left, because keep_ref is False by default (and using += gives no way to change it).

So for this to work correctly I'd need to keep a reference to every single transformer in the pipeline, or I'd need to explicitly create and connect Map objects with keep_ref=True, right?

Is using weak refs by default a good idea?

additional array methods

Would you be open to add some additional methods on Array class? While using eventkit with ib_insync, it would be helpful to have some basic indicators built in. I'm currently missing equivalent to pandas.ewm, pandas.diff, atr, rsi, but gradually more could be added. I could take a crack at it and send a PR, the question is whether you see it as part of the package or should I just make an extension?

connecting or disconnecting a listener while handling an emit

What is the expected behavior of the following?

from eventkit import Event

event = Event("event")


def hello():
    global event
    print("hello")
    event += goodbye        # Changing the order of this line 
    event -= hello          # and the next changes the output.

def goodbye():
    print("goodbye")


event += hello

event.emit()
event.emit()

Per the comment above, changing the order of those two lines unexpectedly changes the output. It looks to me that while the first emit() is in the middle of iterating over the event slots (line 190, see [2] below), disconnecting a listener (as in event -= hello) causes all the slots to be rebuilt (line 157, see [1] below). Will this lead to undefined behavior? It seemed to be giving me unexpected results in more complicated situations.

Perhaps the emit for loop (line 190) should make a copy of the slots before iterating over them?

[1]

self._slots = [s for s in self._slots if s != [None, None, None]]

[2]

for obj, ref, func in self._slots:

datetime.timedelta does not seem to be handled

Hi,

I was developing an application which should trigger every k minutes. For developing reasons I was using the following codesnippet which worked fine.

from datetime import datetime, timedelta

timer_check = eventkit.Timerange(start=datetime.now(), step=20) ``timer_check += _on_timer_check

As soon as I change to
timer_check = eventkit.Timerange(start=datetime.now(), step=timedelta(seconds=20))
the code runs, but no event is triggered anymore, which is I believe something is not working properly.

Would be great to receive a feedback.

Event.aiter could be optimized for skip_to_last=True case

Event.aiter allows a skip_to_last boolean argument that, when set to True, only yields last values from the source event, skipping intermediate values since the previous yield.

The current implementation uses an asynchronous queue for the entire method, whatever the value of the skip_to_last boolean argument.

async def aiter(self, skip_to_last: bool = False, tuples: bool = False):

However when skip_to_last=True, it is not necessary anymore to use a queue: simple state variables remembering the last state of the source iterator are sufficient.

This could vastly reduce the memory consumption for intensive source events emitting many values - which is exactly the optimization case skip_to_last=True was intended for.

Help with error handling

Haven's seen any docs, examples or tests related to error handling.

There's .errors operator that should return the error stream.

I tried to use it like this (test case):

def test_error():
    evt = Event()

    def err():
        raise ValueError()

    errors = evt.map(err, ordered=False).errors()

    evt()

    errors.run()

but it just waits indefinitely.

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.