Skip to content

Commit 6a90b5d

Browse files
committed
2.0.2
1 parent 1a25c2b commit 6a90b5d

File tree

12 files changed

+343
-160
lines changed

12 files changed

+343
-160
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ Python For Change
44
Welcome to the community!
55
-------------------------
66

7-
Python For Change is a **open source** project. {: .fs-6 .fw-300 }
7+
Python For Change is a **open source** project.
88

99
[Get started
10-
now](https://github.com/PythonForChange/pythonforchange.github.io){:
11-
.btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } [View on
12-
Github](https://github.com/PythonForChange){: .btn .fs-5 .mb-4 .mb-md-0
13-
}
10+
now](https://github.com/PythonForChange/pythonforchange.github.io)
11+
12+
[View on
13+
Github](https://github.com/PythonForChange)
14+
1415

1516
### Our software
1617

17-
- [Covid Plot](https://pythonforchange.github.io/covidplot)
18-
- [Python For Change
19-
FilesFormat](https://pythonforchange.github.io/filesformat)
18+
- [Covid Plot](https://pythonforchange.github.io/covidplot)
19+
- [Python For Change Format](https://pythonforchange.github.io/format)
20+
- [Cell](https://pythonforchange.github.io/cell)
2021

2122
### Installation (last stable version)
2223

README.rst

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ Python For Change
44
Welcome to the community!
55
-------------------------
66

7-
Python For Change is a **open source** project. {: .fs-6 .fw-300 }
7+
Python For Change is a **open source** project.
88

9-
`Get started
10-
now <https://github.com/PythonForChange/pythonforchange.github.io>`__\ {:
11-
.btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } `View on
12-
Github <https://github.com/PythonForChange>`__\ {: .btn .fs-5 .mb-4
13-
.mb-md-0 }
9+
`Get started now <https://github.com/PythonForChange/pythonforchange.github.io>`_.
10+
11+
`View on Github <https://github.com/PythonForChange>`_.
1412

1513
Our software
1614
~~~~~~~~~~~~
1715

18-
- `Covid Plot <https://pythonforchange.github.io/covidplot>`__
19-
- `Python For Change
20-
FilesFormat <https://pythonforchange.github.io/filesformat>`__
16+
- `Covid Plot <https://pythonforchange.github.io/covidplot>`_.
17+
- `Python For Change Format <https://pythonforchange.github.io/format>`_.
18+
- `Cell <https://pythonforchange.github.io/cell>`_.
2119

2220
Installation (last stable version)
2321
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -40,46 +38,43 @@ Contributing
4038
~~~~~~~~~~~~
4139

4240
Learn more about how to help others contribute, check out the
43-
`CONTRIBUTING
44-
GUIDELINES <https://pythonforchange.github.io/CodeOfConduct/>`__ for
41+
`CONTRIBUTING GUIDELINES <https://pythonforchange.github.io/CodeOfConduct/>`_ for
4542
repository contributors.
4643

4744
Credits
4845
~~~~~~~
4946

5047
- **Emmanuel Norambuena** - *initial work* -
51-
`Eanorambuena <https://github.com/eanorambuena>`__
48+
`Eanorambuena <https://github.com/eanorambuena>`_
5249
- **Community** - *contributing*
5350
- **Andrés Villanueva** - *this web page is based on the README made by
5451
him* - `Villanuevand <https://github.com/Villanuevand>`__
5552
- **Just the Docs** - *this site uses their documentation theme for
56-
Jekyll* - `View in
57-
Github <https://github.com/pmarsceill/just-the-docs>`__
53+
Jekyll* - `View in Github <https://github.com/pmarsceill/just-the-docs>`_
5854

5955
License
6056
~~~~~~~
6157

62-
This proyect is under the `MIT
63-
License <https://pythonforchange.github.io/license>`__.
58+
This proyect is under the `MIT License <https://pythonforchange.github.io/license>`_.
6459

6560
Made with
6661
~~~~~~~~~
6762

68-
- `Python <https://www.python.org/>`__ - Programming language
63+
- `Python <https://www.python.org/>`_ - Programming language
6964

7065
Wiki
7166
~~~~
7267

7368
You can find much more about how to use this project in our
74-
`Wiki <https://github.com/PythonForChange/pythonforchange.github.io/wiki>`__
69+
`Wiki <https://github.com/PythonForChange/pythonforchange.github.io/wiki>`_
7570
📖
7671

7772
Support or Contact
7873
~~~~~~~~~~~~~~~~~~
7974

8075
Having trouble with Python For Change Software? Check out our
81-
`documentation <https://pythonforchange.github.io/>`__.
76+
`documentation <https://pythonforchange.github.io/>`_.
8277

8378
--------------
8479

85-
⌨️ with ❤️ by `Eanorambuena <https://github.com/eanorambuena>`__ 😊
80+
⌨️ with ❤️ by `Eanorambuena <https://github.com/eanorambuena>`_ 😊

pyforchange/cell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def __init__(self,name,adress,count,n):
77
self.n=n
88
self.adress=adress
99
self.newname=self.name+"1"
10-
t1="from cell import *\n"
10+
t1="from pyforchange.cell import *\n"
1111
t2=self.newname+"=Cell(\""+self.newname+"\",\""+adress+"\","+str(self.count+1)+","+str(n)+")\n"
1212
t3="if "+self.newname+".count>="+str(n)+":\n"
1313
t4="\tclearall("+str(n)+","+self.newname+".adress)\n"

pyforchange/pfcf.py

Lines changed: 0 additions & 127 deletions
This file was deleted.

pyforchange/pfcf/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from pyforchange.pfcf.files import *
2+
from pyforchange.pfcf.read import *
3+
from pyforchange.pfcf.utils import *

pyforchange/pfcf/code.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from pyforchange.pfcf.utils import *
2+
import pyforchange.pfcf.codel.qiskit as q
3+
4+
def codef(codel: str,text: str): #code function
5+
form="_compile.py"
6+
f=open(codel+form,"w")
7+
t=""
8+
if codel=="qiskit":
9+
t=qiskit(text)
10+
f.write(t)
11+
f.close()
12+
13+
def qiskit(text: str):
14+
T=""
15+
T+="from qiskit import QuantumCircuit, execute, Aer\n"
16+
T+="from qiskit.visualization import plot_histogram,display\n"
17+
s=0
18+
command=""
19+
param=""
20+
Q=0
21+
gate=""
22+
gatecount=0
23+
qdef=0
24+
for i in text:
25+
if i==",":
26+
pass
27+
elif s==1: #settings mode on
28+
if i!=" ":
29+
command+=i
30+
else:
31+
s=2
32+
elif s==2:
33+
if i!=" " and i!="\n":
34+
param+=i
35+
else:
36+
T+=q.settings(command,param)
37+
command=""
38+
param=""
39+
s=0
40+
elif i=="$":
41+
s=1
42+
elif qdef==1:
43+
if i=="q":
44+
Q+=1
45+
elif i=="\n":
46+
qdef=2
47+
T+="circuit=QuantumCircuit("+str(Q)+","+str(Q)+")\n"
48+
elif qdef==2:
49+
if i!="\n" and i!=" ":
50+
gate+=i
51+
elif i==" ":
52+
gatecount+=0.5
53+
T+=q.quantum(gate,gatecount)
54+
gate=""
55+
else:
56+
T+=q.quantum(gate,gatecount)
57+
gate=""
58+
gatecount=0
59+
elif i=="q":
60+
qdef=1
61+
Q+=1
62+
return T
63+

pyforchange/pfcf/codel/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from pyforchange.pfcf.codel.qiskit import *

pyforchange/pfcf/codel/qiskit.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from pyforchange.pfcf.utils import *
2+
3+
def settings(command: str,param):
4+
t=""
5+
if command=="host":
6+
t0="s=1024\nbackend=Aer.get_backend('"+param+"')\n"
7+
t1="job=execute(circuit, backend, shots=s)\n"
8+
t2="result=job.result()\n"
9+
t3="counts=result.get_counts(circuit)\n"
10+
t=t0+t1+t2+t3
11+
elif command=="shots":
12+
t="s="+param
13+
elif command=="hist":
14+
t1="graph=plot_histogram(counts)\n"
15+
t2="display(graph)\n"
16+
t=t1+t2
17+
elif command=="draw":
18+
t="circuit.draw('mpl')\n"
19+
elif command=="inject":
20+
t=param+"\n"
21+
return t
22+
23+
def quantum(gate: str,n):
24+
t=""
25+
N=floor(n)
26+
n=str(N)
27+
T="circuit."
28+
if len(gate)==1:
29+
t=T+gate.lower()+"("+n+")\n"
30+
elif gate==".---X":
31+
t=T+"cx("+n+","+str(N+1)+")\n"
32+
elif gate=="X---.":
33+
t=T+"cx("+str(N+1)+","+n+")\n"
34+
else:
35+
number=""
36+
b=0
37+
for i in gate:
38+
if i!="c":
39+
number+=i
40+
else:
41+
b=1
42+
if b==1:
43+
t=T+"measure("+n+","+number+")\n"
44+
return t

0 commit comments

Comments
 (0)