Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

FormatError es2 [PROF]

alessioclemente (19640 points)
16 67 153
in Es2 by (19.6k points)
edited by
Nei test di aggiungi corretto, mi da format error, qualcuna sa cosa sia?
725 views
closed

4 Answers

Best answer
daniel.f (1750 points)
4 20 34
by (1.8k points)
selected by
Io ho risolto riazzerando la matrice prima di crearla perché il test fa diverse chiamate quindi se non la riporti a 0 sovrapponi più matrici
_andrea_ (45670 points)
11 42 297
by (45.7k points)
In che modo lo dà?
Xriuk (13590 points)
6 24 116
by (13.6k points)
Potresti postare il log completo magari? (non serve il tuo codice)
alessioclemente (19640 points)
16 67 153
by (19.6k points)
test_02.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_02.py:43: in do_test
    self.check_img_file(f1, f2)
testlib.py:66: in check_img_file
    img_a = self.__image_load(a)
testlib.py:53: in __image_load
    for png_row in png_img:
png.py:1708: in iterstraight
    recon = self.undo_filter(filter_type, scanline, recon)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <png.Reader object at 0x000001659DD273C8>, filter_type = 255
scanline = array('B', [0, 0, 255, 0, 0, ...])
previous = array('B', [255, 0, 0, 255, 0, ...])

    def undo_filter(self, filter_type, scanline, previous):
        """Undo the filter for a scanline.  `scanline` is a sequence of
            bytes that does not include the initial filter type byte.
            `previous` is decoded previous scanline (for straightlaced
            images this is the previous pixel row, but for interlaced
            images, it is the previous scanline in the reduced image, which
            in general is not the previous pixel row in the final image).
            When there is no previous scanline (the first row of a
            straightlaced image, or the first row in one of the passes in an
            interlaced image), then this argument should be ``None``.

            The scanline will have the effects of filtering removed, and the
            result will be returned as a fresh sequence of bytes.
            """

        # :todo: Would it be better to update scanline in place?
        # Yes, with the Cython extension making the undo_filter fast,
        # updating scanline inplace makes the code 3 times faster
        # (reading 50 images of 800x800 went from 40s to 16s)
        result = scanline

        if filter_type == 0:
            return result

        if filter_type not in (1,2,3,4):
>           raise FormatError('Invalid PNG Filter Type.'
              '  See http://www.w3.org/TR/2003/REC-PNG-20031110/#9Filters .')
E           png.FormatError: FormatError: Invalid PNG Filter Type.  See http://www.w3.org/TR/2003/REC-PNG-20031110/#9Filters .

png.py:1498: FormatError
a.capobianco1 (16770 points)
11 54 165
by (16.8k points)
Sembra quasi che tu stia tentando di salvare un'immagine non valida oppure inesistente...
alessioclemente (19640 points)
16 67 153
by (19.6k points)
faccio solo immagini.save(self.im,fimg)  su salva...
Xriuk (13590 points)
6 24 116
by (13.6k points)
A me sembra un errore del tester, così come lo hai postato, in quanto il filtro indicato (255) non è fra quelli validi (1, 2, 3, 4). A meno che il tutto non sia circondato da un'altro errore. Magari hai qualche errore durante il salvataggio dell'immagine. Oppure prova a riscaricare il file .zip e sostituisci i tester.
alessioclemente (19640 points)
16 67 153
by (19.6k points)
Questo errore purtroppo c'è anche sulla macchina virtuale, e se non lo risolvo non posso fare gli altri test :/
alessioclemente (19640 points)
16 67 153
by (19.6k points)
E non capisco proprio perché, cioè magari il metodo aggiungi sarà pure sbagliato, ma nel caso sarebbe un problema di pixel, boh
Xriuk (13590 points)
6 24 116
by (13.6k points)
@alessioclemente Descrivici cosa fai nel metodo aggiungi, magari c'è un errore lì
alessioclemente (19640 points)
16 67 153
by (19.6k points)
edited by
Scorro tutti i miei rettangoli, e ricreo l'immagine da capo. In base alle varie condizioni (supera x, x più base maggiore di larghezza, altezza superata) creo l'immagine in modo diverso
Xriuk (13590 points)
6 24 116
by (13.6k points)
Prova a creare uno skyline da solo e aggiungici uno o più rettangoli (piccoli), controlla poi la matrice di pixel per vedere se è corretta.
alessioclemente (19640 points)
16 67 153
by (19.6k points)
Si, è corretta, ma anche se fosse sbagliata, sarebbe un problema di pixel messi male e il tester me lo direbbe, per questo qui non do dove mettere mano
K
Khalester (3310 points)
2 5 24
by (3.3k points)
Se stai parlando del test aggiungi_skyline_corretto, credo che ad un certo punto il test chiami il metodo salva. Ed è in questo punto che accade il bug: infatti il metodo salva consiste nel passarti un nome con cui salvare l'immagine. Nel caso quest'ultimo non fosse un nome che finisce con ".png", si crea questo errore.
Per fixare basta soltanto mettere il controllo al formato del nome che viene passato.
alessioclemente (19640 points)
16 67 153
by (19.6k points)
Ho già questo controllo :/
K
Khalester (3310 points)
2 5 24
by (3.3k points)
Uhm hai controllato se funziona? Magari hai preso una parte sbagliata di stringa?
andrea.sterbini (207920 points)
750 1267 2373
by (208k points)
Visto che i test precedenti li passi l'errore dovrebbe essere in quello che fai nel primo test che sbaglia.
Prova a leggere il file della immagine attesa e confrontare quei dati con quelli che stai per salvare.
alessioclemente (19640 points)
16 67 153
by (19.6k points)
Prof, è possibile avere tutti gli input che da il mio test sbagliato? Almeno provo a farlo a mano e debuggarlo. Dal test non riesco a capire quali siano