Metadata-Version: 2.1
Name: ichingpy
Version: 0.1.1
Author-email: Jinyang Wang <jinyang.wang27@outlook.com>
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ipykernel; extra == "dev"
Requires-Dist: rich; extra == "dev"
Requires-Dist: mkdocstrings; extra == "dev"
Requires-Dist: mkdocs-material; extra == "dev"
Requires-Dist: mkdocstrings-python; extra == "dev"

# I-Ching Python

## Description
I-Ching Python is a fully object-oriented Python library for working with the I-Ching, an ancient Chinese divination text. 
This library provides tools for 
1. generating hexagrams using multiple methods, 
2. interpreting their meanings   (TODO)
3. performing divination based on the I-Ching (TODO)
4. arithmetic operations on Heavenly Stems and Earthly Branches (干支)


## Installation

> pip install ichingpy

## Quick Start


```python
import ichingpy as icp
```

Create a Line  (爻)
```python
yin = icp.Line(status=icp.LineStatus.CHANGING)
```

Create a Trigram (八卦)
The default constructor takes a list of Lines. An alternative constructor is to create from "binary" as defined in LineStatus:

 - 0: changing yin (老阴)
 - 1： static yang (少阳)
 - 2: static yin (少阴)
 - 3: changing yang (老阳)

```python
qian = icp.Trigram.from_binary([1, 1, 1])
```
The order is from the inside (初爻， 二爻， 三爻).

Create a Hexagram with transformation (变卦)
```python
qian_tai = icp.Hexagram.from_binary([3, 3, 3, 1, 1, 1]) # 乾之泰
```

A Hexagram can be also generated by using 50 yarrow stalks or 3 coins
```python 
hexagram = icp.Hexagram.from_three_coins()

```
```python 
hexagram = icp.Hexagram.from_yarrow_stalks()
```

```
-- --
-- --
-- --
----- O -> -- --
-- --
----- O -> -- --
```

Assign HeavenlyStems to a hexagram
```python
from ichingpy.calculator.assigner import HexagramAssigner
hexagram = icp.Hexagram.from_yarrow_stalks()
assigner = HexagramAssigner()
assigner.assign_stems(hexagram)
hexagram.inner.stem
```
```
[<HeavenlyStem.Ji: 6>, <HeavenlyStem.Ji: 6>, <HeavenlyStem.Ji: 6>]
```

#### Arithmetic operations on Heavenly Stems and Earthly Branches (干支)

```python
>>> icp.HeavenlyStem.Jia + 1
<HeavenlyStem.Yi: 2>

>>> gui = icp.HeavenlyStem.Gui
>>> jia = icp.HeavenlyStem.Jia
>>> jia + gui 
<HeavenlyStem.Jia: 1>
```
```python
>>> jia = icp.HeavenlyStem.Jia 
>>> zi = icp.EarthlyBranch.Zi
>>> jia_zi = icp.SexagenaryCycle(jia, zi)
>>> jia_zi
甲子
>>> jia_zi+1
乙丑
>>> jia_zi+60
甲子
```
#### Assign Stem and Branch to a hexagram (装卦、纳甲)
```python
>>> gou = icp.Hexagram.from_binary([2, 1, 1, 1, 1, 1]) 
>>> gou
-----
-----
-----
-----
-----
-- --
>>> assigner = icp.StemBranchAssigner()
>>> assigner.assign(gou) 
>>> gou
壬 戌 -----
壬 申 -----
壬 午 -----
辛 酉 -----
辛 亥 -----
辛 丑 -- --
```
