Keys method with (dotted=True) gives multiplication of the same key
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
Direzione di ricerca
Inizia dal punto di ingresso Box.keys(dotted=True) e riproduci l’esempio dell’issue, confrontando i percorsi restituiti per i mappings e i valori di lista. Segui il motivo per cui gli elementi delle liste producono percorsi indicizzati, quindi verifica che il risultato contenga solo le chiavi padre: Animals.Land_animals, Animals.Sea_animals e Trees.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug of keys in Box:
When you use keys() method in a "dotted" situation, meaning we have a tree of keys in a Box, and you want to get the keys of a given node, one can notice that we get back a list of keys that are multiplicated if the value of a key is a list. (and the multiplication is by the lengh of the list)
For example:
b = Box({
"Animals" : {"Land_animals" : ["Lion", "Elephant"], "Sea_animals" : ["Dolphin", "Shark"]},
"Trees" : ["Palm_tree", "Coconut_tree"]
}, box_dots = True)
When you are using keys = b.keys(dotted = True) you get -
['Animals.Land_animals[0]',
'Animals.Land_animals[1]',
'Animals.Sea_animals[0]',
'Animals.Sea_animals[1]',
'Trees[0]',
'Trees[1]']
and we can see the multiple occurances of the keys (with indexes of their number of values), and the method len(keys) would have wrong answer - 6 instead of 3.
The output which I thought would be right is: ['Animals.Land_animals', 'Animals.Sea_animals', 'Trees']
A workaround is to add to the box this:
box_intact_types = (tuple,list)
so that lists wouldn't be converted, and than it works fine.
- Lingua principale
- Python
- Stelle
- 2.8k
- Fork
- 145
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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 cdgriffith/Box
-
subclass of `Box` does not unpickle correctlyForse già presa @koriyoshi2041 l’ha presa 142 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
cdgriffith/Box#308 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
cdgriffith/Box#307 · 1 commento ·
-
Dotted keys read from YAML are lost with box_dots / default_boxForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
cdgriffith/Box#305 ·
-
[Bug] Camel killer box and box dots gives unexpected behaviourForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 30/100
cdgriffith/Box#300 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
cdgriffith/Box#298 ·
Tutte le issue di cdgriffith/Box
Issue simili
-
tunneld on Windows: Wi-Fi devices are not discovered because uvicorn runs on a ProactorEventLoopAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
doronz88/pymobiledevice3#2051 ·
I maintainer di solito rispondono entro 1 giorno
-
Remove DatacircleAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
collabnix/awesome-mcp-lists#230 ·
I maintainer di solito rispondono entro 9 giorni
-
Groc schedules with out of range values pass config validation and fail later when the scheduler is builtForse già presa @auraseb l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
autowarefoundation/autoware_carla_scenario#342 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ianktoo/project-monitor#14 ·