Skip to main content

HLMagix toolset including calculator, models and utilities

Project description

HLMagix

一个功能丰富的 Python 工具集,包含命令行计算器、业务模型和通用工具库。

组件

  • 命令行计算器: 提供强大的计算功能 (hlmagix.hlcalculator)
  • 业务模型: 数据结构和业务逻辑 (hlmagix.models)
  • 工具库: 通用数学和字符串操作 (hlmagix.utils)

功能特性

  • 基础算术运算:

    • 加法 (+)
    • 减法 (-)
    • 乘法 (*)
    • 除法 (/)
    • 幂运算 (^)
  • 科学计算:

    • 平方根 (sqrt)
    • 对数 (log)
    • 三角函数 (sin, cos, tan)
    • 阶乘
  • 数学常数:

    • π (pi)
    • e
    • τ (tau)

安装

使用 pip:

pip install hlmagix

使用 Poetry:

poetry add hlmagix

使用方法

命令行计算器

hlcal calc 5 + 3         # 加法: 8.0
hlcal calc 10 - 4        # 减法: 6.0
hlcal calc 3 '*' 4       # 乘法: 12.0 (注意: * 需要引号)
hlcal calc 15 / 3        # 除法: 5.0
hlcal calc 2 ^ 3         # 幂运算: 8.0

# 科学计算
hlcal calc 16 sqrt       # 平方根: 4.0
hlcal calc 100 log 10    # 对数: 2.0
hlcal calc 0.5 sin       # 正弦: 0.479

# 数学常数
hlcal const pi           # π: 3.141592653589793
hlcal const e            # e: 2.718281828459045

使用模型和工具库

# 使用工具函数
from hlmagix.utils.math_utils import calculate_factorial
from hlmagix.utils.string_utils import format_number

result = calculate_factorial(5)
formatted = format_number(result)

# 使用模型
from hlmagix.models.product import Product
from hlmagix.models.user import User

product = Product(name="Example", price=100)
user = User(name="John Doe")

# 或者使用导入包
import hlmagix

result = hlmagix.utils.math_utils.calculate_factorial(5)
product = hlmagix.models.product.Product(name="Example", price=100)

项目结构

hlmagix/
├── __init__.py      # 包初始化,导出所有子模块
├── hlcalculator/    # 命令行计算器实现
│   ├── __init__.py
│   ├── cli.py       # 命令行接口
│   ├── calculator.py
│   └── parser.py
├── models/          # 业务模型
│   ├── __init__.py
│   ├── product.py
│   └── user.py
└── utils/          # 工具函数
    ├── __init__.py
    ├── math_utils.py
    └── string_utils.py

开发指南

环境要求

  • Python 3.12 或更高版本
  • Poetry 依赖管理工具

设置开发环境

  1. 克隆仓库
git clone https://github.com/hailv/hlmagix.git
cd hlmagix
  1. 安装依赖
poetry install
  1. 激活虚拟环境
poetry shell

代码质量工具

项目使用多个代码质量工具:

  • black: 代码格式化
  • flake8: 代码风格检查
  • mypy: 静态类型检查
  • isort: 导入排序

运行所有检查:

poetry run black .
poetry run flake8 .
poetry run mypy .
poetry run isort .

许可证

本项目基于 MIT 许可证 - 详见 LICENSE 文件

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

hlmagix-0.4.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

hlmagix-0.4.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file hlmagix-0.4.2.tar.gz.

File metadata

  • Download URL: hlmagix-0.4.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.4.0

File hashes

Hashes for hlmagix-0.4.2.tar.gz
Algorithm Hash digest
SHA256 7f223b7a4963d5334120ee7130b9b9ffadda8f6af7a0545d14826c99a7360c75
MD5 92667b3d3ad13b6837a75a0305369bfd
BLAKE2b-256 a55b899206852e3b58970288305c5db7f202924e439e1b954fa7278676632eba

See more details on using hashes here.

File details

Details for the file hlmagix-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: hlmagix-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.4.0

File hashes

Hashes for hlmagix-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0775d6c1d984a3b114cac7d33ec10a467ff099f39a47eceb710ac1125e1fc60d
MD5 5961333dc2f93ccb73131ee917c5cd7b
BLAKE2b-256 49cd31e00bc77e3f21cfeff3d3c3c4b9d30dc7d3de3294a48cdd203f6395b2e1

See more details on using hashes here.

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