Skip to content

Commit

Permalink
Add logo, run doctests as well in CI, other minor polishes for release
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitan94 committed Jun 2, 2020
1 parent 0f1619f commit 93327a0
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 14 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ jobs:
shell: bash -l {0}
run: cmake --build build --config $BUILD_TYPE

- name: Test
- name: Run Unit Tests
working-directory: ${{runner.workspace}}/daylight/build
shell: bash -l {0}
run: ctest --output-on-failure -C $BUILD_TYPE

- name: Run Doctests
working-directory: ${{runner.workspace}}/daylight
shell: bash -l {0}
run: cmake --build build --config $BUILD_TYPE --target pydoctest
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
![Test Status](https://github.com/adonmo/daylight/workflows/Tests/badge.svg)

daylight
========
<p align="center">
<img src="static/logo.png" width="300">
</p>
<p align="center">
<a href="https://github.com/adonmo/daylight/actions">
<img src="https://github.com/adonmo/daylight/workflows/Tests/badge.svg/" alt="Tests Status">
</a>
</p>

daylight or libdaylight is a library which enables you to answer daylight related questions like:

Expand All @@ -28,7 +32,7 @@ $ pip install git+https://github.com/adonmo/daylight

The examples directory contains a real world usage of this library at [Adonmo](https://www.adonmo.com) - for its season and location independent brightness control mechanism: [Click here](/examples/adonmo-daylight-brightness-control.ipynb) to read it.

![Adonmo brightness control mechanism using daylight](/examples/adonmo-daylight-brightness-control.png)
![Adonmo brightness control mechanism using daylight](/static/adonmo-daylight-brightness-control.png)

# Usage (Python)

Expand Down
7 changes: 7 additions & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ add_custom_target(
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
add_dependencies(pydocs daylight)

add_custom_target(
pydoctest
${CMAKE_COMMAND} -E env PYTHONPATH="${CMAKE_SOURCE_DIR}:${CMAKE_SOURCE_DIR}/build/pybind:${PYTHONATH}" make doctest
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
add_dependencies(pydoctest daylight)
20 changes: 18 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
.. role:: raw-html(raw)
:format: html

:raw-html:`<br />`

.. image:: ../static/logo.png
:width: 300px
:align: center
:alt: daylight logo

:raw-html:`<br />`
:raw-html:`<br />`

Welcome to daylight's documentation
===================================


.. toctree::
:maxdepth: 1
:caption: Contents:
Expand All @@ -14,8 +28,10 @@ daylight or libdaylight is a library which enables you to answer daylight relate
- Irradiance - How bright is it outside, given a particular time and location?
- What is the time of sunrise/solarnoon/sunset, given a particular time and location?

Installation
------------
For basic usage via Python or C APIs, check `README <https://github.com/adonmo/daylight>`_ on our GitHub repository.

Installation (Python)
---------------------

.. code-block:: bash
Expand Down
28 changes: 22 additions & 6 deletions pybind/pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ PYBIND11_MODULE(daylight, m) {
.def("irradiance",
py::vectorize((double (Sunclock::*)(time_t)) & Sunclock::irradiance),
R"pbdoc(
Calculates the irradiance level for given date.
Calculates the irradiance level for given datetime.
This is a vectorized function.
Parameters
----------
date : int
datetime : int or array_like
unix timestamp (in UTC, seconds)
Examples
Expand All @@ -39,17 +41,21 @@ PYBIND11_MODULE(daylight, m) {
>>> sun = daylight.Sunclock(17.3859, 78.4867, 5.5)
>>> sun.irradiance(1590050435)
0.882753920406182
>>> sun.irradiance([1590010200, 1590024600])
array([-0.56570521, 0.28650605])
)pbdoc",
py::arg("date"))
py::arg("datetime"))

.def("sunrise",
py::vectorize((time_t(Sunclock::*)(time_t)) & Sunclock::sunrise),
R"pbdoc(
Calculates the sunrise time for given date.
This is a vectorized function.
Parameters
----------
date : int
date : int or array_like
unix timestamp (in UTC, seconds)
Examples
Expand All @@ -58,6 +64,8 @@ PYBIND11_MODULE(daylight, m) {
>>> sun = daylight.Sunclock(17.3859, 78.4867, 5.5)
>>> sun.sunrise(1589999400)
1590019961
>>> sun.sunrise([1590010200, 1590024600])
array([1590019959, 1590019957])
)pbdoc",
py::arg("date"))

Expand All @@ -66,9 +74,11 @@ PYBIND11_MODULE(daylight, m) {
R"pbdoc(
Calculates the solar noon time for given date.
This is a vectorized function.
Parameters
----------
date : int
date : int or array_like
unix timestamp (in UTC, seconds)
Examples
Expand All @@ -77,6 +87,8 @@ PYBIND11_MODULE(daylight, m) {
>>> sun = daylight.Sunclock(17.3859, 78.4867, 5.5)
>>> sun.solar_noon(1589999400)
1590043354
>>> sun.solar_noon([1590010200, 1590024600])
array([1590043355, 1590043355])
)pbdoc",
py::arg("date"))

Expand All @@ -85,9 +97,11 @@ PYBIND11_MODULE(daylight, m) {
R"pbdoc(
Calculates the sunset time for given date.
This is a vectorized function.
Parameters
----------
date : int
date : int or array_like
unix timestamp (in UTC, seconds)
Examples
Expand All @@ -96,6 +110,8 @@ PYBIND11_MODULE(daylight, m) {
>>> sun = daylight.Sunclock(17.3859, 78.4867, 5.5)
>>> sun.sunset(1589999400)
1590066748
>>> sun.sunset([1590010200, 1590024600])
array([1590066751, 1590066754])
)pbdoc",
py::arg("date"));
}
Binary file added static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 93327a0

Please sign in to comment.