Set up the project.
- First, clone this repository.
git clone git@github.com:Qulacs-Osaka/qulacs-visualizer.git
cd qulacs-visualizer
- Install dependencies and development tools.
The qulacs-visualizer uses poetry to manage the development environment.
poetry install
Next, workflow through modification to merge.
- Synchronize with
main
(not necessary for the first time).
git switch main
git pull # Shorthand for `git pull origin main`
- Create branch.
The branch name should be a combination of the issue number and the content to be developed.
git switch -c 99-wonderful-model
- Format, lint and test code before commit.
make check
make test
The formatting is only applied to files that are tracked by Git. If you have created a new file, run git add
.
Lint errors should be fixed by hand along error messages.
If this is unavoidable, it is possible to disable it for a specific line. See the documentation for details.
- black #code-style
- isort #skip-processing-of-imports-outside-of-configuration
- flake8 #in-line-ignoring-errors
- mypy #spurious-errors-and-locally-silencing-the-checker
Code formatting and linting can also be run with make format
and make lint
.
- Commit and push modified files.
git add MODIFIED_FILE
git commit
# For the first push in the branch
git push -u origin 99-wonderful-model
# After first push
git push
- Create a pull request(PR) after you finish the development at the branch. Basically you need someone to review your code. If modification is subtle, you might not need a review.
Write tests when you develop a new feature. Tests are executed automatically.
- Create
test_*.py
intests
directory. Describe what to test in the file name. - Create a function whose name starts with
test_
. - Then run tests.
If you use LaTeX, you need to set the environment variable USE_LATEX=yes
. The default is USE_LATEX=no
.
make test
# If you also want to test LaTeX Drawing
make test USE_LATEX=yes
If assertion fail, error contents are displayed with red. If you do not see that, all test are successful.
We use pytest
for testing. Detailed instructions are available in the pytest document.
We also use pytest-mpl to test the images generated by matplotlib.
If you change the code, the output result may change. If the changed code is correct, please re-generate the correct answer data. You can use the following commands for each.
If you use LaTeX, you need to set the environment variable USE_LATEX=yes
. The default is USE_LATEX=no
.
# Circuit Parser
make gen-circuit-parser
# Text-Based Drawing
make gen-text
# Matplotlib Drawing
make gen-mpl
# LaTeX Drawing
make gen-latex USE_LATEX=yes
# Output LaTeX source
make gen-latex-source
Run CI at GitHub Actions. You cannot merge a branch unless CI passes. In CI, we run tests and check code format and linter error. The purpose of CI is
- Share our code works properly in the team.
- Find error you cannot notice at your local machine.
- Avoid unnecessary diff by forcing code format and linter error.
The build will generate *.whl
and *.tar.gz
in the dist
folder as artifacts.
poetry build
API document of this library is available here: https://qulacs-osaka.github.io/qulacs-visualizer
The documentation is built and deployed on pushing(merged from PR) to main
branch.
Run following command.
make html
In doc/build/html
, you can find build artifacts including HTML files.