This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
2,502 additions
and
382 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
|
||
.. blogpost:: | ||
:title: Javascript et traitement de données | ||
:keywords: | ||
:date: 2016-09-24 | ||
:categories: programmation, javascript | ||
:lid: blog-js-data | ||
|
||
Un des candidats a une forte préférence pour le Javascript | ||
et son premier réflexe est d'utiliser ce langage très utilisé | ||
pour tout ce qui est graphique. Comme éditeur, il utilise | ||
`Atom <https://atom.io/>`_ que je m'empresse d'essayer à mon tour. | ||
Il traite les données en JSON car ce format est le plus adéquat pour ce langage. | ||
Le site `learnjsdata <http://learnjsdata.com/>`_ guide les programmeurs | ||
vers l'utilisation du javascript pour traiter les données. | ||
Il existe des librairies qui implémentent les dataframe | ||
comme `jsdataframe <https://github.com/osdat/jsdataframe>`_. | ||
Le navigateur execute le javascript excepté si un serveur est requis. | ||
Dans ce cas, la solution est d'utiliser un plugin | ||
`Chrome <https://www.google.com/chrome/>`_ : | ||
`Web Server for Chrome <https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?hl=en>`_. | ||
`Chrome <https://www.google.com/chrome/>`_ reste le navigateur préféré des dévelopeurs. | ||
Autre option `http-static <https://www.npmjs.com/package/http-static>`_. | ||
|
||
Côté graph, `d3.js <https://d3js.org/>`_ reste un standard mais un peu ardu au premier abord. | ||
Il faut regarder du côté de `c3.js <http://c3js.org/>`_ | ||
ou plus simple encore `morris.js <http://morrisjs.github.io/morris.js/>`_. | ||
Une dernière astuce, pour des graphes plus élaborés, presque des peintures, | ||
il faut se tourner vers `InkScape <https://inkscape.org/en/>`_ et exporter | ||
son dessin en `SVG <https://en.wikipedia.org/wiki/Scalable_Vector_Graphics>`_. | ||
A partir de là, on peut le retravailler avec `d3.js <https://d3js.org/>`_. | ||
`dc.js <https://dc-js.github.io/dc.js/>`_ a l'air assez doué pour lier les graphes | ||
entre eux et les faire interagir. | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
Timeseries - Séries temporelles | ||
=============================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
ml_timeseries_base |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
""" | ||
@brief test log(time=3s) | ||
""" | ||
|
||
import sys | ||
import os | ||
import unittest | ||
import warnings | ||
|
||
|
||
try: | ||
import src | ||
except ImportError: | ||
path = os.path.normpath( | ||
os.path.abspath( | ||
os.path.join( | ||
os.path.split(__file__)[0], | ||
"..", | ||
".."))) | ||
if path not in sys.path: | ||
sys.path.append(path) | ||
import src | ||
|
||
try: | ||
import pyquickhelper as skip_ | ||
except ImportError: | ||
path = os.path.normpath( | ||
os.path.abspath( | ||
os.path.join( | ||
os.path.split(__file__)[0], | ||
"..", | ||
"..", | ||
"..", | ||
"pyquickhelper", | ||
"src"))) | ||
if path not in sys.path: | ||
sys.path.append(path) | ||
import pyquickhelper as skip_ | ||
|
||
try: | ||
import pyensae as skip__ | ||
except ImportError: | ||
path = os.path.normpath( | ||
os.path.abspath( | ||
os.path.join( | ||
os.path.split(__file__)[0], | ||
"..", | ||
"..", | ||
"..", | ||
"pyensae", | ||
"src"))) | ||
if path not in sys.path: | ||
sys.path.append(path) | ||
import pyensae as skip__ | ||
|
||
from pyquickhelper.loghelper import fLOG | ||
from pyquickhelper.pycode import get_temp_folder | ||
from src.ensae_teaching_cs.data import google_trends | ||
|
||
|
||
class TestDataWeb(unittest.TestCase): | ||
|
||
def test_google_trends_macron(self): | ||
fLOG( | ||
__file__, | ||
self._testMethodName, | ||
OutputPrint=__name__ == "__main__") | ||
|
||
temp = get_temp_folder(__file__, "temp_google_trends_macron") | ||
text = google_trends(local=True, filename=False) | ||
assert text is not None | ||
|
||
name = google_trends(local=True, filename=True) | ||
assert name.endswith("macron.csv") | ||
|
||
try: | ||
text2 = google_trends( | ||
local=False, cache_folder=temp, filename=False) | ||
except ConnectionResetError as e: | ||
warnings.warn("Cannot check remote marathon.txt.\n" + str(e)) | ||
return | ||
|
||
assert text2 is not None | ||
self.assertEqual(len(text), len(text2)) | ||
self.maxDiff = None | ||
self.assertEqual(text, text2) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
@file | ||
@brief Helpers to get data including in the module itself. | ||
""" | ||
import os | ||
|
||
|
||
def any_local_file(name, subfolder, local=True, cache_folder=".", filename=True): | ||
""" | ||
Returns a local data file, reads its content or returns its content. | ||
@param name file to download | ||
@param subfolder sub folder | ||
@param local local data or web | ||
@param cache_folder where to cache the data if downloaded a second time | ||
@param filename return the filename (True) or the content (False) | ||
@return text content (str) | ||
""" | ||
if local: | ||
this = os.path.abspath(os.path.dirname(__file__)) | ||
this = os.path.join(this, subfolder, name) | ||
if not os.path.exists(this): | ||
raise FileNotFoundError(this) | ||
else: | ||
import pyensae | ||
this = pyensae.download_data(name, whereTo=cache_folder) | ||
if filename: | ||
return this | ||
else: | ||
with open(this, "r") as f: | ||
return f.read() |
Empty file.
Oops, something went wrong.