Skip to content

Commit

Permalink
Merge e124ef3 into 15dc15f
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-rogers committed Dec 4, 2018
2 parents 15dc15f + e124ef3 commit 146948f
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ The QGL config file will be created the first time you run `import QGL` or `from
* networkx
* iPython/Jupyter 4.0 (only for Jupyter notebooks)
* ruamel_yaml

## UnitTest data support
This repository uses the Git Large File Storage (LFS) extension to manage a few
UnitTest data files (see https://git-lfs.github.com/).
6 changes: 6 additions & 0 deletions ReadMe_Docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#---------- 14 Nov 2018
This repository uses the MkDocs (v0.17.2) utilities for documentation rendering.
From the repo root directory, "mkdocs --help" shows the options.
"mkdocs build" for example, writes a set of html documents under the ./site subdirectory

(Aside: ./site is NOT currently in the .gitignore file; insertion pending for consistency).
26 changes: 26 additions & 0 deletions renderDocs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
echo ""
echo "#---------- $0 (QGL) start..."
echo ""
#----- Simple script to capture basic documentation rendering logic.

echo "#-----Building QGL docs via ~:"

export CMD="mkdocs build"
echo $CMD
echo ""
$CMD

pushd .

cd site
echo ""
echo "Target QGL documents list as follows:"
pwd
ls -l


echo ""
echo "#---------- $0 (QGL) stop."
echo ""

74 changes: 74 additions & 0 deletions runUnitTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
echo ""
echo "#---------- $0 (QGL) start..."
echo ""
#----- Simple script to capture unittest preparation and invocation logic.

pwd

export szGit_LFS_Path=`which git-lfs`
echo "szGit_LFS_Path: [${szGit_LFS_Path}]"


# Instantiate the git lfs cached data files...
export CMD="git lfs pull"
echo ""
if [ -z ${szGit_LFS_Path} ]; then
echo ""
echo "#--------------------"
echo "# W A R N I N G -- git-lfs extension library unavailable;"
echo "# -- QGL h5 data file processing may fail."
echo "# << [${szGit_LFS_Path}] << 'which git-lfs'"
echo "#--------------------"
else
echo "git-lfs available; retrieving/instantiating cached QGL h5 data files via ~:"
echo $CMD
echo ""
$CMD
fi
echo ""


# Don't forget to set the BBN_MEAS_FILE reference.
export BBN_MEAS_FILE=tests/test_measure.yml

echo ""
echo "#-----Unit-Testing general QGL (BBN_MEAS_FILE=${BBN_MEAS_FILE}) via ~:"
# -f option fails fast
#export CMD="python -m unittest discover . -v -f"
#export CMD="python -m unittest discover . -v"
# Trimm'ed down (non LFS unitest calls) syntax as follows:
export CMD="python -m unittest tests/test_A*.py tests/test_C*.py tests/test_Scheduler.py tests/test_config.py tests/test_pulse_types.py -v"
echo $CMD
echo ""
$CMD

if [ -z ${szGit_LFS_Path} ]; then
echo ""
echo "#----- W A R N I N G:"
echo " Fast-failing unittest modules test_QGL.py, and test_Sequences.py,"
echo " currently, due to git lfs data file dependencies; in-short, the"
echo " docker continuumio/miniconda load appears to omit the necessary"
echo " git-lfs library installation."
echo ""
echo " Without the git-lfs library extension, h5 data calls from these"
echo " modules typically error out with ~:"
echo " OSError: Unable to open file (file signature not found)"
echo ""
echo " If/when the git-lfs library becomes available in the docker load, "
echo " remove the \"-f\"from the invocation, below:"
fi

echo ""
echo "#----- Testing LFS data file dependent QGL modules via ~:"
# Careful -- in this format (tests.moduleName) DON'T cite the .py suffix
# (it will render an odd error regarding missing 'py' attribute)
export CMD="python -m unittest tests.test_QGL tests.test_Sequences -v -f"
echo $CMD
echo ""
$CMD

echo ""
echo "#---------- $0 (QGL) stop."
echo ""

14 changes: 14 additions & 0 deletions tests/test_QGL.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,21 @@ def load(self):
'Warning: valid waveform file for {0} not found at: {1}'.format(
caseName, fileName))
continue
# -----
# print( "\n\rDBG::Calling \"with h5py.File( {0}, 'r')\"...".format( fileName) )
# -----
# The following pulls in Git Large File Storage (LFS) data files
# from cached signature references; if the h5py.File call fails
# with an OSError, double-check git-lfs library installation (in
# addition to git) -- <https://git-lfs.github.com/>
#
# Where git-lfs was NOT installed the h5py.File() call was observed
# returning:
#
# OSError: Unable to open file (file signature not found))
#
with h5py.File(fileName, 'r') as FID:
# print( "DBG::FID: {0}".format( FID))
for name, waveform in FID['/channels'].items():
validWaveform[name] = waveform[:]
self.validWaveforms[caseName] = validWaveform
Expand Down
3 changes: 3 additions & 0 deletions tests/test_Scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ def test_measurements(self):

# should be unchanged
assert seq == result

if __name__ == "__main__":
unittest.main()
12 changes: 12 additions & 0 deletions tests/test_Sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from QGL.Channels import Edge, Measurement, LogicalChannel, LogicalMarkerChannel, PhysicalMarkerChannel, PhysicalQuadratureChannel
from QGL.drivers import APSPattern, APS2Pattern, TekPattern

# Pulled in logger to help debug stand-alone run issue with the config.AWGDir
# (the configuration was NOT gettng loaded when run independently)
#
import logging
logger = logging.getLogger( 'sequences')

class AWGTestHelper(object):
testFileDirectory = './tests/test_data/awg/'
Expand Down Expand Up @@ -93,6 +98,13 @@ def get_qubits(self):
def set_awg_dir(self, footer=""):
cn = self.__class__.__name__

if None == QGL.config.AWGDir:
logger.warning( "\n\r#----- EEE NULL QGL.config.AWGDir {%s} cited; calling load_config()...", QGL.config.AWGDir)
QGL.config.load_config()
logger.warning( "#----- Post load-config QGL.config.AWGDir: {%s}.\n\r", QGL.config.AWGDir)
#else:
# logger.warning( "\n\r#----- Using QGL.config.AWGDir {%s} 8-p", QGL.config.AWGDir)

self.awg_dir = os.path.abspath(QGL.config.AWGDir + os.path.sep + cn)
self.truth_dir = os.path.abspath(self.testFileDirectory + os.path.sep +
cn)
Expand Down
9 changes: 8 additions & 1 deletion tests/test_pulse_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def setUp(self):
self.q3 = QubitFactory('q3')
self.q4 = QubitFactory('q4')

@unittest.skip("Type promition for CNOT(q1, q2) * X(q3) gives PulseBlock not CompoundGate. Looking into this issue.")
# This appears to run successfully with the skip commented out;
# TJR, 07 Nov 2018
#@unittest.skip("Type promition for CNOT(q1, q2) * X(q3) gives PulseBlock not CompoundGate. Looking into this issue.")
def test_promotion_rules(self):
q1, q2, q3, q4 = self.q1, self.q2, self.q3, self.q4

Expand All @@ -28,3 +30,8 @@ def test_promotion_rules(self):
assert( type(CNOT_CR(q1, q2) * X(q3)) == CompoundGate )
assert( type(X(q3) * CNOT_CR(q1, q2)) == CompoundGate )
assert( type(CNOT_CR(q1, q2) * CNOT_CR(q3, q4)) == CompoundGate )

# Added to support simple python invocation
#
if __name__ == "__main__":
unittest.main()

0 comments on commit 146948f

Please sign in to comment.