Saravanan666/pypi-org huggingface dataset:
Package: binmao-libs
py脚手架安装python版本号:3.10.12pip安装:pip install binmao_libs相关模块orm使用peeweeorm框架代码样例:frombinmao_libsimportdbfrompeeweeimport*# 创建database实例mysql_db=db.connect(config.mysql_connection)# 创建orm对象(表访问对象)classMetaMoment(Model):"""动态实体类"""id=IntegerField(unique=True)uid=CharField()text=CharField()category_id=IntegerField(column_name="categoryId")created_at=DateTimeField(column_name="createdAt")classMeta:database=mysql_dbtable_name="moment__moment"classMetaUserInfo(Model):"""用户信息"""id=IntegerField(unique=True)nickname=CharField()classMeta:database=mysql_dbtable_name="metacat__user_info"# 表查询cursor=MetaMoment.select().limit(10)forrecordincursor:print(f"text:{record.text}")# 设置特定返回字段(prject)cursor=MetaMoment.select(MetaMoment.id.alias("_id")).limit(10)forrecordincursor:print(f"_id:{record._id}")# 返回使用函数cursor=MetaMoment.select(fn.COUNT(MetaMoment.id))print(f"总数:{next(iter(cursor))}")# 带游标查询# 偏移10条数据，返回后续5条cursor=MetaMoment.select().offset(10).limit(5)forrecordincursor:print(f"id:{record.id}")# 简单的联合查询# 注意使用.dicts方法，将返回结果字典化cursor=MetaMoment.select(MetaUserInfo.nickname).join(MetaUserInfo,on=(MetaUserInfo.id==MetaMoment.uid)).limit(1).dicts()forrecordincursor:print(f"{record}")# 更新操作MetaMoment.update(text="Hello World. 12345").where(MetaMoment.id==1).execute()# 插入# MetaMoment.create(text = "Hello World. 12345").execute()参考：peewee orm使用文档http服务http服务包含对以下框架的封装：Flask
http服务框架Flasgger
swagger服务框架prometheus_flask_exporter
发布prometheus格式指标举例：frombinmao_libsimporthttpsfromflaskimportrequest# post请求@https.app.post("/hello")defhello():"""hello---parameters:- name: bodyin: bodyrequired: trueschema:required:- nameproperties:name:type: stringdescription: name.default: "csj"response:200:description: 成功返回examples:{"state": "0", "msg": "success"}"""name=request.json["name"]returnjson.dumps({"state":"0","msg":"success","data":{"name":name}})https.run(application_name="binmaolibs")参考：flaskflasggerprometheus-flask-exporteross服务oss服务封装了七牛云存储对象的接口使用举例importbase_testimportqiniufrombinmao_libs.ossimportOssClient# 构建oss_clientbucket_name=''oss_gateway=""access_key=""secret_key=""oss_client=OssClient(access_key,secret_key,bucket_name)localfile=r"d:\BaiduSyncdisk\DatasetId_1864493_1687253829.zip"key="models/demo/1.png"progress_handler=lambdaprogress:print(f"progress:{progress}")oss_client.upload(localfile,key,progress_handler=progress_handler)url=oss_gateway+"/"+keyprint(url)模型文件上传/下载服务提供中心化管理模型方案，为公司内部模型共享提供便利binmao-libs.yaml项目目录中引入binmao-libs.yaml配置model:
  ftp:
    host: "192.168.9.19"
    usr: "wallan"
    pwd: "wallan1702"上传模型文件from binmao_libs.model import download_model, upload_model

upload_model(r"/Users/chishijie/Documents/bingmao/python/binmao-libs/dist", "binmao-libs")下载模型文件from binmao_libs.model import download_model, upload_model

download_model("binmao-libs", r"/Users/chishijie/Documents/bingmao/python/binmao-libs/tmp")
Package: binmap
Dataclass for go to and from binary dataIt follows dataclass pattern with typehinting as the binary format.
Temperature with one unsigned byte:>>>classTemperature(BinmapDataclass):...temp:unsignedchar=0...>>>t=Temperature()>>>t.temp=22>>>print(bytes(t))b'\x16'>>>t2=Temperature(b'\x20')>>>print(t2.temp)32Temperature and humidity consisting of one signed byte for temperature and
one unsiged byte for humidity:>>>classTempHum(BinmapDataclass):...temp:signedchar=0...hum:unsignedchar=0...>>>th=TempHum()>>>th.temp=-10>>>th.humidity=60>>>print(bytes(th))b'\xfc<'>>>th2=TempHum(b'\xea\x41')>>>print(th2.temp)-22>>>print(th2.hum)65DatatypesBinmap supports all datatypes that standard librarystructhas.
The types works as typehints in the dataclass. When giving an attribute a
typehinted datatype it will be added to the binary output from the class.PaddingPadding is a field type and datatype that islengthbytes long, and will not show up as
attributes in the dataclass. Trying to assign it a value will be silently
ignored and reading from will raise theAttributeExceptionexception.>>>classPaddedData(BinmapDataclass):...temp:signedchar=0...pad1:pad=padding(length=5)...>>>pd=PaddedData()>>>pd.temp=14>>>print(bytes(pd))b'\x0e\x00\x00\x00\x00\x00'ConstantConstant is fieldtype that always is the given value. Constant could be of any
datatype.>>>classConstant(BinmapDataclass):...signature:unsignedshort=constant(0x1313)...temp:unsignedchar=0...>>>c=Constant()>>>c.temp=18>>>print(bytes(c))b'\x13\x13\x12'>>>print(c.signature)4883>>>print(c.temp)18>>>c.signature=10AttributeError:signatureisaconstantEnumsEnumfield maps agaings IntEnum or IntFlag so that you could set the value
either as the enum or as the numeric value.>>>classWindEnum(IntEnum):...North=0...East=1...South=2...West=3...>>>classWind(BinmapDataclass):...speed:unsignedchar=0...direction:unsignedchar=enumfield(WindEnum,default=WindEnum.East)...>>>w=Wind()>>>print(w)Wind(speed=0,direction=<WindEnum.East:1>)>>>w.direction=WindEnum.West>>>print(w.direction)<WindEnum.West:3>>>>w.direction=2>>>print(w.direction)<WindEnum.South:2>AutolengthAutolenght field types counts number of bytes in the output, including the
autolength field it self. You can’t set an autolenght field. Autolength can be
offseted, for example to ignore it’s own length.>>>classMyBinStruct(BinmapDataclass):...length:unsignedchar=autolength()...temp:signedchar=0...>>>mb=MyBinStruct()>>>print(mb)MyBinStruct(length=2,temp=0)>>>mb.length=10AttributeError:lengthisaconstantCalculated fieldsCalculated fields calls a function when data is converted to binary value. The
function must be declared when the field is added.>>>classWithChecksum(BinmapDataclass):...temp:signedchar=0...hum:unsignedchar=0...defchk(self)->unsignedchar:...return(self.temp+self.hum)&0xFF...checksum:unsignedchar=calculatedfield(chk)...>>>wc=WithChecksum()>>>wc.temp=-20>>>wc.hum=10>>>print(wc)WithChecksum(temp=-20,hum=10,checksum=246)>>>print(bytes(wc))b'\xec\n\xf6'
Package: binmapper
Python package for mapping objects to binary data. It works with Python
2.7+InstallationBinmapper is available fromhttps://pypi.python.org/pypi/binmapperand
can be installed using pippipinstallbinmapperExample usageimportbinmapperimporttextwrapdefinition=u"""\bintype BinX:
        field: uint8
    bintype Bin:
        fieldX: BinX
    """definition=textwrap.dedent(definition)binmap=binmapper.compile(definition)bin=binmap.Bin()input=io.BytesIO("\x01")bin.parse(input)print(bin.fieldX.field)Data typesTypeByte SizeDescriptionuint81Unsigned byteuint162Unsigned shortuint324Unsigned shortsint81Signed bytesint162Signed shortsint324Signed wordfloat4Floating point with single-precisionstringnStringarraynArrayCommon class templatebintypeCLASS_NAME:FIELD_NAME:FIELD_TYPE&FIELD_ATTRIBUTE...&CLASS_ATTRIBUTE=CLASS_ATTRIBUTE_VALUE...&LET_FIELD_NAME=EXPRESSION...FieldsByteorderValueDescriptionlittlendianIncreasing numeric significance with increasing memory addressesbigendianDecreasing numeric significance with increasing memory addressesByteorder can be specified 3-wayField attributefield: uint8 &byteorder=littlendianApply only to fieldBinType attribute:::python
field: uint8
&byteorder=littlendianApply to all fields in BinType, except having attribute byteorderParse argument:::python
bin.parse(input, byteorder='littlendian')Apply to all parsed data, except having attribute byteorder or
BinType byteorderByteorder apply order:`field byteorder > class byteorder > parse byteorder`Class UsageArray UsageString UsageLet Field UsageChange elements in runtime
Package: binmergetool
binmergetoolSimple tool for merging two binary files together.Installpip install binmergetoolUsageExample: merging Arduino bootloader with application codeIn this example, we'll add the Arduino bootloader to a compiled binary file for one-step flashing of microcontrollers.
Application code starts at 0x2000 so we set this as the offset.python -m binmergetool bootloader.bin application.bin 0x2000 0xFF application_with_bootloader.bin
Package: binning-utils-sebastian-achim-mueller
A collection of tools to help with binning.power10Create binning with power-space which is aligned to decades.importbinning_utilsbinning_utils.power10.space(start_decade=0,start_bin=0,stop_decade=2,stop_bin=1,num_bins_per_decade=3,)array([1.,2.15,4.64,10.,21.54,46.41,100.])
Package: biNNytree
This package allows to print Binary Tree beautifully.To use you need to follow this steps:1. from BinaryTree.tree import *2. Set root: root = Node(1)3. Use this: while True:    value = int(input('Enter a number to add to the binary tree (0 to stop): ').lower())    if value == 0:        break    insert_node(root, value)OR: insert_node(root, 2),    insert_node(root, 4),    insert_node(root, value))
Package: binobj
A cross-platform Python 3 library for reading and writing structured binary data
in an object-oriented (ish) style.Why usebinobj?You may have used Python’s built-instructlibrary to load and dump binary
data. It’s unwieldy for larger or more complex data structures, and the format
strings are easy to get wrong.binobjis different in that it takes a class-based
approach to declaring binary structures.Take a look at this example usingstruct:data=(b'BM',1024,0,12,40,32,32,1,1,0,0,72,72,2,2)header_bytes=struct.pack('<2sIIIIiiHHIIiiII',*data)loaded=struct.unpack('<2sIIIIiiHHIIiiII',header_bytes)n_pixels=loaded[5]*loaded[6]The same example rewritten usingbinobj:classBMP(binobj.Struct):classMeta:argument_defaults={"endian":"little"}magic:Bytes=b"BM"file_size:UInt32_reserved:binobj.Bytes(const=b"\0\0\0\0",discard=True)pixels_offset:UInt32()# Legacy DIB headerheader_size:UInt32=40image_width:Int32image_height:Int32n_color_planes:UInt16n_bits_per_pixel:UInt16compression_method:UInt32=0bitmap_size:UInt32v_resolution:Int32h_resolution:Int32n_palette_colors:UInt32n_important_colors:UInt32bmp=BMP(file_size=1024,pixels_offset=12,image_width=32,image_height=32,...)header_bytes=bytes(bmp)loaded=BMP.from_bytes(header_bytes)n_pixels=loaded.image_width*loaded.image_heightbinobjalso has other advantages in that it supports strings in any encoding
Python supports, toggling endianness on a per-field basis (necessary for ISO 9660
images), a variety of integer encodings, computed fields, validation, and more.System RequirementsThis package willnotwork on amixed-endiansystem. Those are pretty rare
nowadays so chances are you won’t have a problem.This has been tested on CPython 3.7-3.11, PyPy 3.7-3.9.InstallationYou can install this withpiplike so:pip3installbinobjBe sure to usepip3and notpip, becausepipdefaults to Python 2.If you get a “Permission Denied” error, try:pip3install--userbinobjSide note: Don’t usesudo(evensudo-EH) to force a package to install,
as that’s a security risk. Seethis answeron Stack Overflow to find out why.Testing and DevelopmentThis package usesToxto run tests on
multiple versions of Python.SetupTo set up your development environment, you’ll need to install a few things.For Python version management, I usepyenv-virtualenv.
Follow the installation instructions there.You’ll also needmake. Depending on your platform you can install it in
one of several ways:macOS:brew install makeDebian systems (e.g. Ubuntu):sudoapt-getinstall makeWindows: UseCygwinand install it during setup.Once you have those installed, in the root directory of this repo run:makesetupRunning the TestsTo run the unit tests for all supported versions of Python, runmake test.
The environments will automatically be rebuilt if needed.Issues and Feature RequestsTo report an issue, request a feature, or propose a change, please file a
report on the project’s GitHub pagehere.LicenseI’m releasing this under the terms of the3-Clause BSD License. For the full
legal text, seeLICENSE.txtin the repository.
Package: binoculars
Binoculars: Binomial Confidence IntervalsThis is a small package that provides functions to compute the confidence interval for a binomial proportion. I made it because I spend altogether too much time staring at the Binomial proportion confidence intervalwiki page.Presently, the package implements:The Normal ApproximationThe Wilson Interval(no continuity correction)Jeffrey's interval(via scipy.stats.beta)Clopper-Pearson interval(also via scipy.stats.beta)If you haven't spent a lot of time thinking about which intervalyoushould use (and why would you want to?), I suggest using the Wilson interval or Jeffrey's interval. Jeffrey's interval is returned by default by thebinomial_confidencefunction in this package.Yououghtn'tuse the normal approximation if you don't have to. It produces patently inaccurate values with low/high probabilities at low Ns. The plot at the top of this readme shows the normal approximation producing lower lower bounds ofless than 0in these cases.InstallpipinstallbinocularsUsagefrombinocularsimportbinomial_confidenceN,p=100,0.2binomial_confidence(p,N)# default to jeffrey's interval# (0.1307892803998113, 0.28628125447599173)binomial_confidence(p,N,tail='lower')# grab one tail# 0.1307892803998113# set Z valuebinomial_confidence(p,N,tail='lower',z=2.58)# 0.11212431621448567# choose your methodbinomial_confidence(p,N,method='normal')# (0.12160000000000001, 0.2784)binomial_confidence(p,N,method='wilson')# (0.1333659225590988, 0.28883096192650237)DevelopmentI honestly do not imagine touching this a lot. But maybe you want to add one of the other interval methods?Make a python 3.6+ venvpip install -e .[test]black lib --checkpytestLater (?)Add confidence intervals for odds ratios, differencesAdd the unimplemented intervalsAdd plots comparing the intervals to readme.
Package: binodtharu
BinodTharuThis ain't no useless shit hon. A low code drive file downloader that's what it is.pip install binodtharuUsagefrom binodtharu.binodfile import binodfunc
binodfunc('https://drive.google.com/file/d/1idYyq8CVm81WguiXyTuBCbXS53VT04YP/view?usp=sharing') # This mofo lets you download any (publicly available) Drive file/folder.BySayantan DasFollow me onGithubfor more such stupid shit/serious stuff.ToDoDropbox Support
Package: binodtharu-cli
BinodTharuThis ain't no useless shit hon. A low code drive file downloader that's what it is.pip install binodtharu-cliUsagefrombinodcli.binodfileimportbinodfuncbinodfunc('https://drive.google.com/file/d/15CJ-dulqm-piGea1kRpWZZXS3-G5-ccH/view?usp=sharing')# This mofo lets you download any (publicly available) Drive file/folder.binodcli https://drive.google.com/file/d/15CJ-dulqm-piGea1kRpWZZXS3-G5-ccH/view?usp=sharingBySayantan DasFollow me onGithubfor more such stupid shit/serious stuff.Contributions:Soumyadip SarkarToDoadd cliadd progress bar
Package: binomialbias
BinomialBiasThis library computes and plots quantitative assessments of discrimination within organizations, based on the binomial distribution.This code supports the following paper:Quantitative assessment of discrimination in appointments to senior Australian university positions.Robinson PA, Kerr CC.Under review (2023).There are several ways to use this library, described below.WebappA live webapp is running athttps://binomialbias.sciris.org.Local installation and usagePythonTo use locally with Python, runpip install binomialbiasThis can then be run via e.g.:import binomialbias as bb
bb.plot_bias(n=20, n_e=10, n_a=7)This example shows the statistics for the case where there weren = 20appointments (e.g., the size of a committee), out of whichn_e = 10people were expected to belong to a given group (e.g., female), and for whichn_a = 7actually were.ShinyTo run theShinyapp locally, clone the repository from GitHub, then install withpip install -e .[app]The Shiny app can then be run locally via therunscript.StructureAll code for the Python package is in thebinomialbiasfolder.The script for generating the figure in the paper is in thescriptsfolder.Continuous integration tests are in thetestsfolder.Older Jupyter and Matplotlib versions are available in thearchivefolder.
Package: binooculars
binocularsA tiny, yet blazingly fast machine learning library written in Rust with Python interface.
This project was motivated bypolarsandsklearn.
The goal is to learn Rust, have a better understanding of what is happening under the hood of classic ML models, and explore the pitfalls of building a Python package.Example usage>>>frombinoculars.clusterimportKMeans>>>X=[[1,1],[1,2],[2,1],[2,2],[5,5],[5,6],[6,5],[6,6]]>>>kmeans=KMeans(n_clusters=2,init="random",max_iter=100,random_state=0)>>>kmeans.fit(X)>>>kmeans.predict(X)[0,0,0,0,1,1,1,1]>>>kmeans.get_centroids()[[1.5,1.5],[5.5,5.5]]
Package: binopt
===============================binopt===============================.. image:: https://img.shields.io/pypi/v/binopt.svg:target: https://pypi.python.org/pypi/binopt.. image:: https://img.shields.io/travis/yhaddad/binopt.svg:target: https://travis-ci.org/yhaddad/binopt.. image:: https://readthedocs.org/projects/binopt/badge/?version=latest:target: https://binopt.readthedocs.io/en/latest/?badge=latest:alt: Documentation Status.. image:: https://pyup.io/repos/github/yhaddad/binopt/shield.svg:target: https://pyup.io/repos/github/yhaddad/binopt/:alt: Updates.. image:: https://zenodo.org/badge/86721620.svg:target: https://zenodo.org/badge/latestdoi/86721620This package is aiming to categorize labeled data in terms of a global figure of merit. In high energy physics, categorization of collision data is done by maximizing the discovery significance. This package run on unbinned binary datasets.installation************Install like any other python package::pip install binopt --useror::git clone git@github.com:yhaddad/binopt.gitcd binopt/pip install .Getting started***************.. code-block:: pythonsevent = 1000bevent = 10000X = np.concatenate((expit(np.random.normal(+2.0, 2.0, sevent)),expit(np.random.normal(-0.5, 2.0, bevent))))Y = np.concatenate((np.ones(sevent),np.zeros(bevent)))W = np.concatenate((np.ones(sevent), np.ones(bevent)))binner = binopt.optimize_bin(nbins=3, range=[0, 1],drop_last_bin=True,fix_upper=True,fix_lower=False,use_kde_density=True)opt = binner.fit(X, Y, sample_weights=W,method="Nelder-Mead",breg=None, fom="AMS2")print "bounds : ", opt.xprint "signif : ", binner.binned_score(opt.x)print "Nsig   : ", binner.binned_stats(opt.x)[0]print "Nbkg   : ", binner.binned_stats(opt.x)[1]* Free software: GNU General Public License v3* Documentation: https://binopt.readthedocs.io.Features--------* TODOCredits---------This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template... _Cookiecutter: https://github.com/audreyr/cookiecutter.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage=======History=======0.1.0 (2017-04-06)------------------* First release on PyPI.
Package: bin-optimize
bin_optimizeThis project is an extension to binpacking problem. The utility provides
ability to optimize existing bins which are already allocated using any
bin_packing algorithm into n-1 bins.The items in the bins are presented as a tuple of an identifier and
volume of the item.Usage:>>> from bin_optimize import optimize
>>> bins = {'b1': [('a1', 6), ('a5', 4.5), ('a9', 4)],
            'b2': [('a2', 4), ('a6', 5), ('a10', 2)],
            'b3': [('a3', 7), ('a7', 2), ('a11', 3)],
            'b4': [('a4', 2), ('a8', 2), ('a12', 2), ('a13', 2), ('a15', 4)]}
>>> bin_to_reduce = 'b4'
>>> optimize(bins, bin_to_reduce)
    {'b1': [('a1', 6), ('a5', 4.5), ('a9', 4), ('a8', 2)],
     'b2': [('a2', 4), ('a6', 5), ('a10', 2), ('a12', 2), ('a15', 4)],
     'b3': [('a3', 7), ('a7', 2), ('a11', 3), ('a13', 2), ('a4', 2)]}The input bins can also have an empty bin.>>> from bin_optimize import optimize
>>> bins = {'b1': [('a1', 6), ('a5', 4.5), ('a9', 4)],
            'b2': [('a2', 4), ('a6', 5), ('a10', 2)],
            'b3': [],
            'b4': [('a4', 2), ('a8', 2), ('a12', 2), ('a13', 2), ('a15', 4)]}
>>> bin_to_reduce = 'b4'
>>> optimize(bins, bin_to_reduce)
{'b1': [('a1', 6), ('a5', 4.5), ('a9', 4)],
 'b2': [('a2', 4), ('a6', 5), ('a10', 2)],
 'b3': [('a12', 2), ('a13', 2), ('a15', 4), ('a4', 2), ('a8', 2)]}
Package: binotel
Binotel package for Python languageThis package provides Python implementation of some Binotel api.InstallationUse thepipcommand:$ pip install binotelRequirementsBinotel package tested against Python 3.8.1ExamplefrombinotelimportBinotel# Creating binotel objectb=Binotel('your_key','your secret')# Get all incoming calls since datecalls=b.all_incoming_calls_since(1370034000)print(calls)
Package: binp
Basic Integration PlatformProvides a platform for automation with code-first approach,
with embedded batteries:Tracing (journals)Internal and user-defined APIUltra-light but rich mobile-first UIEmbedded key-value storageIt is heavily inspired by node-red and aims to provide same
enjoyment during development but without mess of nodes and connections
for tasks a little bit more complicated than just hello world.The platform also tries to be easy in deployment and maintaining.
Code could be stored in a SCM (ex: git) and persistent storage is just a single file that
could be backed up and restored trivially.Because memory and CPU consumption relatively low a solution based on the platform
could be launched even on Raspberry Pi Zero with 512MB RAM.Installpip install binp uvicorn[standard]Example:fromrandomimportrandintfrombinpimportBINPbinp=BINP()@binp.app.post('/random',response_model=int)@binp.journalasyncdefgenerate_random():"""Generate random number in range 0 ... 1024"""returnrandint(0,1024)@binp.action@binp.journalasyncdefcurrency_rate():"""Fetch currency rate for EUR -> USD"""# go to external serviceeuro=1.3awaitbinp.journal.record('rates fetched',base_currency='USD',euro=euro)Save as 'example.py' and run it byuvicorn example:binp.appTIP: pass--reloadflag touvicornto support automatic reload during developmentIt will exposehttp://127.0.0.1:8000- UI and APIhttp://127.0.0.1:8000/docs- Swagger docs for user-defined APIshttp://127.0.0.1:8000/internal/docs- Swagger docs for internal APIsConfigurationDefault configuration can be changed by environment variables:DEV- setDEV=trueto enable development modeDB_URL- database SQLITE URL, defaultsqlite:///data.dbHTTP port and binding address configured byuvicorn:--port- set listening port, default8000--host- set binding host, default127.0.0.1Foruvicorncommand should be likeuvicorn <python file without .py>:<binp instance>.app