Skip to content

Commit

Permalink
Coverage (#12)
Browse files Browse the repository at this point in the history
* Added sphinx-design package install to docs workflow

* Changed scardb docs and added coverage

* Updated workflows

* Updated workflows

* Updated workflows
  • Loading branch information
nikothomas authored Aug 8, 2024
1 parent a58c731 commit ccbf8bb
Show file tree
Hide file tree
Showing 16 changed files with 280 additions and 248 deletions.
43 changes: 19 additions & 24 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
name: Test
name: Testing

on:
pull_request:
branches:
- "**"
branches: [main]
push:
branches: [main]

jobs:
test-python:
run-with-coverage:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Python 3.12
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
python-version: '3.12'

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry
curl -sSL https://install.python-poetry.org | python3 -
poetry config virtualenvs.in-project true
- name: Install dependencies
run: poetry install
run: |
poetry install
- name: Run tests
- name: Run tests with coverage
run: |
poetry run pytest --junitxml=junit.xml || {
if [ $? -eq 5 ]; then
echo 'Did not find any tests to run.';
else
exit 1;
fi
}
- name: Store test results
if: success() || failure()
poetry run pytest --cov=ctdfjorder --cov-report=html
- name: Upload coverage report as artifact
if: success() # This step will only run if previous steps succeeded
uses: actions/upload-artifact@v3
with:
name: junit-results
path: junit.xml
name: coverage-report
path: htmlcov
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![CircleCI](https://dl.circleci.com/status-badge/img/circleci/BqQeY7gNQzLD7veRpM5Fpj/4nijPG3CZqyE8SAoqtPWZr/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/circleci/BqQeY7gNQzLD7veRpM5Fpj/4nijPG3CZqyE8SAoqtPWZr/tree/main)
![Tests](https://github.com/nikothomas/ctdfjorder/actions/workflows/tests.yml/badge.svg?branch=main)
[![PyPI version](https://badge.fury.io/py/ctdfjorder.svg)](https://badge.fury.io/py/ctdfjorder)

<p style=text-align:center;>
Expand Down
1 change: 1 addition & 0 deletions ctdfjorder/CTD.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ def clean(self, method) -> None:
See Also
--------
_AI.clean_salinity_ai : Method used to clean salinity with 'clean_salinity_ai' option.
"""
for profile_id in (
self._data.select(PROFILE_ID_LABEL)
Expand Down
6 changes: 5 additions & 1 deletion ctdfjorder/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class Mastersheet(Warning):
def __init__(self, message):
self.message = message

class SCARDatabase(Warning):
def __init__(self, message):
self.message = message


class Calculation(Warning):
def __init__(self, message):
Expand Down Expand Up @@ -105,5 +109,5 @@ def raise_warning_site_location(message, filename=None):
message : str
Explanation of the error.
"""
warnings.warn(message=f"{filename} - {message}", category=Mastersheet)
warnings.warn(message=f"{filename} - {message}", category=SCARDatabase)
logger.warning(f"{filename} - {message}")
8 changes: 4 additions & 4 deletions ctdfjorder/scardb/scardb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from ctdfjorder.dataclasses.dataclasses import SitesDatabase, ResearchSite
import polars as pl
from ctdfjorder.exceptions.exceptions import raise_warning_site_location
from ctdfjorder.exceptions.exceptions import raise_warning_site_location, SCARDatabase


def generate_sites_database(site_names: list[str]) -> SitesDatabase:
Expand Down Expand Up @@ -31,9 +31,9 @@ def generate_sites_database(site_names: list[str]) -> SitesDatabase:
>>> site_names = ['Site A', 'Site B', 'Site C']
>>> database = generate_sites_database(site_names)
>>> print(database)
SitesDatabase with 3 sites
# SitesDatabase with 3 sites
Details
Notes
-------
- The function uses Levenshtein distance to compute similarities between site names.
- It reads data from SCAR datasets stored in Parquet files.
Expand All @@ -43,7 +43,7 @@ def generate_sites_database(site_names: list[str]) -> SitesDatabase:
Raises
------
Warning
SCARDatabase
If a provided site name does not match exactly or similarly with any site name in the SCAR datasets.
"""
Expand Down
8 changes: 2 additions & 6 deletions docs/API.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
API Documentation
=================

Welcome to the **CTDFjorder API** documentation! This section provides a detailed overview of the various modules, classes, and functions available in the CTDFjorder library. Use the navigation below to explore the different components of the API.

Introduction
------------

The CTDFjorder API is organized into several modules, each focused on specific functionality. Below is a brief overview of what each module offers:
Welcome to the CTDFjorder API documentation! This section provides a detailed overview of the various modules, classes, and functions available in the CTDFjorder library. Use the navigation below to explore the different components of the API.

+----------------------+-----------------------------------------------------------------------------------------+
| Module | Description |
Expand Down Expand Up @@ -38,6 +33,7 @@ The CTDFjorder API is organized into several modules, each focused on specific f
.. toctree::
:maxdepth: 2
:caption: Contents
:hidden:

AI
CLI
Expand Down
2 changes: 1 addition & 1 deletion docs/SCAR Database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ SCAR Database
This function uses the USA, UK, Argentina, and Chile `SCAR Gazetteer Database <https://data.aad.gov.au/aadc/gaz/scar/>`__
for site information.

.. automodule:: ctdfjorder.scardb
.. automodule:: ctdfjorder.scardb.scardb
:members:
44 changes: 44 additions & 0 deletions docs/_templates/changelog.rst.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% if render_title %}
{% if versiondata.name %}
{{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }})
{{ top_underline * ((versiondata.name + versiondata.version + versiondata.date)|length + 4)}}
{% else %}
{{ versiondata.version }} ({{ versiondata.date }})
{{ top_underline * ((versiondata.version + versiondata.date)|length + 3)}}
{% endif %}
{% endif %}
{% for section, _ in sections.items() %}
{% set underline = underlines[0] %}{% if section %}{{section}}
{{ underline * section|length }}{% set underline = underlines[1] %}

{% endif %}

{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section]%}
{{ definitions[category]['name'] }}
{{ underline * definitions[category]['name']|length }}

{% if definitions[category]['showcontent'] %}
{% for text, values in sections[section][category].items() %}
- {{ text }}
{{ values|join(',\n ') }}
{% endfor %}

{% else %}
- {{ sections[section][category]['']|join(', ') }}

{% endif %}
{% if sections[section][category]|length == 0 %}
No significant changes.

{% else %}
{% endif %}

{% endfor %}
{% else %}
No significant changes.


{% endif %}
{% endfor %}
----
21 changes: 6 additions & 15 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
*********
Changelog
*********
*************
**Changelog**
*************

.. towncrier release notes start
CTDFjorder 0.6.2 (2024-08-08)
CTDFjorder 0.7.0 (2024-08-08)
=============================

Backward incompatible changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Changed add_bf_squared to add_brunt_vaisala_squared (#9)


Miscellaneous
^^^^^^^^^^^^^

- Updated docs tutorial for R users (#9)

- Added changelogs :)

Features
^^^^^^^^

- Added new methods for calculating derived variables in the CTD class (#9)

----

Check failure on line 17 in docs/changelog.rst

View workflow job for this annotation

GitHub Actions / pages

Document may not end with a transition. [docutils]
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
project = 'CTDFjorder'
copyright = '2024, Nikolas Yanek-Chrones'
author = 'Nikolas Yanek-Chrones'
release = '0.6.2'
release = '0.7.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand All @@ -33,6 +33,8 @@
"content_footer_items": ["last-updated"],
"use_edit_page_button": True,
"navbar_align": "left",
"footer_start": ["copyright"],
"footer_end": [],
"icon_links": [
{
# Label for this link
Expand Down
4 changes: 2 additions & 2 deletions docs/developers.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CTDFjorder for Developers
=========================
Developers
==========

Welcome to the **CTDFjorder** documentation! This guide will help you get started with using the CTDFjorder library,
designed to process and analyze CTD (Conductivity, Temperature, Depth) data efficiently.
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ References
Getting Started
researchers
developers
API
API
changelog
8 changes: 4 additions & 4 deletions docs/researchers.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CTDFjorder for Researchers
==========================
Researchers
===========

Welcome to the **CTDFjorder** documentation! This guide will help you get started with using the CTDFjorder library,
designed to process and analyze CTD (Conductivity, Temperature, Depth) data efficiently.
Expand All @@ -23,8 +23,8 @@ Getting Started

If you're new to **CTDFjorder**, we recommend starting with the :doc:`Getting Started` guide. It provides a
comprehensive introduction to the library, including installation instructions, basic usage examples,
and an overview of the key features. If you'd prefer to create scripts in Python or R using CTDFjorder then visit
:doc:`developers`
and an overview of the key features. If you'd prefer to create scripts in Python or R using CTDFjorder then visit the
:doc:`developers` page.

Command-Line Interface (CLI)
----------------------------
Expand Down
Loading

0 comments on commit ccbf8bb

Please sign in to comment.