Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I'm trying to call a function within a class from another function within the same class with pool map
pool = Pool(num_cores)
res = pool.map(self.get_data_vector())
The function has no arguments except self and I'm getting this error
TypeError: map() missing 1 required positional argument: 'iterable'
This is the function
def get_data_vector(self):
EDIT:
I was missing the variable to map which is self.doc_ids and it is a list.
I'm now calling it like this
res = pool.map(__class__.get_data_vector,(self,self.doc_ids))
The function should be called like this
def get_data_vector(self, doc_id):
but the error now changed to
TypeError: get_data_vector() missing 1 required positional argument: 'doc_id'
–
I will assume that self.doc_ids
is a list or something else iterable.
Then you should be able to use this:
res = pool.map(self.get_data_vector, self.doc_ids)
This means that get_data_vector
will be called with two arguments. The first one is self
, as a bound method, and the second one are the elements of the iterable self.doc_ids
.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.