Closed josh146 closed 5 years ago
Merging #7 into master will increase coverage by
1.68%
. The diff coverage is97.59%
.
@@ Coverage Diff @@
## master #7 +/- ##
==========================================
+ Coverage 93.51% 95.19% +1.68%
==========================================
Files 7 10 +3
Lines 802 1083 +281
==========================================
+ Hits 750 1031 +281
Misses 52 52
Impacted Files | Coverage Δ | |
---|---|---|
blackbird_python/blackbird/tests/test_load_dump.py | 100% <100%> (ø) |
|
blackbird_python/blackbird/tests/test_program.py | 100% <100%> (ø) |
|
blackbird_python/blackbird/listener.py | 100% <100%> (ø) |
:arrow_up: |
blackbird_python/blackbird/program.py | 100% <100%> (ø) |
|
blackbird_python/blackbird/__init__.py | 100% <100%> (ø) |
:arrow_up: |
blackbird_python/blackbird/error.py | 20.31% <11.11%> (ø) |
:arrow_up: |
blackbird_python/blackbird/tests/test_listener.py | 99.43% <98.63%> (+0.03%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 3c3e2b0...ade25a0. Read the comment docs.
Note: from my side, after this PR is merged, the Blackbird library is functionally complete. It does 3 simple things, and 3 simple things only:
Defines the Blackbird grammar
Deserializes Blackbird scripts to a Python dataclass
Serializes the Blackbird Python dataclass to a blackbird script
Barring simple maintenance, bug fixes, and potential changes to the Blackbird grammar, there are likely no new features that need to be added.
If changes to the Blackbird grammar are required in the future, having it centralized and versioned here means we can easily deploy new versions of the parser to different components of the ecosystem with minimal issue/effort.
This PR adds several things to the Blackbird library:
A new
BlackbirdProgram
class, to encapsulate a blackbird program using Python data structures. The blackbird parser now automatically returns aBlackbirdProgram
object. This is useful for several reasons:It standardizes how the Blackbird data is represented in Python, and is much easier to document in Sphinx.
It allows us to return an object with properties and methods that provide useful information to the developer/user.
A
BlackbirdProgram.serialize()
method has been added, allowing a loaded/parsed blackbird program to be re-serialized. This can be used by any library that needs to send or save blackbird data, i.e. Strawberry Fields/backends.Top level
load
,loads
,dump
, anddumps
functions have been added, for serializing/deserializing Blackbird program to a file/string. This terminology matches that used for the standard Python JSON library, and also uses the same function signatures, allowing it to almost be a drop in replacement for users familiar with Python JSON.