Metadata-Version: 2.1
Name: ichingpy
Version: 0.1.3
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

[汉语文档由此](https://github.com/JinyangWang27/ichingpy/blob/main/README_CN.md)

[![pypi](https://img.shields.io/badge/pypi-v0.1-blue)](https://pypi.org/project/ichingpy/)
[![license](https://img.shields.io/badge/license-MIT-g)]([LICENSE](https://github.com/JinyangWang27/ichingpy/blob/main/LICENSE))

## Description
I-Ching objects construction using Python type hints.

Pattern-based implementation without hard-coded mappings. Define how philosophical concepts in pure Python.

Features

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 (干支)

A few implementations are in Chinese, as the author is not satisfied with their current translation. In the future, both Chinese and English will be supported.

## Installation

> pip install ichingpy

## A Simple Example

```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()
```

```
-- --
-- --
-- --
----- 
-- -- X -> -----
----- 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
壬 戌土 -----
壬 申金 -----
壬 午火 -----
辛 酉金 -----
辛 亥水 -----
辛 丑土 -- --
```
