Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unary operations on TimeSeries #170

Open
mvcisback opened this issue Nov 13, 2017 · 2 comments
Open

Unary operations on TimeSeries #170

mvcisback opened this issue Nov 13, 2017 · 2 comments

Comments

@mvcisback
Copy link

Given the current API (v0.3.1) there does not seem to be a straightforward way to do a unary operation.

Suppose one wishes to negate a boolean valued signal. One option is:

import traces

x = traces.TimeSeries([(0, False), (1, True)])
x.operation(x, lambda val, _: not val)

but this seems somewhat clunky.

Better might be

import traces

x = traces.TimeSeries([(0, True), (1, False)])
x.map(lambda val: not val)

Which could be syntatic sugar for:

traces.TimeSeries((t, not val) for (t, v) in x))
@vlsd
Copy link
Contributor

vlsd commented Nov 26, 2018

You're right, this would be a nice addition!

@mvcisback
Copy link
Author

@vlsd
I've actually written a library inspired by traces that supports this operation:

https://github.com/mvcisback/DiscreteSignals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants