Skip to main content

Farady Python Library

Project description

Farady-Python

法拉第的python本地开发辅助库,目前为止兼容云端的导入环境,简化并加速开发过程。

使用方法

  • 安装:pip install Farady-Python
  • 具体使用:from FDLib import *

使用示例

代码

import math
from FDLib import *


def gen_x(b: float, e: float, s: float = 1.0):
    assert s != 0, "s couldn't be zero"

    def pos():
        return b <= e

    def neg():
        return b >= e

    cond = pos if s > 0 else neg
    while cond():
        yield b
        b += s


class MyLib(FDLibrary):
    metalLayers = ["Metal Layer"]
    Parameters = {
        # 参数列表
        "X": 0.0, "Y": 0.0, "L1": 50.6, "L2": 67.8
    }
    ParameterOrder = [
        # 参数显示顺序
        "X", "Y", "L1", "L2"
    ]

    def check_param(self):
        # 检查参数是否合法,不能用f-string,需要用format
        assert 0 < self.L1 < self.L2, "require: 0 < L1 < L2, got: L1={0}, L2={1}".format(self.L1, self.L2)
        # 其它检查

    def reload(self):
        self.check_param()  # 调用前必须重写父类方法
        # 生成polygon关键点
        xs = list(gen_x(-self.L1 + 5, self.L1 - 5, 0.1))
        sin_n = [math.sin(x) * 5 for x in xs]
        y_t = [y + 2 for y in sin_n]
        y_b = [y - 2 for y in sin_n]
        ps_t = [(x, y) for (x, y) in zip(xs, y_t)]
        ps_b = [(x, y) for (x, y) in zip(xs, y_b)]
        ps = ps_t + ps_b[::-1]  # 带有宽度的sin曲线
        
        self.specifications = [
            Arc(
                location=(self.X, self.Y),
                innerRadius=self.L1,
                outerRadius=self.L2,
                beginAngle=0,
                endAngle=math.pi / 3 * 2,
                clockwise=0,  # 逆时针从0转到120°
                metalLayer="arc-small"  # 该部分为小圆部分
            ),
            Arc(
                location=(self.X, self.Y),
                innerRadius=self.L1,
                outerRadius=self.L2,
                beginAngle=0,
                endAngle=math.pi / 3 * 2,
                clockwise=1,  # 顺时针从0转到120°
                metalLayer="arc-big"  # 该部分为大圆部分
            ),
            Rectangle(
                location=(self.X - 20, self.Y + 10),
                width=40,
                height=10,
                metalLayer="rect-up"  # 上面的矩形
            ),
            Rectangle(
                location=(self.X - 5, self.Y - 40),
                width=10,
                height=30,
                metalLayer="rect-bo"  # 下面的矩形
            ),
            Path(
                location=[
                    (self.X - self.L2, self.Y - self.L2),
                    (self.X - self.L2, self.Y + self.L2)
                ],
                width=10,
                path_type="round",
                metalLayer="path-1"  # 左侧的线条
            ),
            Path(
                location=[
                    (self.X + self.L2, self.Y - self.L2),
                    (self.X + self.L2, self.Y + self.L2)
                ],
                width=10,
                path_type="round",
                metalLayer="path-2"  # 右侧的线条
            ),
            Polygon(
                location=ps,  # 中间的sin曲线
                pins_location=[  # 上下的pin点
                    [(self.X, self.Y - self.L2), (self.X, self.Y + self.L2)]
                ]
            )
        ]


if __name__ == "__main__":
    MyLib().run()

运行结果

example

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

farady_python-0.1.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

farady_python-0.1.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file farady_python-0.1.2.tar.gz.

File metadata

  • Download URL: farady_python-0.1.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for farady_python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f1c7eef63c53a477e4ce0c3454be81b21be84c8a2f2a52a3f60d855b841b1068
MD5 7dbd1257b0532b6fa6e32652738f53d9
BLAKE2b-256 e2d976c9797be72bf8fcd4ae7916d864f8e9f937efea00a54219fbd9bcc6232f

See more details on using hashes here.

File details

Details for the file farady_python-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: farady_python-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for farady_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f0b0756f1679876ef14bfcd8f6c3ded6704165537f367e73a0155fe23d78c2ed
MD5 ddcb376b581c9c470fd493bfb13ed072
BLAKE2b-256 5c5e364d5e76fc3661e246da697d9df8f63b3a24d26aa2cd8925c7b5c58a3832

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