Skip to content

Release v0.4 #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 96 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
1148c90
add ismi sample data (see #17)
robcast Nov 10, 2022
24be8e8
update ISMI sample data and README with current CIDOC-CRM model.
robcast Nov 18, 2024
869ed56
Merge branch 'develop' into 17-ismi-sample-data
robcast Nov 18, 2024
0e36e45
move to new directory.
robcast Nov 18, 2024
739d22d
Merge branch 'release/0.3' into develop
rlskoeser Nov 18, 2024
1457bcb
Set develop version to 0.4-dev
rlskoeser Nov 18, 2024
c83ed49
Fix spelling and formatting errors in changelog
rlskoeser Nov 19, 2024
f0ee32c
add notebook with first examples of converting ismi dates to undate.
robcast Nov 21, 2024
a2dfae6
Preliminary hijri date parser
rlskoeser Nov 21, 2024
ed23f6c
Test all Hijri months; assume 3+ digit years and use LALR parser
rlskoeser Nov 21, 2024
646f739
Clean up edtf parser code (remove old test case comments)
rlskoeser Nov 21, 2024
51850cc
Add transformer for hijri parser to convert parsed date to undate
rlskoeser Nov 21, 2024
50f2331
Rename test directories & files to be consistent & explicit
rlskoeser Nov 21, 2024
778c67b
Add an undate converter to wire in hijri date parsing capability
rlskoeser Nov 21, 2024
99c0611
Tell mypy to ignore that convertdate code is untyped
rlskoeser Nov 21, 2024
7fd6c07
Merge branch 'main' into develop
rlskoeser Nov 21, 2024
4a7a1d8
Merge branch 'develop' into feature/convert-hijri
rlskoeser Nov 21, 2024
a16a0ac
Merge branch 'hotfix/0.3.1' into develop
rlskoeser Nov 21, 2024
454382f
Merge branch 'develop' into feature/convert-hijri
rlskoeser Nov 21, 2024
315ad7a
Clean up one more date and add more possible todos
rlskoeser Nov 21, 2024
18c8f25
Update src/undate/converters/calendars/hijri/transformer.py
rlskoeser Nov 21, 2024
f3ce58b
Update src/undate/converters/edtf/edtf.lark
rlskoeser Nov 21, 2024
11cc007
Update src/undate/converters/calendars/hijri/converter.py
rlskoeser Nov 21, 2024
2cc596e
Add more error cases for EDTF and Hijri parser tests
rlskoeser Nov 21, 2024
b994eb2
move notebook to separate branch
robcast Nov 22, 2024
57f8f66
Merge pull request #104 from dh-tech/17-ismi-sample-data
rlskoeser Nov 22, 2024
0aac63a
Add calendar field to Undate object
rlskoeser Nov 22, 2024
e2444ed
Partial refactor: initialize hijri dates as undate with hijri calendar
rlskoeser Nov 26, 2024
3aa462b
Use calendar converter to get max month/day and convert to gregorian
rlskoeser Nov 26, 2024
fe41545
Generate iso format date from native calendar date, not earliest/latest
rlskoeser Nov 26, 2024
3a43e6d
Include calendar name in undate repr
rlskoeser Nov 26, 2024
7c9ccb7
Support and test comparing undates across calendars
rlskoeser Nov 26, 2024
b6b6376
Work around StrEnum not being in python until 3.11
rlskoeser Nov 26, 2024
e91b7ba
Allow any Hijri year (drop 3+ digit year constraint and year-month-day)
rlskoeser Nov 26, 2024
6c6f09a
Confirm hijri dates + partially unknown date behavior
rlskoeser Nov 26, 2024
5cc19fd
Add calendar converter base class and document how to add calendars
rlskoeser Nov 26, 2024
d26574c
Implementing Hebrew Anno Mundi calendar converter based on Hijri
rlskoeser Nov 27, 2024
5660fa2
Fix mis-formatted docstring
rlskoeser Nov 27, 2024
c6ed817
Fix mis-formatted docstring
rlskoeser Nov 27, 2024
88e4d17
Adjust imports for hebrew calendar converter
rlskoeser Nov 27, 2024
f908cd5
Add comment about earliest Hebrew year in grammar
rlskoeser Dec 6, 2024
c24cd34
Test exceptions and parser type errors more specific
rlskoeser Dec 6, 2024
5773bf7
Run unit tests on pull request to any branch
rlskoeser Dec 6, 2024
3032785
Fix incorrect import
rlskoeser Dec 6, 2024
9137608
Force calendar converters to implement min/max month methods
rlskoeser Dec 6, 2024
920f736
Differentiate min/max month from first/last month
rlskoeser Dec 6, 2024
867e018
Merge branch 'feature/convert-hijri' into feature/convert-hebrew
rlskoeser Dec 6, 2024
333e740
Merge pull request #108 from dh-tech/feature/convert-hebrew
rlskoeser Dec 6, 2024
b7ae594
Rewrite gregorian calendar docstring that incorrectly ref'ed Hijri
rlskoeser Dec 7, 2024
759d0c7
Fix docstring typo caught by @coderabbitai
rlskoeser Dec 7, 2024
d9fd4ba
Include calendar converters in sphinx docs and add basic usage to readme
rlskoeser Dec 20, 2024
4372b23
Address coverage issues flagged by codecov
rlskoeser Dec 20, 2024
a33e43b
Merge pull request #107 from dh-tech/feature/convert-hijri
rlskoeser Dec 20, 2024
f6c4382
Find all converter subclasses / descendants
rlskoeser Feb 6, 2025
0deb9ad
Update docstring to describe the modified logic
rlskoeser Feb 7, 2025
89e806d
Document that duration logic is inclusive #63
rlskoeser Feb 7, 2025
48f1189
Add closed interval language to describe duration logic
rlskoeser Feb 7, 2025
6c8c639
Clean up commented out print statement
rlskoeser Feb 7, 2025
ea45598
Merge pull request #111 from dh-tech/feature/doc-duration
rlskoeser Feb 7, 2025
43d1011
Try using uv for unit test workflow
rlskoeser Feb 7, 2025
e58e507
Remove pip caching; configure uv cache
rlskoeser Feb 7, 2025
e8cdf62
Try using uv for check workflow
rlskoeser Feb 7, 2025
d56115c
Some example notebooks require jupyter & pandas
rlskoeser Feb 7, 2025
a0f4b05
Install only the necessary dependencies for test/check workflow
rlskoeser Feb 7, 2025
0fefcec
Move interval object and tests into separate files
rlskoeser Feb 20, 2025
60aefc4
Update example notebook to import UndateInterval from new location
rlskoeser Feb 20, 2025
1607b98
Remove debug print statement flagged by code rabbit
rlskoeser Mar 5, 2025
6eaa0be
Merge pull request #115 from dh-tech/feature/reorg-interval
rlskoeser Mar 5, 2025
ffc1993
Add validation and type conversion to interval init
rlskoeser Feb 20, 2025
710c66a
Implement & test an intersection method for UndateInterval
rlskoeser Feb 20, 2025
298bb19
Make conversion to undate more reusable and extensible
rlskoeser Feb 21, 2025
fc4f7a9
Drop support for python 3.9 so we can use match/case
rlskoeser Feb 21, 2025
a4f2e7b
Add more type checks and tests
rlskoeser Feb 21, 2025
ca9fb7b
Merge pull request #110 from feature/converter-nested-subclasses
rlskoeser Mar 5, 2025
b09c9fc
Remove unused import
rlskoeser Mar 6, 2025
4504542
Merge branch 'develop' into feature/intersection
rlskoeser Mar 6, 2025
f06960a
Use raise from err on type error in interval init
rlskoeser Mar 13, 2025
9ee14ef
Add and test contains/in method for interval
rlskoeser Mar 13, 2025
700c834
Address nitpicks flagged by @coderabbitai
rlskoeser Mar 13, 2025
cfdef42
Revise contains logic: interval contains itself or equivalent interval
rlskoeser Apr 5, 2025
3dd2b33
Merge pull request #114 from dh-tech/feature/intersection
rlskoeser Apr 9, 2025
8a01277
Merge pull request #113 from dh-tech/feature/uv-github-actions
rlskoeser Apr 9, 2025
fb694b7
Support conversion from internal Date class to Undate #119
rlskoeser Apr 11, 2025
1f873bc
Use `islamic` for Islamic/Hijri calendar classes #120
rlskoeser Apr 11, 2025
7e3dd84
Merge pull request #122 from dh-tech/feature/convert-undate
rlskoeser Apr 11, 2025
48b0f62
Reorganize examples and update readme / contents #121
rlskoeser Apr 11, 2025
f442724
Clean up additional mentions & typos flagged by coderabbitai
rlskoeser Apr 11, 2025
6d36928
Fix shxco notebook path and augment description
rlskoeser Apr 11, 2025
b0f56f7
Merge pull request #123 from dh-tech/feature/rename-hijri
rlskoeser Apr 11, 2025
3c722fa
Merge pull request #124 from dh-tech/feature/cleanup-examples
rlskoeser Apr 11, 2025
58d2717
Set version to 0.4.0 final
rlskoeser Mar 31, 2025
0677649
Document changes since the last release
rlskoeser Mar 31, 2025
110f00b
Change project status from pre-alpha to alpha
rlskoeser Apr 11, 2025
4d0b488
Document changes since last release
rlskoeser Apr 11, 2025
04f8b65
Update documentation to match current functionality
rlskoeser Apr 11, 2025
6098361
Minor cleanup and fixes suggested by coderabbitai
rlskoeser Apr 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,28 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install package with development dependencies
run: pip install -e ".[dev]"

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Install package with check dependencies
run: uv sync --extra check

# check with ruff
- name: Run ruff
run: ruff check
run: uv run ruff check

# check docs build
- name: Check that documentation builds with no errors or warnings
run: sphinx-build docs docs/_build --fail-on-warning
run: uv run sphinx-build docs docs/_build --fail-on-warning

# check types with mypy
- name: Check types in python src directory; install needed types
run: mypy --install-types --non-interactive src
run: uv run mypy --install-types --non-interactive src

# use treon to make sure that example notebooks run
- name: Check jupyter notebooks with treon
run: treon
run: uv run treon
29 changes: 19 additions & 10 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- 'undate/**'
- 'tests/**'
pull_request:
branches:
- "**"

env:
# python version used to calculate and submit code coverage
Expand All @@ -18,30 +20,37 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python: ["3.10", "3.11", "3.12", "3.13"]
defaults:
run:
working-directory: .

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v4

# use github python action instead of uv to take advantage of caching
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install package with dependencies
run: pip install -e ".[test]"

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Install package with dev and test dependencies
run: uv sync --extra test

# for all versions but the one we use for code coverage, run normally
- name: Run unit tests normally
run: pytest
run: uv run pytest
if: ${{ matrix.python != env.COV_PYTHON_VERSION }}

# run code coverage in one version only
- name: Run unit tests with code coverage reporting
run: pytest --cov=undate
run: uv run pytest --cov=undate
if: ${{ matrix.python == env.COV_PYTHON_VERSION }}
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 0.4

- Make Undate Calendar aware / explicit; default is Gregorian
- Parsing and calendar conversion for Hebrew/Anno Mundi
- Parsing and calendar conversion for Islamic/Hijri


## 0.3.1

Update readthedocs config for current installation
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ An `UndateInterval` is a date range between two `Undate` objects. Intervals can
```

You can initialize `Undate` or `UndateInterval` objects by parsing a date string with a specific converter, and you can also output an `Undate` object in those formats.
Available converters are "ISO8601" and "EDTF" (but only)
Currently available converters are "ISO8601" and "EDTF" and supported calendars.

```python
>>> from undate import Undate
Expand All @@ -156,6 +156,33 @@ Available converters are "ISO8601" and "EDTF" (but only)
<UndateInterval 1800/1900>
```

### Calendars

All `Undate` objects are calendar aware, and date converters include support for parsing and working with dates from other calendars. The Gregorian calendar is used by default; currently `undate` supports the Islamic Hijri calendar and the Hebrew Anno Mundi calendar based on calendar conversion logic implemented in the [convertdate](https://convertdate.readthedocs.io/en/latest/) package.

Dates are stored with the year, month, day and appropriate precision for the original calendar; internally, earliest and latest dates are calculated in Gregorian / Proleptic Gregorian calendar for standardized comparison across dates from different calendars.

```python
>>> from undate import Undate
>>> tammuz4816 = Undate.parse("26 Tammuz 4816", "Hebrew")
>>> tammuz4816
<Undate '26 Tammuz 4816 Anno Mundi' 4816-04-26 (Hebrew)>
>>> rajab495 = Undate.parse("Rajab 495", "Hijri")
>>> rajab495
<Undate 'Rajab 495 Hijrī' 0495-07 (Hijri)>
>>> y2k = Undate.parse("2001", "EDTF")
>>> y2k
<Undate 2001 (Gregorian)>
>>> [str(d.earliest) for d in [rajab495, tammuz4816, y2k]]
['1102-04-28', '1056-07-17', '2001-01-01']
>>> [str(d.precision) for d in [rajab495, tammuz4816, y2k]]
['MONTH', 'DAY', 'YEAR']
>>> sorted([rajab495, tammuz4816, y2k])
[<Undate '26 Tammuz 4816 Anno Mundi' 4816-04-26 (Hebrew)>, <Undate 'Rajab 495 Hijrī' 0495-07 (Hijri)>, <Undate 2001 (Gregorian)>]
```

* * *

For more examples, refer to the [example notebooks](https://github.com/dh-tech/undate-python/tree/main/examples/notebooks/) included in this repository.

## Documentation
Expand Down
35 changes: 29 additions & 6 deletions docs/undate/converters.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
Converters
==========

Overview
--------

.. automodule:: undate.converters.base
:members:
:undoc-members:

Formats
--------

ISO8601
-------
^^^^^^^

.. automodule:: undate.converters.iso8601
:members:
:undoc-members:

Extended Date-Time Format (EDTF)
--------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: undate.converters.edtf.converter
:members:
Expand All @@ -23,8 +29,25 @@ Extended Date-Time Format (EDTF)
:members:
:undoc-members:

.. transformer is more of an internal, probably doesn't make sense to include
.. .. automodule:: undate.converters.edtf.transformer
.. :members:
.. :undoc-members:

Calendars
---------

Gregorian
^^^^^^^^^

.. automodule:: undate.converters.calendars.gregorian
:members:

Hebrew Anno Mundi calendar
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: undate.converters.calendars.hebrew.converter
:members:

Islamic Hijri calendar
^^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: undate.converters.calendars.islamic.converter
:members:

7 changes: 5 additions & 2 deletions docs/undate/core.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
Undate objects
==============

undates and undate intervals
dates, intervals, and calendar
------------------------------

.. autoclass:: undate.undate.Undate
:members:

.. autoclass:: undate.undate.UndateInterval
.. autoclass:: undate.undate.Calendar
:members:

.. autoclass:: undate.interval.UndateInterval
:members:

date, timedelta, and date precision
Expand Down
16 changes: 11 additions & 5 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# undate examples

Example data and projects with use cases for uncertain date logic and
example code notebooks using undate.

- [use cases](use-cases) - examples from projects or specific data with use cases for undate
- [notebooks](notebooks) - code notebooks showing how undate can be used on a specific dataset or for a specific problem
This folder contains code notebooks demonstrating how `undate` can be
used on a specific dataset, problem, or format, as well as example
data from projects with use cases for uncertain date logic.

## Contents

- [EDTF support](edtf-support.ipynb) - demonstrate and validate supported portions of the Extended Date Time Format (EDTF) specification (jupyter notebook)
- [ISMI](ismi) - Sample data from the Islamic Scientific Manuscript Initiative project
- [Shakespeare and Company Project](shakespeare-and-company-project) - data, description of partial date implementation, and example notebook
- Events data from version 1.2 of Shakespeare and Company Project datasets
- [Partial date duration logic](shakespeare-and-company-project/shxco_partial_date_durations.ipynb) - compare `undate` partial date range duration logic with a previous implementation in the _Shakespeare and Company Project_ (jupyter notebook)
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "9c6b7379-b2a7-4ec1-afa5-2cd9832c8a5d",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -92,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "923476ff-344a-4018-a02e-6e5f80ea76a8",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -159,7 +159,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "6ed422de-34a2-4324-b254-f62db00563f7",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -212,7 +212,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "8d98a139-627b-40bd-b1c5-d0028e538a53",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -255,7 +255,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "532470db-851e-4f91-9242-cd93d35054cf",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -320,7 +320,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "a5abd0e4-0b26-49b0-bf78-3e1fe6c046d8",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -425,7 +425,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "e47f3fff-d35c-4c2e-9568-214763f6511a",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -481,7 +481,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "39143c1f-932a-450c-9b2d-ffbe3e1416b0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -535,7 +535,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "95965f17-0bd5-446f-bc09-9503eaed68e2",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -589,7 +589,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "c6c2d1a1-39f1-45eb-ac08-1de4fadbe842",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -640,7 +640,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"id": "f24fd31a-176a-40b5-bff4-d72b68f32a18",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -688,7 +688,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"id": "5910caab-eada-4715-b863-9bbbb15b9c5c",
"metadata": {},
"outputs": [],
Expand Down
22 changes: 22 additions & 0 deletions examples/ismi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Sample data from the ISMI project database

The [Islamic Scientific Manuscript Initiative project](https://ismi.mpwig-berlin.mpg.de) aims to collect information about all Islamic Manuscripts in the exact sciences from the 9th to the 19th centuries CE.

The new [ISMI database](https://gitlab.gwdg.de/MPIWG/Department-II/ismi-project) stores historical dates as CIDOC-CRM RDF objects with the following structure:

- `crm:E52_Time-Span`
- `crm:P2_has_type`: date type
- "datetype:day"
- `crm:P82_at_some_time_within`: given day (xsd:date)
- "datetype:year"
- `crm:P82a_begin_of_the_begin`: first day (xsd:date), `crm:P82b_end_of_the_end`: last day of year (xsd:date)
- "datetype:range"
- `crm:P82a_begin_of_the_begin`: first day (xsd:date), `crm:P82b_end_of_the_end`: last day of range (xsd:date)
- `crm:P1_is_identified_by`
- `crm:E41_Appellation`
- `rdfs:label`: textual representation of timespan (e.g. "901 Rabīʿ I 14 (islamic)")
- `crm:P2_has_type`: calendar type (calendar the date was entered in)
- "calendartype:julian", "calendartype:islamic", "calendartype:gregorian"
- `crm:P3_has_note`: textual note with additional information

A sample file with dates of each type can be found in `data/ismi-crm-date-samples.ttl`
Loading