Skip to main content

No project description provided

Project description

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

import ichingpy as icp

Create a Line (爻)

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 (老阳)
qian = icp.Trigram.from_binary([1, 1, 1])

The order is from the inside (初爻, 二爻, 三爻).

Create a Hexagram with transformation (变卦)

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

hexagram = icp.Hexagram.from_three_coins()
hexagram = icp.Hexagram.from_yarrow_stalks()
-- --
-- --
-- --
----- O -> -- --
-- --
----- O -> -- --

Assign HeavenlyStems to a hexagram

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

>>> 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+1
乙丑
>>> jia_zi+60
甲子

Assign Stem and Branch to a hexagram (装卦、纳甲)

>>> gou = icp.Hexagram.from_binary([2, 1, 1, 1, 1, 1]) 
>>> gou
-----
-----
-----
-----
-----
-- --
>>> assigner = icp.StemBranchAssigner()
>>> assigner.assign(gou) 
>>> gou
  -----
  -----
  -----
  -----
  -----
  -- --

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ichingpy-0.1.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ichingpy-0.1.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file ichingpy-0.1.1.tar.gz.

File metadata

  • Download URL: ichingpy-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ichingpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 97a99724a51abf194f7fd1137505a9f1c9c80e92a907c9e8bfb8cc53dc9fa736
MD5 ce57385b8735964f0fb55708068b45a4
BLAKE2b-256 de69ae44ea00242f72a6723b8a05a4f39dde425923ec0d5c30c5e65c1ef97484

See more details on using hashes here.

Provenance

The following attestation bundles were made for ichingpy-0.1.1.tar.gz:

Publisher: python-publish.yml on JinyangWang27/ichingpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ichingpy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ichingpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ichingpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f00b46e181409153e04f2a5a3ab813626d05e22e4d1bc8fa2d37af15f9e2a2f
MD5 a75ee9b3d44096377ba9710902d28684
BLAKE2b-256 396896f581b8b76c8c2a55a634142268fe8f75a88c6adf955142baa715813022

See more details on using hashes here.

Provenance

The following attestation bundles were made for ichingpy-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on JinyangWang27/ichingpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page