Is there a way to deal with variable sized iterables?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 40/100
Direzione di ricerca
Inizia individuando l’implementazione di progress_bar e la riga self.total = len(gen) if total is None else total descritta nell’issue. Riproduci l’esempio di Timer fornito, quindi determina come rappresentare gli iterable di dimensioni variabili o l’iterazione basata sul tempo; il lavoro è completo quando la barra di avanzamento può gestire questo caso d’uso senza presumere una lunghezza fissa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The problem is this line:
self.total = len(gen) if total is None else total
That is executed at the beginning. But len(gen) might change throughout the iteration, but progress_bar just assumes it keeps still.
What I really want is to use a timer (so "train for 1 hour" instead of "train for so and so epochs").
import time
class Timer:
def __init__(self, num_seconds):
self.num_seconds = num_seconds
self.i = None
def __len__(self):
if self.i is None: return 1
eps = 1e-7
t = time.time() - self.start
progress = t/num_seconds
return int((num_seconds*self.i)/(progress+eps)) # estimated size. Changes constantly.
def __iter__(self):
self.start = time.time()
self.i, t = 0, 0.0
while t <= self.num_seconds:
t = time.time() - self.start
self.i += 1
yield None
With this class, if you write
for t in Timer(3.0):
# do stuff
it runs for 3 seconds. But it doesn't work with the progress_bar :(
- Lingua principale
- Jupyter Notebook
- Stelle
- 1.1k
- Fork
- 103
- Merge medio
- 1m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AnswerDotAI/fastprogress
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
AnswerDotAI/fastprogress#124 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
AnswerDotAI/fastprogress#121 · 2 reazioni ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
AnswerDotAI/fastprogress#117 · 4 commenti · 12 reazioni ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
AnswerDotAI/fastprogress#111 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
AnswerDotAI/fastprogress#107 ·
Tutte le issue di AnswerDotAI/fastprogress
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 commento ·
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
rust-bitcoin/rust-bitcoin#6930 · 1 commento ·
-
Solved site promotion gate fails on runner PHP patch drift (expects 8.2.33, runner installs 8.2.34) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Automattic/blocks-engine#2161 ·