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.3.tar.gz (10.2 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.3-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: farady_python-0.1.3.tar.gz
  • Upload date:
  • Size: 10.2 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.3.tar.gz
Algorithm Hash digest
SHA256 92079cfd2691873e87747c44aabbd8a245822ceaa73be59e2285cf7edadd41de
MD5 c6e844ebba094dcfcac5f046bf5e5d30
BLAKE2b-256 81b5c549cdd094851645834ab4429e787cd8b005634ad0feefbfd3de32d654df

See more details on using hashes here.

File details

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

File metadata

  • Download URL: farady_python-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 535ffe56f72ae697209bc9fc7ce34f08c254652de130132d659edd354095057c
MD5 57911bd04d1b7babffaccdc5137cfadc
BLAKE2b-256 759365e4e72213ca398dd1d99141d37e24c92c238a22aff90ca2c22d10cb4fdd

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