Saravanan666/pypi-org huggingface dataset:
Package: cputils
cputilsUtilities for Competitive Programming.Features:Download samples fromkattis,aceptaelreto.Test in c, cpp, python, java, rust, ruby, bash, nim.Submit to kattis.Tests only for complete textual match, ignoring leading and trailing whistespaces.InstallationAssuming you have aPython3distribution withpip, install the package running:pip3installcputilsUsagecpconfigTo create a config file, runcpconfigcpsamplesTo download the samples of a problem runcpsamples<problem>cptestTo test a solution or set of solutions runcptest<problem>/<solution(s)>Pro-tip: you can use glob patterns likeproblem/code*orproblem/*.py.cpsubmitTo submit a solution (only kattis)cpsubmit<problem>/<solution(s)>DevelopmentTestingTesting requires installing the test extra. Furthermore, some tests require the languages to be installed and available.To run all tests:maketestTo run a single test module:pytesttests/test_<test_name>.py
Package: cpvlib
cpvlibis an open source tool that provides a set of functions and classes
for simulating the performance of concentrator photovoltaic (CPV) systems,
a specific type of photovoltiac systems composed of lenses and/or
mirrors that focus sunlight onto small cells. It makes special emphasys on
static micro CPV systems with internal tracking.Documentation:http://cpvlib.readthedocs.ioSource code:https://github.com/isi-ies-group/cpvlib
Package: cpyberry-pybencode
pybencodeSimple bencode library for pythonRequirementspython 3.6, 3.7, 3.8, 3.9Installationpipinstallcpyberry-pybencodeUsageimportpybencodepybencode.encode(256)# return b"i256e"pybencode.encode(b"neko")# return b"4:neko"pybencode.encode([1,2,3])# return b"li1ei2ei3ee"pybencode.encode({1:b"kuro",2:b"sakura"})# return b"di1e4:kuroi2e6:sakurae"Nested lists and dicts can also be encoded.pybencode.encode([b"cat",1024,[b"meow",b"woof"]])# return b"l3:cati1024el4:meow4:woofee"pybencode.encode({1:{b"yuki":b"ghost"}})# return b"di1ed4:yuki5:ghostee"Decode can do the opposite of the above.Similarly, you can decode nested list and dict.pybencode.decode(b"5:night")# return "night"pybencode.decode(b"i128e")# return 128python.decode(b"di1ed4:yuki5:ghostee")# return {1: {b"yuki": b"ghost"}}python.decode(b"l3:cati1024el4:meow4:woofee")# return [b"cat", 1024, [b"meow", b"woof"]]If you want to encode the string to bencode format, you need to encode it with any character code first.For examplestring="coppelia"pybencode.encode(string.encode("latin-1"))
Package: cpyberry-pytransform
pytransformA library that applies arbitrary functions to each element of list type and dict type objectsFunctions that defines the conversion process, which takes each element before conversion as an argument and returns each element after conversion, is called recursively, so it also supports nested list and dictionary.Requirementspython 3.5, 3.6, 3.7, 3.8, 3.9Installationpipinstallcpyberry-pytransformUsageWhen you want to multiply each element of the list by 2, you can write:importpytransformdefoperation_double(element:int,origin:list)->int:# The first argument contains each element of the original list.# The original list is stored in the second argument.returnelement*2pytransform.transform_list([1,2,3],operation_double)# return [2, 4, 6]pytransform.transform_list(origin=[1,2,3],operation=operation_double)# return [2, 4, 6]When you want to insert "_neko" at the end of each key in the dictionary and "_inu" at the end of each value, you can write:defoperation_key(key:str,origin:dict,value:str):# The first argument contains each key of the original dictionary.# The original dictionary is stored in the second argument.# The third argument contains the value corresponding to each key in the original dictionary.returnkey+"_neko"defoperation_value(value:str,origin:dict,key:str):# The first argument contains each key of the original dictionary.# The original dictionary is stored in the second argument.# The third argument contains the value corresponding to each key in the original dictionary.returnvalue+"_inu"pytransform.transform_dictionary(origin={"meow":"woof"},operation_key=operation_key,operation_value=operation_value)# return {"meow_neko", "woof_inu"}The above functions are called recursively, so they also support nested list and dictionary.pytransform.transform_list([1,2,[3,4,5]],operation_double)# return [2, 4, [6, 8, 10]]pytransform.transform_dictionary(origin={"meow":{"pows":"woof"}},operation_key=operation_key,operation_value=operation_value)# return {"meow_neko": {"pows_neko": "woof_inu"}}Foundercpyberryemail:cpyberry222@gmail.com
Package: cpymad
cpymad is aCythonbinding toMAD-Xfor giving full control and access to a
MAD-X interpreter in python.Note:Support for 32bit builds and python 2.7 has been removed in version
1.8.0. Support for python 3.5 has been removed in version 1.10.0.Note:python 3.6 and manylinux1 have reached EOL. Support will be
removed in a future release.LinksDocumentation:InstallationGetting startedSource code:MAD-X sourceIssue trackerReleasesLicenseThe cpymad source code itself is under free license, seeCOPYING.rst.However, the MAD-X software package and henceforth all binary cpymad package
distributions areNOT FREE., seeMAD-X license.CHANGELOGThe full changelog is available online inCHANGES.rst.Reporting issuesNote that cpymad links against a custom build of MAD-X that may differ from
the official CERN command line client. This binary may have problems that the
official binary does not have and vice versa.Therefore, before reporting issues, please make sure that you report to the
correct recipient. First try to check if that problem remains when using the
MAD-X command line client distributed by CERN, then report the issue:to CERN if it can be reproduced with the official MAD-X executableto us if it can not be reproduced with the official MAD-X executablePlease keep the code in the bug report as minimal as possible, i.e. remove
everything that can be removed such that the issue still occurs. This will
save us some effort in handling the error report.Please post the code inline, don’t upload zip files, or link to external
sources, if possible.Bug reports should describe the issue and contain a minimal python script
similar to this:fromcpymad.madximportMadxm=Madx()m.call('commands.madx')as well as the content of thecommands.madxfile.You can create this file from your original python code with a minimal change
that tells cpymad to write all MAD-X commands to a file:m=Madx(command_log='commands.madx')...Now run this file with the official MAD-X command line client:madx commands.madxIfmadxreports the same error, check if there are any syntax errors in
thecommands.madxfile. These may result from incorrect usage of cpymad,
or bugs in cpymad.
Package: c-py-py
C-Py-Pyfromcppimport*x=(cpp)[std::vector<int>v({1,2,3})]x.push_back(4)(cpp)[std::cout]<<"Vector x: "<<x<<(cpp)[std::endl]# -> prints 'Vector x: [1, 2, 3]'foriinauto&x:(cpp)[std::cout]<<"Incrementing "<<i<<"..."<<(cpp)[std::endl]# -> prints 'Incrementing 1...', 'Incrementing 2...', etc.i+=1(cpp)[std::cout]<<"Vector after: "<<x<<(cpp)[std::endl]# -> prints 'Vector after: [2, 3, 4, 5]'How?Template notationThe<>template notation was quite difficult to pull off. Python has a weird concept of multiple-boolean-operators, so the following:x=(cpp)[std::vector<int>v({1,2,3})]is equivalent tox=(cpp)[std::((vector<int)and(int>v({1,2,3})))]We can then overwrite the less than operator for the objectvectorto simply return True, so that it's negligible:x=(cpp)[std::(Trueand(int>v({1,2,3})))]x=(cpp)[std::(int>v({1,2,3}))]Now we can overwrite the less than operator on a different class (v, in this case) so that it simply takes in a fully formed vector object asselfand a type as the comparison, then tries to transform that into a new vector of the type in the comparison. This would be equivalent to:x=(cpp)[std::(v({1,2,3}))]C++-style namespacingNearly there. For the namespacing (::), we turn to the only place in the Python syntax where adjacent colons are allowed: slice notation. The code above is equivalent to:x=cpp[slice(std,None,v({1,2,3}))]We can definecppto be an instance of a class that overrides the__getitem__method to simply return the rightmost part of the slice:classcpp:def__getitem__(self,other:slice):returnother.stepcpp=cpp()Now the code is equivalent to just:x=v({1,2,3})wherevis essentially a thin wrapper aroundlist.coutcoutperforms a small sleight-of-hand. Since Python is evaluated left-to-right, we have to have the<<operator reduce each of the expressions down into a single format string, then pass that toendlto actually do the printing. We do this by makingcout.lshift() return aCoutable:class_Coutable:def__init__(self,o)->None:self._total_str:str=format(o)def__lshift__(self,other:Any)->Self:ifotherisendl:print(self._total_str)self._total_str=self._total_str+format(other)returnselfThis class will just keep accumulating objects' formatted representations until it hits endl, when it will print everything out.Taking referencesUnfortunately, Python'sfor _ in _:syntax is pretty rigid, and won't allow any operations in-between for and in, so we have to stick theauto&on the right side. ThisWhy?Scientists are hard at work trying to come up with an answer to that question.
Package: cpyquickhelper
cpyquickhelper: python + C++ in different wayscpyquickhelperis a template to create a module with
C functions in different ways. It implements functionmeasure_time:from cpyquickhelper.numbers import measure_time
from math import cos

res = measure_time(lambda: cos(0.5))
print(res){'average': 3.909366205334663e-06, 'deviation': 6.238702219064397e-07,
 'min_exec': 3.635883331298828e-06, 'max_exec': 5.776062607765198e-06,
 'repeat': 10, 'number': 50, 'context_size': 240}It also implements an event profiler: it logs the timestamp
for every event such as functions call or returns, memory allocations.import io
import numpy
from cpyquickhelper.profiling import EventProfiler

def custom_array(N):
    a = numpy.zeros((N, N))
    a[:, 0] = 1
    a[0, :] = 1
    return a

ev = EventProfiler(impl='c')
ev.start()

custom_array(3)

ev.stop()

df = ev.retrieve_results()  # DataFrame
st = io.StringIO()
df.to_csv(st, index=False)
print(st.getvalue().replace("\r", ""))time,value1,value2,event,name,mod,lineno,from_name,from_mod,from_line
822467345556400,0,0,return,_setup_profiler,cpyquickhelper/profiling/event_profiler.py,153,start,cpyquickhelper/profiling/event_profiler.py,126
822467345566700,0,0,c_call,_profiling_register_pyinstance,cpyquickhelper.profiling._event_profiler_c,109,_profiling_register_pyinstance,k.py,19
822467345569000,0,0,c_return,_profiling_register_pyinstance,cpyquickhelper.profiling._event_profiler_c,109,_profiling_register_pyinstance,k.py,19
822467345569700,0,0,return,start,cpyquickhelper/profiling/event_profiler.py,109,<module>,k.py,19
822467345575100,0,0,call,custom_array,k.py,5,<module>,k.py,19
822467345579600,0,0,c_call,zeros,numpy,5,zeros,k.py,19
822467345584300,2698130437280,32,malloc,start,cpyquickhelper/profiling/event_profiler.py,109,<module>,k.py,19
822467345590500,0,0,c_return,zeros,numpy,5,zeros,k.py,19
822467345598200,0,0,free,start,cpyquickhelper/profiling/event_profiler.py,109,<module>,k.py,19
822467345600400,0,0,free,start,cpyquickhelper/profiling/event_profiler.py,109,<module>,k.py,19
822467345600900,0,0,return,ndarray,numpy,5,ndarray,k.py,19
822467345603200,0,0,call,stop,cpyquickhelper/profiling/event_profiler.py,128,<module>,k.py,19
822467345604900,0,0,call,_restore_profiler,cpyquickhelper/profiling/event_profiler.py,168,stop,cpyquickhelper/profiling/event_profiler.py,151
822467345605600,0,0,c_call,setprofile,sys,168,setprofile,cpyquickhelper/profiling/event_profiler.py,151Links:GitHub/cpyquickhelperdocumentationBlog
Package: cpytest
CPYTESTCPYTESTis a python package that allows you to write unit tests for your C code. It usescffito generate python bindings for C code, so that you can use the fullpytestframework for testing your C code.Installationt.b.d.Runing the ExampleDependenciespipinstallpoetrypytest
sudoaptinstallgcovr
sudoaptinstalllcovBuild and Run Example TestUsing Poetrypoetryinstall
poetryrunpipinstallpycparser==2.21
poetryrunpython3-mcpytestexample/test/cpytest.yaml
poetryrunpytestexample/test/test_example.pyUsing virtualenvvirtualenv.venvsource.venv/bin/activate
poetryinstall
poetryrunpipinstallpycparser==2.21
python3-mcpytestexample/test/cpytest.yaml
pytestexample/test/test_example.pyGenerate Coveragelcov--capture--directoryexample/src--base-directoryexample/test/build--output-filecoverage.info--rclcov_branch_coverage=1--no-external
genhtmlcoverage.info--output-directorycoverage_report--rcgenhtml_branch_coverage=1lscoverage_report/index.htmlLimitationspycparser/pycparserextversion conflictpycparserextrequirespycparser==2.20, but we needpycparser==2.21(for#pragmasupport).poetrydoesn't solve this conflict for us, but we can manually installpycparser=2.21using poetry:poetry run pip install pycparser==2.21. The correspondingpip installerror that is shown can be ignored.#pragmavs.__attribute__((packed))supportpycparserdoesn't support__attribute__((packed))on structs, but it supports#pragma pack. We need to use#pragma packin order to the correct python code for packed structs.__attribute__limitations ofpycparserextpycparserexthas only limited support for GCC__attribute__extensions. To avoid problems, we run a postprocessor after the preprocessor, which filters out all__attribute__extensions.DevelopmentRun QAtoxis used to run all QA tools at once.toxDockerRun the Examplecddocker
docker-composeup--buildtest-example-project
docker-composedownRun the interactive docker shelldocker-composeup--build-dshell
docker-composeexecshellbash
docker-composedown
Package: cpytraceafl-regex
cpytraceafl-regexThis is a thinly modified version of Matthew Barnett'smrab-regexregular expression library with
added instrumentation for use when fuzzing python code withcpytraceafl.The intention is for fuzzing harnesses to be able to substitute the builtinremodule
library with this, highly compatible, module and thereby allow AFL to generate examples
which pass regular expressions used in the target or explore their limits in interesting
ways.See the originalREADME.mrab-regex.rstfor more general
information in this library's extended regex features.Recommended usageEarly in the startup of the fuzzing harness, (though after the call toinstall_rewriter()):importregexfromsysimportmodulesmodules["re"]=regexcode later importing/referencing theremodule should instead be using this instrumentedregexcode. Note that before evaluating any regexes,cpytraceafl.tracehook.set_map_start()will need to have been initialized with a memory region to write its intrumentation data
into. Otherwise you'll get segfaults.
Package: cpz
BriefA simple xml parse and build library.Installationpipinstalldb0905Examplesxml to python object>>>importdb0905
>>>xml='<demo><foo>foo</foo><bar>bar</bar></demo>'>>>db0905.loads(xml){'bar':'bar','foo':'foo'}>>>db0905.loads(xml,strip_root=False){'demo':{'bar':'bar','foo':'foo'}}>>>xml='<demo><foo>foo</foo><bar>1</bar><bar>2</bar></demo>'>>>db0905.loads(xml){'bar':['1','2'],'foo':'foo'}python object to xml>>>data={'demo':{'bar':['1','2'],'foo':'<foo>'}}>>>db0905.dumps(data)'<?xml version="1.0" encoding="utf-8"?><demo><foo><![CDATA[<foo>]]></foo><bar><![CDATA[1]]></bar><bar><![CDATA[2]]></bar></demo>'>>>db0905.dumps(data,cdata=False)'<?xml version="1.0" encoding="utf-8"?><demo><foo>&lt;foo&gt;</foo><bar>1</bar><bar>2</bar></demo>'>>>printdb0905.dumps(data,indent=' '*4)<?xmlversion="1.0"encoding="utf-8"?>
<demo><foo><![CDATA[<foo>]]></foo><bar><![CDATA[1]]></bar><bar><![CDATA[2]]></bar>
</demo>DocumentationSeedocs in readthedocsChangelogSeechangelog
Package: cqase-client
custom-qase-clientThis is an unofficial clientQASEOfficial client:https://github.com/qase-tms/qase-pythonAPI QASE:https://developers.qase.io/reference/Guide:https://developers.qase.io/docsInstallationYou can install via pip$ pip install cqase-clientor with poetry$ poetry add -D cqase-clientHow to workFirst, get api token from pagehttps://app.qase.io/user/api/token(See guide)For body and params use dict type, like inrequestslibraryfromcqase.clientimportQaseClientclient=QaseClient(api_token='YOUR_API_TOKEN')code='CODE'# project code# create projectbody={'title':f'Title test project','code':code,'access':'all'}client.projects.create(body=body)# create suitebody={"title":"test suit"}client.suites.create(code=code,body=body)# create casebody={"title":"test case"}client.cases.create(code=code,body=body)# create test runbody={"title":"test run"}client.runs.create(code=code,body=body)# upload attachmentclient.attachments.upload(code,"./cat.jpeg")# finish test runclient.runs.complete(code=code,uuid=1)
Package: cqc
CQC (3.2.3)The classical-quantum combiner (CQC) interface is an interface between higher layers and hardware in a Quantum Internet. It comes with a Python, C and Rust library for constructing CQC messages. The Python library is definitely the best place to get started.Documentation of CQC can be found athttps://softwarequtech.github.io/CQC-Python/The CQC can be used to either program hardware which supports the interface or the simulatorhttps://github.com/SoftwareQuTech/SimulaQron.More information about CQC can also be found in the paper on SimulaQron athttps://arxiv.org/abs/1712.08032
Package: cqdm
cqdmA drop-in replacement for the populartqdm library, accelerated with C bindings.UsageInstall withpip install cqdm.Replace usages oftqdm.tqdmwithcqdm.cqdm. This can be done
succinctly by changing yourimportstatement:# was: from tqdm import tqdmfromcqdmimportcqdmastqdmPerformanceThis library has about 1/5 the overhead of standardtqdm:This graph was generated by runningperformance.py.ImpactThere are over 40 million monthly downloads oftqdm. Let's
assume there are 40 million instances oftqdmrunning every
day, each performing 100,000 iterations. This totals 92,000
seconds or 9.58 days of overhead, per day. Using a reasonable
price for CPU time on AWS, this equates to around $10
of compute, per day globally.Switching tocqdmwould reduce this overhead by 4/5.
That means, if everyone switched to usingcqdm,
we could save $8 in CPU time per day, globally.Of course, this ignores the increased time for installs,
compilation, etc., which is nearly an order of magnitude
greater than the time saved...DevelopingTo developcqdmlocally:Create a freshvenvInstalltqdmwithpip install tqdmBuild the C-extension withpython setup.py buildInstall it withpython setup.py installRun the demo withpython demo/demo.pyPerformanceTo generate performance graphs:Installmatplotlibwithpython3 -m pip install matplotlibIf on linux, then it might be necessary to install a gui backend forplt.show()to function. Do so withsudo apt-get install python3-tkGenerate the performance graph withpython demo/performance.py
Package: cqfbt
Cornell Quant Fund Backtester (cqfbt)EngineAnEngineis the main component in our backtester. It accepts strategies and simulates them on the price data it is initialized with, and can output a variety of metrics on their performance.TheEngineis initialized with a start date and end date to pull data for, as well as the periodicity of the data. Price data is pulled from Yahoo Finance via theyfinancepackage. Optionally, theEnginecan also be initialized with a list of Yahoo Finance tickers to load price data for.A feature of theEngineis the ability to set transaction costs. These must be set via theEngine.set_transaction_costsmethod, which takes either a float representing a uniform transaction cost or a list of floats for each portfolio asset.TheEnginealso contains methods that compare portfolio returns to a market benchmark. This market benchmark is set to theSPX,DJI, orNDAQticker, depending on which one is included in the list of tickers to load price data for during initialization. If more than one benchmark ticker appears in the ticker list, the market benchmark is set to the benchmark ticker that appears last in the ticker list. If no benchmark ticker is included in the ticker list, the default is theSPYticker.StrategyAStrategyis an abstract class that requires the user of the backtester to implment the method 'execute()'. This function can access memory, and use incoming data to decide which orders the engine should to attempt to close.AStrategyshould inherit the strategy interface defined in the strategy module, and define its 'execute()' function. The execute function should return a list of orders to the engine, which the engine will attempt to execute. An 'InsufficientFundsException' may arise if there is insufficient capital to complete a transaction. In this case, the order list will be cleared, and the 'error' parameter will be set to true, while the same data is passed to 'execute()'. If this error is not addressed, the engine will crash.OrderAnOrderis an object that represents an order submitted to the engine. An order has a boolean value representing buy as True and sell as False, an asset number, a quantity, and optionally, a limit price.
Package: cq-filter
CadQuery object filtering frameworkcq-filter adds a few new workplane methods that take a function argument
of typef: Callable[[CQObject], bool]:filter(f): filters Workplane objectssort(f): orders Workplane objectsgroup(f): groups Workplane objectslast: selects newly created facestoWires: select wires from selected facesAdditionally, it adds subscription support to the Workplane, allowing
selection of objects quickly.RationaleManipulating object selections in cadquery isn't currently possible without breaking out of the fluent API.Using filterFollowing example filters all faces with an Area of more than 100wp=(wp.faces(">Z").filter(lambdaface:face.Area()>100))⚠️ values in cq/occt are often not as exact as you'd expect. For example you might expect a certain
face to have an area of exactly 100 and be included when you filter the area against>= 100, but upon
closer inspection it turns out the area is actually just slightly below 100 (99.999999997). Consider rounding to some
sane precision, likeround(face.Area(), 4)Using sort and subscriptionFollowing example sorts all faces by area and selects the three biggest oneswp=(wp.faces(">Z").sort(lambdaface:face.Area())[-3:])Using group and clusteringSelect the smallest faces that are within 10 units of each otherwp=(wp.faces(">Z").group(Cluster(lambdaface:face.Area(),tol=10)[0]))⚠️group()call will not yet select new objects, but it will create a new workplane object.
Selection should be done immediatelly after the grouping. Grouping data will be erased by
next manipulation of workplane.selecting a range of groups ([0:2]) works as expectedCluster() defaults to a tolerance of1e-4Usinglastto select newly created facesA call to.last(everything=False)attempts to select newly created faces. Wheneverything = Falseit will only
select faces that share all their edges with other new faces. In other words: probably the face you'd want to focus on
after some operation like extrude, cut or revolve will be selected.Supplyingeverything = Truewill select all faces that are new.fromcq_filterimportWorkplanewp=(Workplane().rect(5,5).extrude(2).last().workplane())⚠️lastwill not select faces that were modifiedUsageYou may want to create your own workplane class if you have multiple mixinsfromcq_filterimportCQFilterMixinclassWorkplane(CQFilterMixin,cq.Workplane):passIf you don't have multiple mixins, then the above class can also be directly importedfromcq_filterimportWorkplane
Package: cqh-file
serveopts:port,  端口,默认是8081dir, 要目录timeout, 默认值为60s, 内存缓存的超时时间eg:sudo /home/vagrant/envs/default/bin/cqh_file serve –port=8081 –dir=/www/backup/pathclient目的是为了下载服务器的diropts:url, 地址dir, 本地保存的目录sleep,  睡眠时间,默认是300seg:cqh_file client --url='http://127.0.0.1:8081' --dir=/tmp/backup1

python -m cqh_file client --url="http://192.168.146.129:8081" --dir="D:\backup"