Skip to content
Snippets Groups Projects
Commit 85575d33 authored by Hock, Martin's avatar Hock, Martin
Browse files

Merge branch 'dev' into 'main'

Include architecture diagram in docs

Closes #75

See merge request !34
parents 05e761b5 306f996b
No related branches found
No related tags found
3 merge requests!53Resolve "Unit tests fail if called from command line",!36Change author entry. Add Documentation and Source URLs. Raise Dev Status to Alpha (3).,!34Include architecture diagram in docs
Pipeline #824570 passed with warnings
......@@ -8,7 +8,8 @@ plotID is a program connected to Research Data Management (RDM). It has two main
**Note:** To run plotID python version ≥ 3.10 is required.
## Installation
Currently there are two options to run plotID. Either install it via pip from the Python Package Index (PyPi) or install plotID from the source code. Apart from setting up an optional virtual environment, installation is the same for Windows and Unix systems.
Currently there are two options to run plotID. Either install it via pip from the Python Package Index (PyPi) or install plotID from the source code.
**Installation is the same for Windows and Unix systems, except** for the **optional** first set of setting up a virtual environment.
1. [Optional] Create a virtual environment and activate it:
```bash
......@@ -47,19 +48,19 @@ Tag your figure/plot with an ID. It is possible to tag multiple figures at once.
`tagplot(figures, plot_engine)`
The variable "figures" can be a single figure or a list of multiple figures.
The argument "plot_engine" defines which plot engine was used to create the figures. It also determines which plot engine plotID uses to place the ID on the plot. Currently supported plot engines are:
- 'matplotlib', which processes figures created by matplotlib.
- 'image', which processes pictures with common extensions (jpg, png, etc.).
- *matplotlib*, which processes figures created by matplotlib.
- *image*, which processes pictures files with common extensions (jpg, png, etc.).
tagplot returns a PlotIDTransfer object that contains the tagged figures and the corresponding IDs as strings.
Optional parameters can be used to customize the tag process.
- prefix : str, optional
- *prefix* : str, optional
Will be added as prefix to the ID.
- id_method : str, optional
- *id_method* : str, optional
id_method for creating the ID. Create an ID by Unix time is referenced as 'time', create a random ID with id_method='random'. The default is 'time'.
- location : string, optional
- *location* : string, optional
Location for ID to be displayed on the plot. Default is 'east'.
- qrcode : boolean, optional
- *qrcode* : boolean, optional
Experimental support for encoding the ID in a QR Code.
Example:
......@@ -75,16 +76,16 @@ FIGS_AND_IDS = tagplot(FIGS_AS_LIST, 'matplotlib', prefix='XY23_', id_method='ra
Save plot, data and measuring script. It is possible to export multiple figures at once.
`publish(figs_and_ids, src_datapath, dst_path, plot_name)`
- "figs_and_ids" must be a PlotIDTransfer object. Therefore, it can be directly passed from tagplot() to publish().
- "src_datapath" specifies the path to (raw) data that should be published. It can be a string or a list of strings that specifies all files and directories which will be published.
- "dst_path" is the path to the destination directory, where all the data should be copied/exported to.
- "plot_names" will be the file names for the exported plots. If you give only one plot name but several figures, plotID will name the exported plots with an appended number, e.g. example_fig1.png, example_fig2.png, ...
- *figs_and_ids* must be a PlotIDTransfer object. Therefore, it can be directly passed from tagplot() to publish().
- *src_datapath* specifies the path to (raw) data that should be published. It can be a string or a list of strings that specifies all files and directories which will be published.
- *dst_path* is the path to the destination directory, where all the data should be copied/exported to.
- *plot_names* will be the file names for the exported plots. If you give only one plot name but several figures, plotID will name the exported plots with an appended number, e.g. example_fig1.png, example_fig2.png, ...
Optional parameters can be used to customize the publish process.
- data_storage: str, optional
- *data_storage*: str, optional
Method how the data should be stored. Available options:
- centralized: The raw data will copied only once. All other plots will reference this data via sym link.
- individual: The complete raw data will be copied to a folder for every plot, respectively.
- *centralized*: The raw data will copied only once. All other plots will reference this data via sym link.
- *individual*: The complete raw data will be copied to a folder for every plot, respectively.
Example:
`publish(figs_and_ids, '/home/user/Documents/research_data', '/home/user/Documents/exported_data', 'EnergyOverTime-Plot')`
......@@ -93,8 +94,8 @@ If you want to build plotID yourself, follow these steps:
1. Download the source code from [Gitlab](https://git.rwth-aachen.de/plotid/plotid_python):
`git clone https://git.rwth-aachen.de/plotid/plotid_python.git`
`cd plotid_python`
2. [Optional] Create a virtual environment (see Installation).
3. [Optional] Run unittests and coverage:
2. *[Optional]* Create a virtual environment (see [Installation](#Installation)).
3. *[Optional]* Run unittests and coverage:
`python3 tests/runner_tests.py`
4. Build the package
`python3 -m build`
......@@ -102,6 +103,8 @@ If you want to build plotID yourself, follow these steps:
## Contributing
Contributions to plotID are very welcome. If you encounter any issues with plotID please report them in our [issue tracker](https://git.rwth-aachen.de/plotid/plotid_python/-/issues). Code contributions via merge request are also highly appreciated. Please have a look at [CONTRIBUTING](https://git.rwth-aachen.de/plotid/plotid_python/-/blob/main/CONTRIBUTING.md) first.
To install all optional dependencies use `pip install .[test,docs]` or `pip install plotid[test,docs]` respectively.
## Documentation
If you have more questions about plotID, please have a look at the [documentation](https://plotid.pages.rwth-aachen.de/plotid_python).
......
......
docs/source/_static/plotID.jpg

152 KiB

docs/source/_static/plotID.png

28.5 KiB

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 26.5.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 438 378" enable-background="new 0 0 438 378" xml:space="preserve">
<filter filterUnits="userSpaceOnUse" height="120%" id="fx0" primitiveUnits="userSpaceOnUse" width="120%" x="-10%" y="-10%">
<feComponentTransfer color-interpolation-filters="sRGB">
<feFuncR tableValues="0 0" type="discrete"></feFuncR>
<feFuncG tableValues="0 0" type="discrete"></feFuncG>
<feFuncB tableValues="0 0" type="discrete"></feFuncB>
<feFuncA intercept="0" slope="0.4" type="linear"></feFuncA>
</feComponentTransfer>
<feGaussianBlur stdDeviation="6.11111 6.11111"></feGaussianBlur>
</filter>
<g display="none">
<defs>
<rect id="SVGID_1_" x="-816.4" y="-63" width="365" height="72"/>
</defs>
<clipPath id="SVGID_00000021840905257671126840000014227800589511661480_" display="inline">
<use xlink:href="#SVGID_1_" overflow="visible"/>
</clipPath>
<g transform="translate(2136 1752)" display="inline" clip-path="url(#SVGID_00000021840905257671126840000014227800589511661480_)" filter="url(#fx0)">
<g>
<g>
<defs>
<rect id="SVGID_00000088816509798223945890000000235914026726048956_" x="-2949.4" y="-1857" width="416" height="156"/>
</defs>
<clipPath id="SVGID_00000029735425270779549330000014779046801403664559_">
<use xlink:href="#SVGID_00000088816509798223945890000000235914026726048956_" overflow="visible"/>
</clipPath>
</g>
</g>
<g>
<g>
<defs>
<rect id="SVGID_00000098921936600849189490000010012037358900037053_" x="-2949.4" y="-1857" width="416" height="156"/>
</defs>
<clipPath id="SVGID_00000136400049304070468900000004534601106772835235_">
<use xlink:href="#SVGID_00000098921936600849189490000010012037358900037053_" overflow="visible"/>
</clipPath>
<g clip-path="url(#SVGID_00000136400049304070468900000004534601106772835235_)">
<path d="M-2929.2-1785.2l259.3,0v13l-259.3,0V-1785.2z M-2676.3-1791.7l65,13l-65,13V-1791.7z"/>
</g>
</g>
</g>
<g>
<g>
<defs>
<rect id="SVGID_00000091014671130186324570000011522761433027551645_" x="-2949.4" y="-1857" width="416" height="156"/>
</defs>
<clipPath id="SVGID_00000141421524398337821070000015048522232261394608_">
<use xlink:href="#SVGID_00000091014671130186324570000011522761433027551645_" overflow="visible"/>
</clipPath>
</g>
</g>
</g>
</g>
<path d="M377.9,297.2l-63-12.6v6.3h-36c4.7-3.5,9-7.5,12.8-11.9c4.8-5.6,8.8-11.9,11.9-18.7c2.1-4.1,4.4-8,6.8-11.6
c0.3,0.8,0.7,1.7,1,2.5c1.3,3.2,2.2,5.5,3,7.9c0.9,2.3,1.7,4.7,3.1,8.2c2.2,5.5,3.3,8.3,4.7,10.1c4.7,6.2,10.2,8.5,14.1,9.3
c1.5,0.3,3.1,0.5,4.6,0.5c0.9,0,1.7,0,2.6-0.1c2.2-0.2,3.8-2.2,3.5-4.4c-0.2-2.2-2.2-3.8-4.4-3.5c-1.6,0.2-3.1,0.1-4.6-0.2
c-2.5-0.5-6.1-2.1-9.4-6.3c-0.7-1-2-4-3.6-8.2c-1.4-3.4-2.2-5.8-3-8c-0.9-2.5-1.8-4.8-3.2-8.2c-0.8-1.9-1.5-3.8-2.5-5.9
c0.2-0.1,0.4-0.2,0.6-0.2c0.6-0.2,1.9-0.5,3.4-0.2c0.9,0.2,2.2,0.6,4.3,2.6c1.6,1.5,2.1,2.4,3.2,4.2c1,1.6,2.3,3.8,4.7,7.1
c2.5,3.3,4.8,5.2,6.8,6.7c1.6,1.2,3.2,2.2,5,3.1c2,1,4.4,0.2,5.4-1.7c1-2,0.2-4.4-1.7-5.4c-1.3-0.7-2.7-1.5-3.8-2.4
c-1.3-1-3.2-2.4-5.2-5.1c-2.2-3-3.4-4.9-4.3-6.4c-1.2-2.1-2.2-3.7-4.6-5.9c-2.8-2.6-5.4-4-8.2-4.6c-3.1-0.6-5.8-0.1-7.4,0.5
c-0.5,0.2-1.1,0.4-1.6,0.6c-3.6-6.8-7.3-12.4-11-16.1c-3.7-3.8-6.7-5.8-10.4-6.7c-1.2-0.3-4.7-1.2-8.9-0.2c-2.1,0.5-5,1.7-9.2,6
c-2.9,3-5.1,6.1-8.1,11.7c-1.8,3.2-2.6,5-3.5,7c-0.4,0.9-0.8,1.7-1.3,2.8l0,0.1c-0.2,0.4-1,1.9-1.8,3.6c-2.1,3.9-3.8,7.3-6.1,9.6
c-2,2.1-4.7,3.6-8.1,4.5v-45.6h-12.6v79.2H60.1v12.6h254.8v6.3L377.9,297.2z M244.4,290.9v-25.5c0.2,0,0.5,0,0.7-0.1
c5.3-1.2,9.8-3.6,13.1-7c3-3.1,5.2-7.1,7.4-11.4c1.1-2.1,1.7-3.3,2-4c0.5-1.1,0.9-2,1.3-2.8c0.9-1.9,1.7-3.5,3.3-6.5
c2.7-4.9,4.4-7.5,6.8-10c3.1-3.2,4.7-3.6,5.4-3.8c2.2-0.5,4.1,0,4.9,0.2c1.8,0.5,3.7,1.5,6.7,4.6c3.4,3.5,7,9,10.4,15.8
c-0.4,0.5-0.7,0.9-1,1.4c-3.4,4.6-6.5,9.6-9.2,15.1l-0.1,0.1c-2.8,6.1-6.4,11.8-10.7,16.8c-6.1,7.1-13.4,12.8-21.8,17.1H244.4z"/>
<polygon points="250.7,131.2 244.4,131.2 244.4,139.7 231.8,139.7 231.8,131.2 225.5,131.2 238.1,68.2 "/>
<g enable-background="new ">
<path fill="#007D59" d="M71.8,191.7v-45.8h14.8c5.6,0,9.3,0.2,11,0.7c2.6,0.7,4.8,2.2,6.6,4.5c1.8,2.3,2.7,5.3,2.7,8.9
c0,2.8-0.5,5.2-1.5,7.1c-1,1.9-2.3,3.4-3.9,4.5s-3.2,1.8-4.8,2.2c-2.2,0.4-5.4,0.7-9.6,0.7h-6v17.3H71.8z M81.1,153.6v13h5.1
c3.6,0,6.1-0.2,7.3-0.7c1.2-0.5,2.2-1.2,2.9-2.2c0.7-1,1-2.2,1-3.6c0-1.7-0.5-3-1.5-4.1c-1-1.1-2.2-1.8-3.7-2
c-1.1-0.2-3.3-0.3-6.7-0.3H81.1z"/>
<path fill="#007D59" d="M114.5,191.7v-45.8h8.8v45.8H114.5z"/>
<path fill="#007D59" d="M130.2,174.6c0-2.9,0.7-5.7,2.2-8.5c1.4-2.7,3.5-4.8,6.1-6.2s5.6-2.2,8.8-2.2c5,0,9.1,1.6,12.3,4.9
c3.2,3.3,4.8,7.4,4.8,12.4c0,5-1.6,9.2-4.9,12.5c-3.2,3.3-7.3,5-12.2,5c-3,0-5.9-0.7-8.7-2.1s-4.9-3.4-6.3-6
S130.2,178.5,130.2,174.6z M139.2,175.1c0,3.3,0.8,5.8,2.3,7.6s3.5,2.6,5.8,2.6s4.2-0.9,5.8-2.6s2.3-4.3,2.3-7.6
c0-3.2-0.8-5.8-2.3-7.5s-3.5-2.6-5.8-2.6s-4.2,0.9-5.8,2.6S139.2,171.8,139.2,175.1z"/>
<path fill="#007D59" d="M186.6,158.5v7h-6v13.4c0,2.7,0.1,4.3,0.2,4.7c0.1,0.4,0.4,0.8,0.8,1.1c0.4,0.3,0.9,0.4,1.5,0.4
c0.8,0,2-0.3,3.5-0.8l0.8,6.8c-2,0.9-4.4,1.3-6.9,1.3c-1.6,0-3-0.3-4.3-0.8s-2.2-1.2-2.8-2.1s-1-2-1.2-3.4c-0.2-1-0.3-3.1-0.3-6.2
v-14.5h-4v-7h4v-6.6l8.8-5.1v11.7H186.6z"/>
<path fill="#007D59" d="M192.4,191.7v-45.8h9.2v45.8H192.4z"/>
<path fill="#007D59" d="M210.5,145.9h16.9c3.8,0,6.7,0.3,8.7,0.9c2.7,0.8,5,2.2,6.9,4.2c1.9,2,3.4,4.5,4.4,7.4
c1,2.9,1.5,6.5,1.5,10.8c0,3.8-0.5,7-1.4,9.8c-1.1,3.3-2.8,6-4.9,8.1c-1.6,1.6-3.8,2.8-6.5,3.7c-2,0.6-4.8,1-8.2,1h-17.4V145.9z
M219.7,153.6V184h6.9c2.6,0,4.4-0.1,5.6-0.4c1.5-0.4,2.7-1,3.7-1.9c1-0.9,1.8-2.4,2.4-4.4c0.6-2.1,0.9-4.8,0.9-8.4
c0-3.5-0.3-6.3-0.9-8.2c-0.6-1.9-1.5-3.4-2.6-4.4s-2.6-1.8-4.3-2.2c-1.3-0.3-3.8-0.4-7.6-0.4H219.7z"/>
</g>
<g>
<g>
<g>
<polygon points="159.7,235.3 159.7,238.2 156.8,238.2 156.8,244.1 153.8,244.1 153.8,235.3 "/>
</g>
<g>
<rect id="p_00000123439268576486602700000009581921259755516571_" x="153.8" y="255.9" width="2.9" height="2.9"/>
</g>
<g>
<path d="M153.8,264.7v20.6h20.6v-20.6H153.8z M171.5,282.4h-14.7v-14.7h14.7V282.4z"/>
</g>
<g>
<polygon points="165.6,244.1 165.6,252.9 159.7,252.9 159.7,255.9 156.8,255.9 156.8,252.9 153.8,252.9 153.8,250 156.8,250
156.8,247 159.7,247 159.7,250 162.7,250 162.7,244.1 "/>
</g>
<g>
<rect id="p_00000062910596667749145500000008503473972037311923_" x="159.7" y="241.2" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000079472029943003826610000002686399014724613763_" x="159.7" y="258.8" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000039100928243485769180000002698231460425568143_" x="162.7" y="235.3" width="2.9" height="2.9"/>
</g>
<g>
<rect x="162.7" y="255.9" width="5.9" height="3"/>
</g>
<g>
<rect x="159.7" y="217.6" width="8.8" height="8.8"/>
</g>
<g>
<rect x="165.6" y="238.2" width="2.9" height="5.9"/>
</g>
<g>
<rect x="159.7" y="270.6" width="8.8" height="8.8"/>
</g>
<g>
<rect x="168.5" y="258.8" width="8.8" height="2.9"/>
</g>
<g>
<path d="M153.8,211.7v20.6h20.6v-20.6H153.8z M171.5,229.4h-14.7v-14.7h14.7V229.4z"/>
</g>
<g>
<rect x="171.5" y="235.3" width="5.9" height="2.9"/>
</g>
<g>
<rect x="171.5" y="241.2" width="5.9" height="2.9"/>
</g>
<g>
<rect x="171.5" y="247" width="5.9" height="2.9"/>
</g>
<g>
<rect id="p_00000102522578266725741870000009140281055097981867_" x="171.5" y="252.9" width="2.9" height="2.9"/>
</g>
<g>
<polygon points="203.9,214.6 203.9,217.6 198,217.6 198,223.5 195.1,223.5 195.1,217.6 192.1,217.6 192.1,220.5 189.2,220.5
189.2,223.5 180.3,223.5 180.3,220.5 177.4,220.5 177.4,214.6 180.3,214.6 180.3,217.6 186.2,217.6 186.2,214.6 189.2,214.6
189.2,211.7 201,211.7 201,214.6 "/>
</g>
<g>
<rect id="p_00000080169463583866062290000006112526568943095466_" x="177.4" y="244.1" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000127007561909585438130000005244577349216328848_" x="177.4" y="250" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000147900594363510815760000015849234016418706821_" x="177.4" y="255.9" width="2.9" height="2.9"/>
</g>
<g>
<rect x="177.4" y="261.8" width="8.8" height="5.9"/>
</g>
<g>
<rect id="p_00000148655426614715283010000010052377602611170975_" x="177.4" y="273.6" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000068655992362606148590000011805057053439098018_" x="180.3" y="211.7" width="2.9" height="2.9"/>
</g>
<g>
<polygon points="180.3,229.4 180.3,232.3 183.3,232.3 183.3,235.3 177.4,235.3 177.4,223.5 180.3,223.5 180.3,226.4 183.3,226.4
183.3,229.4 "/>
</g>
<g>
<polygon points="189.2,238.2 189.2,241.2 186.2,241.2 186.2,244.1 180.3,244.1 180.3,241.2 183.3,241.2 183.3,235.3 186.2,235.3
186.2,238.2 "/>
</g>
<g>
<polygon points="183.3,282.4 183.3,285.3 177.4,285.3 177.4,279.4 180.3,279.4 180.3,282.4 "/>
</g>
<g>
<rect id="p_00000145058424659420032130000010813169514718006158_" x="183.3" y="229.4" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000156566739914724274580000016386483015821754752_" x="183.3" y="255.9" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000115502680583802610680000004228673697401314951_" x="186.2" y="226.4" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000143603680981358306700000014498812955667069097_" x="186.2" y="258.8" width="2.9" height="2.9"/>
</g>
<g>
<rect x="189.2" y="229.4" width="2.9" height="5.9"/>
</g>
<g>
<rect x="192.1" y="223.5" width="3" height="5.9"/>
</g>
<g>
<polygon points="198,241.2 198,244.1 195.1,244.1 195.1,247 192.1,247 192.1,241.2 "/>
</g>
<g>
<path d="M221.6,261.8v-2.9h-5.9v-5.9h-2.9V247h-5.9v-2.9h-3v-5.9H201v8.8h-3v2.9h3v3h2.9v-3h3v3h-3v2.9H198v3h3v2.9h-3v-2.9h-2.9
v-3h-3V247h-2.9v2.9h-5.9v3h5.9v5.9h2.9v2.9h3v3h2.9v2.9h3v5.9h2.9v3h3v-3h2.9v5.9h5.9v-2.9h3v2.9h2.9v-5.9h-2.9v-2.9h2.9v-2.9
h-2.9v-5.9H221.6z M212.7,270.6h-8.8v-8.8h8.8V270.6z M212.7,258.8h-5.9v-3h5.9V258.8z"/>
</g>
<g>
<rect x="192.1" y="264.7" width="3" height="5.9"/>
</g>
<g>
<rect id="p_00000011743187155963921610000015565184821725408394_" x="195.1" y="229.4" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000131337903659184509130000007441309213132709293_" x="195.1" y="235.3" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000061469145507360837600000003008555269875269276_" x="195.1" y="252.9" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000049938519811567965420000010936659741735962514_" x="195.1" y="270.6" width="2.9" height="2.9"/>
</g>
<g>
<polygon points="203.9,223.5 203.9,226.4 201,226.4 201,229.4 198,229.4 198,223.5 "/>
</g>
<g>
<polygon points="203.9,229.4 203.9,235.3 198,235.3 198,232.3 201,232.3 201,229.4 "/>
</g>
<g>
<path d="M206.8,211.7v20.6h20.6v-20.6H206.8z M224.5,229.4h-14.7v-14.7h14.7V229.4z"/>
</g>
<g>
<rect id="p_00000176018499386432170070000014406927632004287368_" x="206.8" y="264.7" width="2.9" height="2.9"/>
</g>
<g>
<polygon points="209.8,279.4 209.8,282.4 203.9,282.4 203.9,285.3 195.1,285.3 195.1,282.4 198,282.4 198,279.4 195.1,279.4
195.1,282.4 189.2,282.4 189.2,285.3 186.2,285.3 186.2,282.4 183.3,282.4 183.3,279.4 180.3,279.4 180.3,276.5 186.2,276.5
186.2,273.5 183.3,273.5 183.3,270.6 186.2,270.6 186.2,267.7 189.2,267.7 189.2,270.6 192.1,270.6 192.1,273.5 195.1,273.5
195.1,276.5 198,276.5 198,273.5 201,273.5 201,279.4 "/>
</g>
<g>
<rect id="p_00000116199787016984342990000013494253759607291042_" x="209.8" y="282.4" width="2.9" height="2.9"/>
</g>
<g>
<rect x="212.7" y="217.6" width="8.8" height="8.8"/>
</g>
<g>
<polygon points="212.7,238.2 212.7,241.2 215.7,241.2 215.7,247 212.7,247 212.7,244.1 206.8,244.1 206.8,235.3 215.7,235.3
215.7,238.2 "/>
</g>
<g>
<rect id="p_00000023280724969844711130000012494899777513900161_" x="215.7" y="279.4" width="2.9" height="2.9"/>
</g>
<g>
<rect x="218.6" y="235.3" width="5.9" height="2.9"/>
</g>
<g>
<polygon points="221.6,250 221.6,255.9 218.6,255.9 218.6,252.9 215.7,252.9 215.7,247 218.6,247 218.6,250 "/>
</g>
<g>
<polygon points="227.5,238.2 227.5,244.1 221.6,244.1 221.6,241.2 224.5,241.2 224.5,238.2 "/>
</g>
<g>
<polygon points="227.5,247 227.5,255.9 224.5,255.9 224.5,250 221.6,250 221.6,247 "/>
</g>
<g>
<rect id="p_00000101097631975350201870000015164566306823593893_" x="221.6" y="255.9" width="2.9" height="2.9"/>
</g>
<g>
<polygon points="227.5,261.8 227.5,267.7 221.6,267.7 221.6,264.7 224.5,264.7 224.5,261.8 "/>
</g>
<g>
<rect x="221.6" y="282.4" width="5.9" height="2.9"/>
</g>
<g>
<rect id="p_00000084519256098015027220000015830736021620261807_" x="224.5" y="270.6" width="2.9" height="2.9"/>
</g>
<g>
<rect id="p_00000029010096945984569650000000432214522222326954_" x="224.5" y="276.5" width="2.9" height="2.9"/>
</g>
</g>
</g>
<path d="M74.6,211.7v73.6h73.6v-73.6H74.6z M137.7,274.8H85.1v-52.6h52.6V274.8z"/>
<rect x="94.4" y="231.5" width="34" height="34"/>
</svg>
This diff is collapsed.
docs/source/_static/publish.png

98.3 KiB

This diff is collapsed.
docs/source/_static/tagplot.png

79.5 KiB

.. PlotID documentation master file, created by
.. plotID documentation master file, created by
sphinx-quickstart on Tue Jun 21 14:09:27 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to PlotID's documentation!
Welcome to plotID's documentation!
==================================
.. toctree::
......@@ -11,6 +11,7 @@ Welcome to PlotID's documentation!
:caption: Contents:
README <readme_link.rst>
Structure and architecture <structure.rst>
Indices and tables
......
......
Structure and architecture of plotID
==================================
A visualization of the internal structure of plotID is provided here. The structure tries to follow Object Oriented Programming (OOP) principles. First tagplot() is depicted with matplotlib as example plot engine:
|structure tagplot|
In the following is shown how a call to publish is processed by plotID:
|structure publish|
.. |structure tagplot| image:: _static/tagplot.png
:width: 700
:alt: Graph to show the architecture of the function tagplot().
.. |structure publish| image:: _static/publish.png
:width: 700
:alt: Graph to show the architecture of the function publish().
......@@ -2,6 +2,8 @@
# -*- coding: utf-8 -*-
"""Contains the PlotOptions and PlotIDTransfer classes."""
import os
class PlotOptions:
"""
......@@ -10,7 +12,10 @@ class PlotOptions:
Methods
-------
__init__
validate_input : Check if input is correct type.
validate_input
Check if input is correct type.
validate_list
Check if all elements of a given list are of certain type.
Attributes
----------
......@@ -87,7 +92,6 @@ class PlotIDTransfer:
Methods
-------
__init__
validate_input : Check if input is correct type.
Attributes
----------
......@@ -100,7 +104,55 @@ class PlotIDTransfer:
def __init__(self, figs, figure_ids):
self.figs = figs
self.figure_ids = figure_ids
self.figure_ids = validate_list(self.figure_ids)
def __str__(self):
"""Representation if an object of this class is printed."""
return str(self.__class__) + ": " + str(self.__dict__)
def validate_list(list_var, elt_type=str, is_file=False):
"""
Validate if contents of a list are of specific type.
Parameters
----------
list_var : list or str
List or single string which contents will be validated.
elt_type : datatype, optional
Datatype of which the list elements must be type of. Otherwise
an Error will be raised. The default is str.
is_file : boolean, optional
Flag to indicate if the list contains paths to files. If True the
strings will be checked if they correspond to an existing file.
The default is False.
Raises
------
TypeError
If one of the list elements is not of type elt_type.
FileNotFoundError
If strings are also checked for existing files and one of the files
does not exist.
Returns
-------
list_var as list
"""
if isinstance(list_var, elt_type):
list_var = [list_var]
if isinstance(list_var, list):
for elt in list_var:
if not isinstance(elt, elt_type):
raise TypeError(f'The list of {list_var} contains an '
f'object which is not of type {elt_type}.')
if is_file:
# Check if directory and files exist
if not os.path.exists(elt):
raise FileNotFoundError('The specified directory'
f'/file {elt} does not exist.')
else:
raise TypeError(f'The specified {list_var} are neither a '
f'{elt_type} nor a list of {elt_type}.')
return list_var
......@@ -17,7 +17,7 @@ import shutil
import sys
import warnings
from plotid.save_plot import save_plot
from plotid.plotoptions import PlotIDTransfer
from plotid.plotoptions import PlotIDTransfer, validate_list
class PublishOptions:
......@@ -69,53 +69,25 @@ class PublishOptions:
"""
# Check if IDs are str
if isinstance(self.figure_ids, str):
self.figure_ids = [self.figure_ids]
if isinstance(self.figure_ids, list):
for identifier in self.figure_ids:
if not isinstance(identifier, str):
raise TypeError('The list of figure_ids contains an object'
' which is not a string.')
else:
raise TypeError('The specified figure_ids are neither a string nor'
' a list of strings.')
self.figure_ids = validate_list(self.figure_ids)
# Check if plot_name is a string or a list of strings
self.plot_names = validate_list(self.plot_names)
if not os.path.isfile(sys.argv[0]):
raise FileNotFoundError('Cannot copy original python script. '
'Running publish from a shell is not '
'possible.')
if isinstance(self.src_datapaths, str):
self.src_datapaths = [self.src_datapaths]
if isinstance(self.src_datapaths, list):
for path in self.src_datapaths:
if not isinstance(path, str):
raise TypeError(f'{path} is not a string.')
# Check if source directory and files exist
if not os.path.exists(path):
raise FileNotFoundError('The specified source directory'
f'/file {path} does not exist.')
else:
raise TypeError('The source directory/files are neither '
'a string nor a list.')
# Check if self.src_datapaths are strings and existing files.
self.src_datapaths = validate_list(self.src_datapaths,
is_file=True)
# Check if destination directory is allowed path
if not os.path.exists(self.dst_path_head):
raise FileNotFoundError('The specified destination directory '
f'{self.dst_path_head} does not exist.')
# Check if plot_name is a string or a list of strings
if isinstance(self.plot_names, str):
self.plot_names = [self.plot_names]
if isinstance(self.plot_names, list):
for name in self.plot_names:
if not isinstance(name, str):
raise TypeError('The list of plot_names contains an object'
' which is not a string.')
else:
raise TypeError('The specified plot_names is neither a string nor'
' a list of strings.')
# Check if data_storage is a string
if not isinstance(self.data_storage, str):
raise TypeError('The specified data_storage method is not a '
......@@ -139,7 +111,6 @@ class PublishOptions:
"""
# Export plot figure to picture.
plot_paths = save_plot(self.figure, self.plot_names)
print(plot_paths)
match self.data_storage:
case 'centralized':
self.centralized_data_storage()
......
......
......@@ -27,7 +27,7 @@ def save_plot(figures, plot_names, extension='png'):
Returns
-------
plot_path : str or list of str
plot_path : list of str
Names of the created pictures.
"""
# Check if figs is a valid figure or a list of valid figures
......
......
......@@ -47,7 +47,10 @@ class TestPublish(unittest.TestCase):
'from a Python script. Therefore, the script cannot be '
'copied.')
def test_publish(self):
""" Test publish and check if an exported picture file exists. """
"""
Test publish and check if an exported picture file exists.
The destination path is given with trailing slash.
"""
publish(PlotIDTransfer(FIG, 'testID'), SRC_DIR, DST_PATH + '/',
PIC_NAME, data_storage='individual')
assert os.path.isfile(os.path.join(DST_PATH, 'testID',
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment