Skip to content

JinyangWang27/ichingpy

Repository files navigation

I-Ching Python

pypi codecov license

汉语文档由此

Foreword by Carl Gustav Jung

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)
  4. Interpreting meanings of hexagrams (TODO)
  5. Performing divination based on the I-Ching (TODO)

Installation

pip install ichingpy

Help

See Documentation for more details.

A Simple Example

import ichingpy as icp
icp.set_language("en")

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

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

gui = icp.HeavenlyStem.Gui
jia = icp.HeavenlyStem.Jia
jia + gui 
#> <HeavenlyStem.Jia: 1>
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 (装卦、纳甲)

gou = icp.Hexagram.from_binary([2, 1, 1, 1, 1, 1]) 
gou
"""
-----
-----
-----
-----
-----
-- --
"""
assigner = icp.SixLinesDivinationEngine()
assigner.execute(gou) 
gou
"""
PARENTS  Ren  (9) Xu   (11) EARTH -----
SIBLINGS Ren  (9) Shen (9 ) METAL -----
OFFICIALSRen  (9) Wu   (7 ) FIRE  ----- OBJECT
SIBLINGS Xin  (8) You  (10) METAL -----
CHILDREN Xin  (8) Hai  (12) WATER -----
PARENTS  Xin  (8) Chou (2 ) EARTH -- -- SUBJECT
"""

About

An object-oriented Python library for working with the I-Ching with type annotations

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages