mirror of
https://github.com/wassname/p_tqdm.git
synced 2026-09-09 11:28:21 +08:00
Minor fixes to README
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
`p_tqdm` makes parallel processing with progress bars easy.
|
||||
|
||||
`p_tqdm` is a wrapper around [pathos.multiprocessing](https://github.com/uqfoundation/pathos/blob/master/pathos/multiprocessing.py) and [tqdm](https://github.com/tqdm/tqdm). Unlike Python's default multiprocessing library, pathos provides a more flexible parallel map which can apply almost any type of function -- including lambda functions, nested functions, and class methods -- and can easily handle functions with multiple arguments. tqdm is applied on top of pathos's parallel map and displays a progress bar which includes an estimated time to completion.
|
||||
`p_tqdm` is a wrapper around [pathos.multiprocessing](https://github.com/uqfoundation/pathos/blob/master/pathos/multiprocessing.py) and [tqdm](https://github.com/tqdm/tqdm). Unlike Python's default multiprocessing library, pathos provides a more flexible parallel map which can apply almost any type of function --- including lambda functions, nested functions, and class methods --- and can easily handle functions with multiple arguments. tqdm is applied on top of pathos's parallel map and displays a progress bar including an estimated time to completion.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -43,35 +43,14 @@ added = p_map(add, l1, l2)
|
||||
|
||||
### Parallel maps
|
||||
|
||||
* [`p_map`](#p_map) - parallel ordered map
|
||||
* [`p_imap`](#p_imap) - iterator for parallel ordered map
|
||||
* [`p_umap`](#p_umap) - parallel unordered map
|
||||
* [`p_uimap`](#p_uimap) - iterator for parallel unordered map
|
||||
* [p_map](#p_map) - parallel ordered map
|
||||
* [p_imap](#p_imap) - iterator for parallel ordered map
|
||||
* [p_umap](#p_umap) - parallel unordered map
|
||||
* [p_uimap](#p_uimap) - iterator for parallel unordered map
|
||||
|
||||
### Sequential maps
|
||||
* [`t_map`](#t_map) - sequential ordered map
|
||||
* [`t_imap`](#t_imap) - iterator for sequential ordered map
|
||||
|
||||
### Shared properties
|
||||
|
||||
#### Arguments
|
||||
|
||||
All `p_tqdm` functions accept any number of lists (of the same length) as input, as long as the number of lists matches the number of arguments of the function. Additionally, if any non-list variable is passed as an input to a `p_tqdm` function, the variable will be passed to all calls of the function. See the example below.
|
||||
|
||||
```python
|
||||
l1 = ['1', '2', '3']
|
||||
l2 = ['a', 'b', 'c']
|
||||
|
||||
def add(a, b, c):
|
||||
return a + b + c
|
||||
|
||||
added = p_map(add, l1, l2, '!')
|
||||
# added == ['1a!', '2b!', '3c!']
|
||||
```
|
||||
|
||||
#### CPUs
|
||||
|
||||
All the parallel `p_tqdm` functions can be passed the keyword `num_cpus` to indicate how many CPUs to use. The default is all CPUs. `num_cpus` can either be an integer to indicate the exact number of CPUs to use or a float to indicate the proportion of CPUs to use.
|
||||
* [t_map](#t_map) - sequential ordered map
|
||||
* [t_imap](#t_imap) - iterator for sequential ordered map
|
||||
|
||||
### p_map
|
||||
|
||||
@@ -144,7 +123,6 @@ def add(a, b):
|
||||
return a + b
|
||||
|
||||
added = t_map(add, ['1', '2', '3'], ['a', 'b', 'c'])
|
||||
|
||||
# added == ['1a', '2b', '3c']
|
||||
```
|
||||
|
||||
@@ -163,3 +141,24 @@ iterator = t_imap(add, ['1', '2', '3'], ['a', 'b', 'c'])
|
||||
for result in iterator:
|
||||
print(result) # prints '1a', '2b', '3c'
|
||||
```
|
||||
|
||||
## Shared properties
|
||||
|
||||
### Arguments
|
||||
|
||||
All `p_tqdm` functions accept any number of lists (of the same length) as input, as long as the number of lists matches the number of arguments of the function. Additionally, if any non-list variable is passed as an input to a `p_tqdm` function, the variable will be passed to all calls of the function. See the example below.
|
||||
|
||||
```python
|
||||
l1 = ['1', '2', '3']
|
||||
l2 = ['a', 'b', 'c']
|
||||
|
||||
def add(a, b, c):
|
||||
return a + b + c
|
||||
|
||||
added = p_map(add, l1, l2, '!')
|
||||
# added == ['1a!', '2b!', '3c!']
|
||||
```
|
||||
|
||||
### CPUs
|
||||
|
||||
All the parallel `p_tqdm` functions can be passed the keyword `num_cpus` to indicate how many CPUs to use. The default is all CPUs. `num_cpus` can either be an integer to indicate the exact number of CPUs to use or a float to indicate the proportion of CPUs to use.
|
||||
|
||||
Reference in New Issue
Block a user