Skip to content

Commit

Permalink
Get docsring examples running
Browse files Browse the repository at this point in the history
  • Loading branch information
vergauwenthomas committed Sep 2, 2024
1 parent be1e7aa commit 6de8751
Show file tree
Hide file tree
Showing 29 changed files with 1,029 additions and 583 deletions.
7 changes: 6 additions & 1 deletion deploiment/run_doctests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ cd ${DEPLOY_DIR}
cd .. #Navigate to workdir
WORKDIR=$(pwd)
LOGDIR=${DEPLOY_DIR}/logs
BIGLOGFILE=${LOGDIR}/all_log

#clear big log file
rm -f ${BIGLOGFILE}

#clear all specific log files
rm ${LOGDIR}/DOCtest_output_*_log


Expand All @@ -24,7 +29,7 @@ for t in $modules; do
module_file=${WORKDIR}/metobs_toolkit/${t}
echo "Running doctests in ${module_file}"

python3 -m doctest -o ELLIPSIS -o NORMALIZE_WHITESPACE ${module_file} | tee ${LOGDIR}/DOCtest_output_${t:2:-3}_log
python3 ${module_file} 2>&1 | tee -a ${LOGDIR}/DOCtest_output_${t:2:-3}_log ${BIGLOGFILE}
done

rm ${WORKDIR}/*.pkl #created by doctest
Expand Down
3 changes: 1 addition & 2 deletions docs/build_doc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
rm -r _build/*
rm -r _autosummary/*


#sphinx-autogen index.rst



cd ..



sphinx-build -a -E -v docs/ docs/_build/

cd docs
278 changes: 171 additions & 107 deletions metobs_toolkit/analysis.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions metobs_toolkit/data_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,12 @@ class MetobsDataImportError(Exception):
"""Exception raised for errors on importing Data."""

pass


# =============================================================================
# Docstring test
# =============================================================================
if __name__ == "__main__":
from metobs_toolkit.doctest_fmt import setup_and_run_doctest

setup_and_run_doctest()
54 changes: 15 additions & 39 deletions metobs_toolkit/dataset_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def import_dataset(self, folder_path=None, filename="saved_dataset.pkl"):
>>> import os
>>> # Import the dataset
>>> dataset=empty_dataset.import_dataset(folder_path=os.getcwd(),
... filename='your_saved_dataset.pkl')
... filename='your_saved_dataset.pkl') # doctest: +SKIP
"""
# check if folder_path is known and exists
Expand Down Expand Up @@ -886,6 +886,7 @@ def get_station(self, stationname):
*0 gaps
*records range: 2022-09-01 00:00:00+00:00 --> 2022-09-15 23:55:00+00:00 (total duration: 14 days 23:55:00)
*time zone of the records: UTC
*Known GEE datasets for: ['lcz', 'altitude', 'worldcover', 'ERA5-land']
*Coordinates are available for all stations.
"""
Expand Down Expand Up @@ -1186,30 +1187,13 @@ def coarsen_time_resolution(
vlinder03 0 days 00:05:00
vlinder04 0 days 00:05:00
vlinder05 0 days 00:05:00
vlinder06 0 days 00:05:00
vlinder07 0 days 00:05:00
vlinder08 0 days 00:05:00
vlinder09 0 days 00:05:00
vlinder10 0 days 00:05:00
vlinder11 0 days 00:05:00
vlinder12 0 days 00:05:00
vlinder13 0 days 00:05:00
vlinder14 0 days 00:05:00
vlinder15 0 days 00:05:00
vlinder16 0 days 00:05:00
vlinder17 0 days 00:05:00
vlinder18 0 days 00:05:00
vlinder19 0 days 00:05:00
vlinder20 0 days 00:05:00
vlinder21 0 days 00:05:00
vlinder22 0 days 00:05:00
vlinder23 0 days 00:05:00
...
vlinder24 0 days 00:05:00
vlinder25 0 days 00:05:00
vlinder26 0 days 00:05:00
vlinder27 0 days 00:05:00
vlinder28 0 days 00:05:00
Name: dataset_resolution, dtype: timedelta64[ns]
Name: dataset_resolution, Length: 28, dtype: timedelta64[ns]
We can coarsen the time resolution to 15 minutes with a maximum
allowd timestamp shift of 4 minutes.
Expand All @@ -1223,30 +1207,13 @@ def coarsen_time_resolution(
vlinder03 0 days 00:15:00
vlinder04 0 days 00:15:00
vlinder05 0 days 00:15:00
vlinder06 0 days 00:15:00
vlinder07 0 days 00:15:00
vlinder08 0 days 00:15:00
vlinder09 0 days 00:15:00
vlinder10 0 days 00:15:00
vlinder11 0 days 00:15:00
vlinder12 0 days 00:15:00
vlinder13 0 days 00:15:00
vlinder14 0 days 00:15:00
vlinder15 0 days 00:15:00
vlinder16 0 days 00:15:00
vlinder17 0 days 00:15:00
vlinder18 0 days 00:15:00
vlinder19 0 days 00:15:00
vlinder20 0 days 00:15:00
vlinder21 0 days 00:15:00
vlinder22 0 days 00:15:00
vlinder23 0 days 00:15:00
...
vlinder24 0 days 00:15:00
vlinder25 0 days 00:15:00
vlinder26 0 days 00:15:00
vlinder27 0 days 00:15:00
vlinder28 0 days 00:15:00
Name: dataset_resolution, dtype: timedelta64[ns]
Name: dataset_resolution, Length: 28, dtype: timedelta64[ns]
"""

Expand Down Expand Up @@ -1709,3 +1676,12 @@ class MetobsDatasetError(Exception):
"""Exception raised for errors in the template."""

pass


# =============================================================================
# Docstring test
# =============================================================================
if __name__ == "__main__":
from metobs_toolkit.doctest_fmt import setup_and_run_doctest

setup_and_run_doctest()
Loading

0 comments on commit 6de8751

Please sign in to comment.