-
Notifications
You must be signed in to change notification settings - Fork 21
Correção strict e pequenas melhorias #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst * Updates README.rst
* Fix bug when time series search returned more than one result pages * Fix bug when time series search returned more than one result pages * Fix bug when time series search returned more than one result pages * Fix bug when time series search returned more than one result pages * Fix bug when time series search returned more than one result pages
* fix date parsing when only year is present * fix date parsing when only year is present * fix date parsing when only year is present
… on date time transformation * fix date parsing when only year is present * fix date parsing when only year is present * fix date parsing when only year is present * fix date parsing when only year is present
Rafpyprog develop
Por que aqui os checks do commit f58efb6 passam e depois começam a indicar problemas? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Questões
1. Primeiro, um erro que cometi no PR #32
O referido PR foi elaborado em função da issue #24 .
A questão era que:
Retornava:
A bibiloteca herdava o comportamento da API do SGS e retornava, por padrão, o último valor armazenado para a série. O #32 corrigiu a falha para a situação específica (quando o retorno da função
dataframe
outime_serie
era apenas um registro):Contudo, o comportamento do parametro
strict=True
quando as funções retornam mais de um registro não é o ideal:No meu entendimento, o correto deveria ser:
E a mensagem deve ocorrer apenas nas situações onde não haja nenhum retorno, como por exemplo:
2. Ainda sobre a issue #24 , percebi que a galera usa a função para extrair dados de um único registro. Assim, não seria necessário ter um parâmetro end.
3. Retorno da função metadata vindo com dois tipos distintos
O dicionário resultante dessa função possui duas chaves (
first_value
elast_value
) que retornam ora umTimestamp
ora umastring
. A multiplicidade de tipos retornados pode acarretar dificuldades.Abordagem:
Sobre o item 1:
Criação de um arquivo específico (
strict.py
) para a funçãoconstrain
.A função tem três parâmetros:
data, start, end
.É, basicamente, um filtro por data que garante as mensagens informativas ao usuário.
Ela está por trás da funcionalidade
strict
datime_serie
e dodataframe
.Da forma como está implementada a função, também é possível aplicar a uma
time_serie
oudataframe
já constituídos.Ex.:
Essa implementação levou a eliminação da função
get_data_with_strict_range
e a simplificação do moduloapi.py
Sobre o item 2:
O parametro
end
das funçõestime_serie
edataframe
foram transformados em opcionais.e
Sobre o item 3:
Foram alterados os arquivos
metadata.py
e osearch.py
.Primeiramente, a função metadata foi alterada para receber
time_serie, list
etuple
.Em segundo lugar, foi criada uma expansão da função
to_datetime
do modulocommon.py
: ato_datetime_string
, que retorna sempre umastring
.Ainda dentro do modulo
common.py
, foi criada uma função auxiliar, chamadaget_series_codes
, para gerar uma lista dos códigos das séries a partir de variaveis do tipoint, list, tuple, df
eseries
.Por fim, e com base nas alterações acima, foram implementadas algumas refatorações nos seguintes modulos:
As alterações não modificam o comportamento atual da biblioteca, apenas acrescentam funcionalidades. Apenas o tipo dos campos de data do dicionário retornado pela função
metadata
passam a serstring
. Mas, como trata-se de metadata, creio que não tenha grande impacto.Por último, foram desenvolvidos testes para as novas funcionalidades.
Se vocês acharem necessário, posso quebrar esse PR em menores para facilitar a análise.