Comments (4)
The generator is not the problem. The problem is that your transform function takes two arguments. So you need to star the tuple argument:
ys = pipe(get_train_test_years(), seq.map(lambda x: transform(*x)))
But we should probably just add a starmap
operator to the seq
module:
def starmap(
mapper: Callable[[Tuple[Any, ...]], Any]
) -> Callable[[Iterable[Any]], Iterable[Any]]:
return seq.map(lambda x: mapper(*x))
from expression.
At
ys = pipe(get_train_test_years(), seq.map(lambda x: transform(*x)))
I get
(parameter) x: TSource@map
"object*" is not iterable
"__iter__" method not definedPylance
from expression.
Yes, lambdas do not support type annotations. Use a function instead so you can specify the type of x
e.g:
def mapper(x: Tuple[List[int], int]):
return transform(*x)
ys = pipe(get_train_test_years(), seq.map(mapper))
PS: Also add type annotations to transform
.
from expression.
Thanks for explaining this to me.
from expression.
Related Issues (20)
- How are the collections implemented? HOT 6
- Fishy locking in CancellationSource HOT 1
- Issue on page /tutorial/effects.html HOT 3
- Feature request: implement hash for `Some`, `Result` and `default_with` to generate default value lazily. HOT 1
- Generic monad algorithm HOT 1
- 4.2.0 has invalid python 3.9 syntax HOT 1
- change function for map does not appear to work correctly HOT 2
- Type aliases using Union syntax incompatible with Python 3.9 HOT 4
- Map change drops current items when len is two HOT 1
- How about using TypeAlias with Result and Option? HOT 1
- Is there some helper function to use parameters for function in Result? HOT 1
- Dependency Dashboard
- Is Option or Result type have apply function? HOT 5
- seq.map does not type check correctly HOT 1
- _TSource in Option should be covariant HOT 7
- NonEmptyList
- __str__ and __repr__ of Failure & Success HOT 1
- Improve the ergonomics of pipelines HOT 13
- Actor Model & Railway oriented programming HOT 1
- Question: How do you use @effect.result with asyncio? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expression.