Skip to content

Latest commit

 

History

History
140 lines (98 loc) · 4.11 KB

CONTRIBUTING.md

File metadata and controls

140 lines (98 loc) · 4.11 KB

Contributing scikit-qulacs

Start coding

Set up the project.

  1. First, clone this repository.
git clone git@github.com:Qulacs-Osaka/qulacs-visualizer.git
cd qulacs-visualizer
  1. Install dependencies and development tools.
    The qulacs-visualizer uses poetry to manage the development environment.
poetry install

Next, workflow through modification to merge.

  1. Synchronize with main(not necessary for the first time).
git switch main
git pull # Shorthand for `git pull origin main`
  1. 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
  1. 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.

Code formatting and linting can also be run with make format and make lint.

  1. 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
  1. 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.

Testing

Write tests when you develop a new feature. Tests are executed automatically.

  1. Create test_*.py in tests directory. Describe what to test in the file name.
  2. Create a function whose name starts with test_.
  3. 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.

Generate correct answers for testing

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

CI

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.

Build

The build will generate *.whl and *.tar.gz in the dist folder as artifacts.

poetry build

Documentation

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.

Build document

Run following command.

make html

In doc/build/html, you can find build artifacts including HTML files.