From d0f999cfd7ea63eaffb52bac709271a546e89c1c Mon Sep 17 00:00:00 2001 From: Steven Tendyra Date: Thu, 21 Mar 2024 14:32:19 +0000 Subject: [PATCH] readme add --- README.md | 28 +++++++++++------ examples.ipynb | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ mypy_tutorial.py | 41 ++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 10 deletions(-) create mode 100644 examples.ipynb create mode 100644 mypy_tutorial.py diff --git a/README.md b/README.md index 554413f2..4924f947 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,25 @@ -# Introduction +# Rivercatch +![Continuous Integration build in GitHub Actions](https://github.com//python-intermediate-catchment/workflows/CI/badge.svg?branch=main) -This is a template software project repository used by the Earth Science focused [Intermediate Research Software Development Skills In Python](https://carpentries-incubator.github.io/python-intermediate-development-earth-sciences) course. +RiverCatch is a data management system written in Python that manages measurement data collected in river catchment surveys and campaigns. -## Purpose +## Main Features +Here are some key features of Inflam: -This repository is intended to be used as a code template which is copied by learners at [Intermediate Research Software Development Skills In Python](https://carpentries-incubator.github.io/python-intermediate-development-earth-sciences) workshops. -This can be done using the `Use this template` button towards the top right of this repo's GitHub page. +- Provide basic statistical analyses of data +- Ability to work on measurement data in Comma-Separated Value (CSV) format +- Generate plots of measurement data +- Analytical functions and views can be easily extended based on its Model-View-Controller architecture -This software project is not finished, is currently failing to run and contains some code style issues. It is used as a starting point for the course - issues will be fixed and code will be added in a number of places during the course by learners in their own copies of the repository, as course topics are introduced. +## Prerequisites +RiverCatch requires the following Python packages: -## Tests +- [NumPy](https://www.numpy.org/) - makes use of NumPy's statistical functions +- [Pandas](https://pandas.pydata.org/) - makes use of Panda's dataframes +- [GeoPandas](https://geopandas.org/) - makes use of GeoPanda's spatial operations +- [Matplotlib](https://matplotlib.org/stable/index.html) - uses Matplotlib to generate statistical plots -Several tests have been implemented already, some of which are currently failing. -These failing tests set out the requirements for the additional code to be implemented during the workshop. +The following optional packages are required to run RiverCatch's unit tests: -The tests should be run using `pytest`, which will be introduced during the workshop. +- [pytest](https://docs.pytest.org/en/stable/) - RiverCatch's unit tests are written using pytest +- [pytest-cov](https://pypi.org/project/pytest-cov/) - Adds test coverage stats to unit testing \ No newline at end of file diff --git a/examples.ipynb b/examples.ipynb new file mode 100644 index 00000000..97d7e653 --- /dev/null +++ b/examples.ipynb @@ -0,0 +1,82 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import pandas.testing as pdt\n", + "from catchment.models import daily_mean\n", + "import datetime\n", + "import pytest" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "test_input = pd.DataFrame(\n", + " data=[[1.0, 2.0],\n", + " [3.0, 4.0],\n", + " [5.0, 6.0]],\n", + " index=[pd.to_datetime('2000-01-01 01:00'),\n", + " pd.to_datetime('2000-01-01 02:00'),\n", + " pd.to_datetime('2000-01-01 03:00')],\n", + " columns=['A', 'B']\n", + ")\n", + "test_result = pd.DataFrame(\n", + " data=[[3.0, 4.0]],\n", + " index=[datetime.date(2000, 1, 1)],\n", + " columns=['A', 'B']\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [], + "source": [ + "test_output = pd.DataFrame(\n", + " data=[[3.0, 3.0]],\n", + " index=[datetime.date(2000, 1, 1)],\n", + " columns=['A', 'B'] \n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [], + "source": [ + "pdt.assert_frame_equal(daily_mean(test_input), test_result)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/mypy_tutorial.py b/mypy_tutorial.py new file mode 100644 index 00000000..06394707 --- /dev/null +++ b/mypy_tutorial.py @@ -0,0 +1,41 @@ +from typing import Union + +flag : bool = True + +def greet(name : str) -> None: + """Say hello to everyone""" + print("Hi " + name) + +greet("Manchester") +greet("Steven") + +def myAbs(x : float) -> float: + """Take the absolute of the floating-point input""" + if x < 0: + return (-x) + else: + return (x) + + +myAbs(12) + +def greetAll(names : list[str]) -> None: + for name in names: + greet(name) + +greetAll(["Alice", "John", "Joe"]) + +#greetAll([12, 12]) + +some_data : tuple[int, bool, str] = (41, True, "Manchester") +#some_other_data : tuple[int, bool, str] = (41, 232132, "Manchester") + +def myDiv(x : float, y : float) -> Union[float, None]: + if y != 0: return x/y + else: return None + + +myDict : dict[str, Union[float, str]] = {"temp": 273.0, "units": "Kelvin"} + +#reveal_type(len) +