玄学排盘库

本库用于六爻排盘(六爻预测)和八字排盘(八字预测),提供了基础的六爻、八字相关实体、符号、五行、天干地支等数据结构和推演逻辑,适合用于命理、易学、占卜等相关应用的开发。致力于面向未来,面向AI
功能简介
六爻排盘
- 支持六爻排盘的基本流程
- 内置天干、地支、五行、六神、卦象等基础数据
- 提供六爻相关实体和符号的操作
八字排盘
- 支持八字排盘的基本流程
- 提供格局、大运、流年、神煞等分析功能
- 内置十神、纳音、十二长生等基础数据
安装
pip install divicast
或直接克隆仓库:
git clone https://github.com/wangsquirrel/divicast.git
cd divicast
pip install .
快速上手
以下是一个简单的六爻排盘示例:
更多用法请参考 examples/sixline_example.py。
from divicast.sixline import DivinatorySymbol, rich_draw_divination, to_standard_format
# 创建一个六爻卦象
d = DivinatorySymbol.create()
# 输出文本排版格式的卦象
rich_draw_divination(d)
# 输出卦象标准化json格式
print(to_standard_format(d).model_dump_json(exclude_none=True))
从 0.2.4 起,新调用推荐使用标准爻值,顺序为初爻到上爻:
from datetime import datetime
d = DivinatorySymbol.create(
now=datetime(2026, 2, 4, 4, 30, 0),
line_values=[6, 7, 8, 9, 6, 7],
calc_rules={"zi_hour": "default_next_day"},
)
# 同一盘的传统铜钱字面计数:
d = DivinatorySymbol.create(
now=datetime(2026, 2, 4, 4, 30, 0),
coin_counts=[3, 2, 1, 0, 3, 2], coin_side="text",
)
line_values 中 6 老阴、7 少阳、8 少阴、9 老阳。coin_side 必须指定为 text
(字面)或 back(背面);三种输入互斥。旧 cnts 和 JSON yaogua 仍保持原来的
0–3 编码,不表示传统铜钱字面枚数。空列表和非法输入会报错,只有未提供记录时才随机。
输出新增 line_values、casting 和 calendar,供 CLI、MCP 和 Python 调用统一消费。
详见六爻模块说明。
八字
以下是一个简单的八字排盘示例:
更多用法请参考 examples/bazi_example.py。
import datetime
from divicast.birth_chart import BirthChart, Gender
# 创建一个八字盘
chart = BirthChart.create(
datetime.datetime(1990, 8, 15, 14, 30, 0),
gender=Gender.Male,
)
# 输出八字标准化json格式
print(chart.to_standard_output().model_dump_json(exclude_none=True))
时间约定
- 本库不处理时区、地点、真太阳时换算。
- 传入
BirthChart.create()、to_standard_format()、DivinatorySymbol.create()的时间,必须是调用方已经归一化好的排盘时间。 - 当前只接受
naive datetime。如果传入带tzinfo的 awaredatetime,库会直接拒绝。 - 如果你的业务口径是“当地真太阳时排盘”,请先在调用方完成转换,再把转换后的
naive datetime传入本库。 - 六爻和共享四柱函数完整保留分秒,默认立春换年、十二节换月、23 点换日;
calc_rules={"zi_hour": "lunar_sect2_day_same"}可选择 Tyme 流派 2 的日界, 不依赖全局 provider。八字现有默认流派不变。 - tyme 节气时刻以 UTC+08:00 为基准。仅提供当地无时区时间并不等于完成了当地节气 换算,调用方须明确口径;本库不做当地节气或真太阳时自动校正。
如有问题或建议,欢迎提交 issue 或 PR
Metadata
Release files for divicast 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| divicast-0.2.4.tar.gz | 67.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| divicast-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 143.5 kB
Release files / divicast-0.2.4.tar.gz
| Download URL | divicast-0.2.4.tar.gz |
|---|---|
| Size | 67.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6218d9f3d27aa3c58f620265511258755feebd7f140f361cb22cf08ffa9e101a
|
|
BLAKE2b-256 checksum How to use checksums |
31b578dfe1567031d125cc5f3422724ff8e1372e4f39b63509187c853c8581be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logRelease files / divicast-0.2.4-py3-none-any.whl
| Download URL | divicast-0.2.4-py3-none-any.whl |
|---|---|
| Size | 76.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7c97a697d39fb7e6e1657f17c3db4ade41952e6d17d90e7421a893dcf8a981e
|
|
BLAKE2b-256 checksum How to use checksums |
e945b554b40c105294a58ea671458c73f950c8160f2fa6409eb450265261166e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency log