Metadata-Version: 2.1
Name: ichingpy
Version: 0.1.7
Summary: I-Ching objects construction using Python type hints.
Author-email: Jinyang Wang <jinyang.wang27@outlook.com>
License: MIT
Project-URL: Homepage, https://github.com/JinyangWang27/ichingpy
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
[![pypi](https://img.shields.io/badge/pypi-v0.1-blue)](https://pypi.org/project/ichingpy/)
[![codecov](https://codecov.io/gh/JinyangWang27/ichingpy/branch/main/graph/badge.svg?token=T27TSAL7BC)](https://codecov.io/gh/JinyangWang27/ichingpy)
[![license](https://img.shields.io/badge/license-MIT-g)]([LICENSE](https://github.com/JinyangWang27/ichingpy/blob/main/LICENSE))

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

[Foreword by Carl Gustav Jung](https://github.com/JinyangWang27/ichingpy/blob/main/docs/books/en/RichardWilhelm/foreword_CG_Jung.md)

## 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 (yarrow stalks, three coins, datetime), 
2. Arithmetic operations on Heavenly Stems and Earthly Branches (干支)
3. Multi-language support (Chinese and English)
3. Interpreting meanings of hexagrams   (TODO)
4. Performing divination based on the I-Ching (TODO)

## Installation

> pip install ichingpy

## A Simple Example

```python
import ichingpy as icp
icp.set_language("en")
```
<!-- 
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
>>> jia_zi+1
Yi Chou
>>> jia_zi+60
Jia Zi
```
#### Assign Stem and Branch to a hexagram (装卦、纳甲)
```python
>>> gou = icp.Hexagram.from_binary([2, 1, 1, 1, 1, 1]) 
>>> gou
-----
-----
-----
-----
-----
-- --
>>> assigner = icp.SixLinesDivinationEngine()
>>> assigner.execute(gou) 
>>> gou
Ren  (9) Xu   (11) EARTH -----
Ren  (9) Shen (9 ) METAL -----
Ren  (9) Wu   (7 ) FIRE  -----
Xin  (8) You  (10) METAL -----
Xin  (8) Hai  (12) WATER -----
Xin  (8) Chou (2 ) EARTH -- --
```
