From 9a7cbf186108237e63d682bddabc25e8c60d959a Mon Sep 17 00:00:00 2001 From: HansBug Date: Sun, 5 Sep 2021 23:08:23 +0800 Subject: [PATCH] dev(hansbug): Init the repo with basic files --- .gitignore | 1085 ++++++++++++++++++++++++++++++++- CONTRIBUTING.md | 3 + Makefile | 26 + cloc.sh | 65 ++ pytest.ini | 5 + requirements-doc.txt | 9 + requirements-test.txt | 11 + requirements.txt | 3 + setup.py | 65 ++ test/__init__.py | 1 + test/config/__init__.py | 1 + test/config/test_meta.py | 9 + treetensor/__init__.py | 0 treetensor/config/__init__.py | 0 treetensor/config/meta.py | 19 + 15 files changed, 1300 insertions(+), 2 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 Makefile create mode 100755 cloc.sh create mode 100644 pytest.ini create mode 100644 requirements-doc.txt create mode 100644 requirements-test.txt create mode 100644 requirements.txt create mode 100644 setup.py create mode 100644 test/__init__.py create mode 100644 test/config/__init__.py create mode 100644 test/config/test_meta.py create mode 100644 treetensor/__init__.py create mode 100644 treetensor/config/__init__.py create mode 100644 treetensor/config/meta.py diff --git a/.gitignore b/.gitignore index b6e47617d..5549398d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,931 @@ +# Created by .ignore support plugin (hsz.mobi) +### Example user template template +### Example user template + +# IntelliJ project files +.idea +*.iml +out +gen +### CVS template +/CVS/* +**/CVS/* +.cvsignore +*/.cvsignore + +### C++ template +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +### CUDA template +*.i +*.ii +*.gpu +*.ptx +*.cubin +*.fatbin + +### SVN template +.svn/ + +### Images template +# JPEG +*.jpg +*.jpeg +*.jpe +*.jif +*.jfif +*.jfi + +# JPEG 2000 +*.jp2 +*.j2k +*.jpf +*.jpx +*.jpm +*.mj2 + +# JPEG XR +*.jxr +*.hdp +*.wdp + +# Graphics Interchange Format +*.gif + +# RAW +*.raw + +# Web P +*.webp + +# Portable Network Graphics +*.png + +# Animated Portable Network Graphics +*.apng + +# Multiple-image Network Graphics +*.mng + +# Tagged Image File Format +*.tiff +*.tif + +# Scalable Vector Graphics +*.svg +*.svgz + +# Portable Document Format +*.pdf + +# X BitMap +*.xbm + +# BMP +*.bmp +*.dib + +# ICO +*.ico + +# 3D Images +*.3dm +*.max + +### Eclipse template +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +#.project + +### Diff template +*.patch +*.diff + +### macOS template +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### CMake template +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### Linux template +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### MicrosoftOffice template +*.tmp + +# Word temporary +~$*.doc* + +# Word Auto Backup File +Backup of *.doc* + +# Excel temporary +~$*.xls* + +# Excel Backup File +*.xlk + +# PowerPoint temporary +~$*.ppt* + +# Visio autosave temporary files +*.~vsd* + +### VisualStudio template +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +### Vim template +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### Backup template +*.bak +*.gho +*.ori +*.orig +*.tmp + +### SublimeText template +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json +sftp-config-alt*.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### C template +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +### VirtualEnv template +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +.Python +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +.venv +pip-selfcheck.json + +### LibreOffice template +# LibreOffice locks +.~lock.*# + +### Xilinx template +# gitignore template for Xilinx Vivado Design Suite +# website: https://www.xilinx.com/support/download.html + +# [home] +*.jou +*.log +*.debug +*.str +*.zip +*.tmp +*.os +*.js +*.pb +*.dcp +*.hwdef +*.vds +*.veo +*.wdf +*.vdi +*.dmp +*.rpx +*.rpt +*_stub.v +*_stub.vhdl +*_funcsim.v +*_funcsim.vhdl +.project + +# [dir] +*.cache +.metadata +*.data +*.ipdefs +.Xil +*.sdk +*.hw +*.ip_user_files + +### IP synth +*_synth_* + +.jobs + +### project synth +*/*.runs/synth*/*.xml +*/*.runs/synth*/*.txt +*/*.runs/synth*/*.sh +*/*.runs/synth*/*.tcl +*/*.runs/synth*/*.bat +*/*.runs/synth*/*.xdc +!*/*.runs/synth*/*utilization*.rpt + +*.runs/synth*/*.xml +*.runs/synth*/*.txt +*.runs/synth*/*.sh +*.runs/synth*/*.tcl +*.runs/synth*/*.bat +*.runs/synth*/*.xdc +!*.runs/synth*/*utilization*.rpt + +### project impl +*/*.runs/impl*/*.xml +*/*.runs/impl*/*.html +*/*.runs/impl*/*.txt +*/*.runs/impl*/*.sh +*/*.runs/impl*/*.tcl +*/*.runs/impl*/*.bat +!*/*.runs/impl*/*utilization*.rpt + +*.runs/impl*/*.xml +*.runs/impl*/*.html +*.runs/impl*/*.txt +*.runs/impl*/*.sh +*.runs/impl*/*.tcl +*.runs/impl*/*.bat +!*.runs/impl*/*utilization*.rpt + +### block design +*/*/bd/*/hdl +*/*/*/bd/*/hdl + +*/*/bd/*/*.xdc +*/*/*/bd/*/*.xdc + +*/*/bd/*/ip/*/*.xdc +*/*/*/bd/*/ip/*/*.xdc + +*/*/bd/*/ip/*/*/ +*/*/*/bd/*/ip/*/*/ + +*/*/bd/*/ip/*/*.vhd +*/*/*/bd/*/ip/*/*.vhd + +*/*/bd/*/ip/*/*.xml +*/*/*/bd/*/ip/*/*.xml + +*.c +*.h +*.vho +*/*/bd/*/ip/*/*.tcl +*/*/*/bd/*/ip/*/*.tcl +hw_handoff +ipshared + +### Lua template +# Compiled Lua sources +luac.out + +# luarocks build files +*.src.rock +*.zip +*.tar.gz + +# Object files +*.o +*.os +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo +*.def +*.exp + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + + +### Vagrant template +# General +.vagrant/ + +# Log files (if you are creating logs in debug mode, uncomment this) +# *.log + +### PuTTY template +# Private key +*.ppk + +### Patch template +*.orig +*.rej + +### Python template # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -20,7 +948,6 @@ parts/ sdist/ var/ wheels/ -pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg @@ -50,6 +977,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +cover/ # Translations *.mo @@ -72,6 +1000,7 @@ instance/ docs/_build/ # PyBuilder +.pybuilder/ target/ # Jupyter Notebook @@ -82,7 +1011,9 @@ profile_default/ ipython_config.py # pyenv -.python-version +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. @@ -127,3 +1058,153 @@ dmypy.json # Pyre type checker .pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +### Windows template +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Xcode template +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Gcc Patch +/*.gcno + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +/test_* +/*.btv +.python-version +/docs/build +/public +/docs/source/**/*.puml.svg +/docs/source/**/*.puml.png +/docs/source/**/*.gv.svg +/docs/source/**/*.gv.png +/docs/source/**/*.py.txt +/docs/source/**/*.py.err +/docs/source/**/*.py.exitcode +/docs/source/**/*.sh.txt +/docs/source/**/*.sh.err +/docs/source/**/*.sh.exitcode +/docs/source/**/*.dat.* \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..240439b54 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing Guide + +Other guide content is still under development, will be completed soon afterwards. diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..40c4d760f --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +.PHONY: docs test unittest + +DOC_DIR := ./docs +TEST_DIR := ./test +SRC_DIR := ./treetensor + +RANGE_DIR ?= . +RANGE_TEST_DIR := ${TEST_DIR}/${RANGE_DIR} +RANGE_SRC_DIR := ${SRC_DIR}/${RANGE_DIR} + +COV_TYPES ?= xml term-missing + +test: unittest + +unittest: + pytest "${RANGE_TEST_DIR}" \ + -sv -m unittest \ + $(shell for type in ${COV_TYPES}; do echo "--cov-report=$$type"; done) \ + --cov="${RANGE_SRC_DIR}" \ + $(if ${MIN_COVERAGE},--cov-fail-under=${MIN_COVERAGE},) \ + $(if ${WORKERS},-n ${WORKERS},) + +docs: + $(MAKE) -C "${DOC_DIR}" build +pdocs: + $(MAKE) -C "${DOC_DIR}" prod \ No newline at end of file diff --git a/cloc.sh b/cloc.sh new file mode 100755 index 000000000..2dc336fc8 --- /dev/null +++ b/cloc.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# This scripts counts the lines of code and comments in all source files +# and prints the results to the command line. It uses the commandline tool +# "cloc". You can either pass --loc, --comments or --percentage to show the +# respective values only. +# Some parts below need to be adapted to your project! + +# Get the location of this script. +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +# Run cloc - this counts code lines, blank lines and comment lines +# for the specified languages. You will need to change this accordingly. +# For C++, you could use "C++,C/C++ Header" for example. +# We are only interested in the summary, therefore the tail -1 +SUMMARY="$(cloc "${SCRIPT_DIR}" --include-lang="Python" --md | tail -1)" + +# The $SUMMARY is one line of a markdown table and looks like this: +# SUM:|101|3123|2238|10783 +# We use the following command to split it into an array. +IFS='|' read -r -a TOKENS <<<"$SUMMARY" + +# Store the individual tokens for better readability. +NUMBER_OF_FILES=${TOKENS[1]} +COMMENT_LINES=${TOKENS[3]} +LINES_OF_CODE=${TOKENS[4]} + +# To make the estimate of commented lines more accurate, we have to +# subtract any copyright header which is included in each file. +# For Fly-Pie, this header has the length of five lines. +# All dumb comments like those /////////// or those // ------------ +# are also subtracted. As cloc does not count inline comments, +# the overall estimate should be rather conservative. +# Change the lines below according to your project. +# DUMB_COMMENTS="$(grep -r -E '//////|// -----' "${SCRIPT_DIR}" | wc -l)" +# COMMENT_LINES=$(($COMMENT_LINES - 5 * $NUMBER_OF_FILES - $DUMB_COMMENTS)) + +# Print all results if no arguments are given. +if [[ $# -eq 0 ]]; then + awk -v a=$LINES_OF_CODE \ + 'BEGIN {printf "Lines of source code: %6.1fk\n", a/1000}' + awk -v a=$COMMENT_LINES \ + 'BEGIN {printf "Lines of comments: %6.1fk\n", a/1000}' + awk -v a=$COMMENT_LINES -v b=$LINES_OF_CODE \ + 'BEGIN {printf "Comment Percentage: %6.1f%\n", 100*a/b}' + exit 0 +fi + +# Show lines of code if --loc is given. +if [[ $* == *--loc* ]]; then + awk -v a=$LINES_OF_CODE \ + 'BEGIN {printf "%.1fk\n", a/1000}' +fi + +# Show lines of comments if --comments is given. +if [[ $* == *--comments* ]]; then + awk -v a=$COMMENT_LINES \ + 'BEGIN {printf "%.1fk\n", a/1000}' +fi + +# Show precentage of comments if --percentage is given. +if [[ $* == *--percentage* ]]; then + awk -v a=$COMMENT_LINES -v b=$LINES_OF_CODE \ + 'BEGIN {printf "%.1f\n", 100*a/b}' +fi diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..fab1c9718 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +timeout = 20 +markers = + unittest + ignore diff --git a/requirements-doc.txt b/requirements-doc.txt new file mode 100644 index 000000000..b9e7cafe1 --- /dev/null +++ b/requirements-doc.txt @@ -0,0 +1,9 @@ +sphinx~=3.2.0 +sphinx_rtd_theme~=0.4.3 +enum_tools +sphinx-toolbox +plantumlcli>=0.0.2 +packaging +sphinx-multiversion~=0.2.4 +where~=1.0.2 +easydict>=1.7,<2 \ No newline at end of file diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 000000000..e55ccc74d --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,11 @@ +coverage>=4,<5 +mock>=4.0.3 +flake8~=3.5 +pytest~=5.4.3 +pytest-cov~=2.10.1 +pytest-mock~=3.5.1 +pytest-forked~=1.3.0 +pytest-xdist~=1.34.0 +pytest-timeout~=1.4.2 +pytest-rerunfailures~=9.1.1 +easydict>=1.7,<2 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..5e7965988 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +treevalue>=0.1.0 +numpy>=1.10 +torch>=1.3.1,<=1.8.0 diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..2dc332d79 --- /dev/null +++ b/setup.py @@ -0,0 +1,65 @@ +import os +import re +from codecs import open +from distutils.core import setup + +from setuptools import find_packages + +_package_name = "treetensor" + +here = os.path.abspath(os.path.dirname(__file__)) +meta = {} +with open(os.path.join(here, _package_name, 'config', 'meta.py'), 'r', 'utf-8') as f: + exec(f.read(), meta) + + +def _load_req(file: str): + with open(file, 'r', 'utf-8') as f: + return [line.strip() for line in f.readlines() if line.strip()] + + +requirements = _load_req('requirements.txt') + +_REQ_PATTERN = re.compile('^requirements-([a-zA-Z0-9_]+)\\.txt$') +group_requirements = { + item.group(1): _load_req(item.group(0)) + for item in [_REQ_PATTERN.fullmatch(reqpath) for reqpath in os.listdir()] if item +} + +with open('README.md', 'r', 'utf-8') as f: + readme = f.read() + +setup( + # information + name=meta['__TITLE__'], + version=meta['__VERSION__'], + packages=find_packages( + include=(_package_name, "%s.*" % _package_name) + ), + description=meta['__DESCRIPTION__'], + long_description=readme, + long_description_content_type='text/markdown', + author=meta['__AUTHOR__'], + author_email=meta['__AUTHOR_EMAIL__'], + license='Apache License, Version 2.0', + keywords='Tree-structured Value Management', + url='https://github.com/opendilab/DI-treetensor', + + # environment + python_requires=">=3.6", + install_requires=requirements, + tests_require=group_requirements['test'], + extras_require=group_requirements, + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: Implementation :: PyPy' + ], +) diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 000000000..27c9ec622 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1 @@ +from .config import * diff --git a/test/config/__init__.py b/test/config/__init__.py new file mode 100644 index 000000000..1c6ac2fd6 --- /dev/null +++ b/test/config/__init__.py @@ -0,0 +1 @@ +from .test_meta import TestConfigMeta diff --git a/test/config/test_meta.py b/test/config/test_meta.py new file mode 100644 index 000000000..759bbee95 --- /dev/null +++ b/test/config/test_meta.py @@ -0,0 +1,9 @@ +import pytest + +from treetensor.config.meta import __TITLE__ + + +@pytest.mark.unittest +class TestConfigMeta: + def test_title(self): + assert __TITLE__ == 'DI-treetensor' diff --git a/treetensor/__init__.py b/treetensor/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/treetensor/config/__init__.py b/treetensor/config/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/treetensor/config/meta.py b/treetensor/config/meta.py new file mode 100644 index 000000000..11b33965c --- /dev/null +++ b/treetensor/config/meta.py @@ -0,0 +1,19 @@ +""" +Overview: + Meta information for treetensor package. +""" + +#: Title of this project (should be `treetensor`). +__TITLE__ = "DI-treetensor" + +#: Version of this project. +__VERSION__ = "0.0.1" + +#: Short description of the project, will be included in ``setup.py``. +__DESCRIPTION__ = 'A flexible, generalized tree-based tensor structure.' + +#: Author of this project. +__AUTHOR__ = "HansBug, DI-engine's Contributors" + +#: Email of the authors'. +__AUTHOR_EMAIL__ = "hansbug@buaa.edu.cn" -- GitLab