Skip to content
Snippets Groups Projects
Commit 5a5bf77b authored by nugget's avatar nugget
Browse files

First packaging try.

parent 198d707d
Branches
Tags
4 merge requests!12v.0.1 for alpha release,!11Draft: Merge version0.1 changes into dev,!10Version0.1,!9Packaging
[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"
[metadata]
name = example-package-Cory-Doctorov-Dr
version = 0.0.1
author = Example Author
author_email = author@example.com
description = A small example package
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/pypa/sampleproject
project_urls =
Bug Tracker = https://github.com/pypa/sampleproject/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
[options]
package_dir =
= src
packages = find:
python_requires = >=3.10
[options.packages.find]
where = src
"""Handling of hdf5 data files."""
import h5py
# Shows how to create an externalLink (symbolic) to a hdf5 File
# Documentation available at:
# https://docs.h5py.org/en/stable/high/group.html#external-links
myfile = h5py.File('./example.h5', 'w')
myfile['ext link'] = h5py.ExternalLink("testdata_2.h5", "/")
myfile.close()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Tag your plot with an ID.
For publishing the tagged plot along your research data have a look at the
module publish.
Functions:
TagPlot(figure object, string) -> list
"""
import warnings
from plotoptions import PlotOptions
from tagplot_matplotlib import tagplot_matplotlib
def tagplot(figs, engine, prefix='', id_method=1, location='east'):
"""
Tag your figure/plot with an ID.
After determining the plot engine, TagPlot calls the corresponding
function which tags the plot.
Parameters
----------
figs : list
Figures that should be tagged.
engine : string
Plot engine which should be used to tag the plot.
prefix : string
Will be added as prefix to the ID.
id_method : int, optional
id_method for creating the ID. Create an ID by Unix time is referenced
as 1, create a random ID with id_method=2. The default is 1.
location : string, optional
Location for ID to be displayed on the plot. Default is 'east'.
Raises
------
RuntimeWarning
DESCRIPTION.
Returns
-------
list
The resulting list contains two lists each with as many entries as
figures were given. The first list contains the tagged figures.
The second list contains the corresponding IDs as strings.
"""
if isinstance(location, str):
pass
else:
raise TypeError("Location is not a string.")
match location:
case 'north':
rotation = 0
position = (0.35, 0.975)
case 'east':
rotation = 90
position = (0.975, 0.35)
case 'south':
rotation = 0
position = (0.35, 0.015)
case 'west':
rotation = 90
position = (0.025, 0.35)
case 'southeast':
rotation = 0
position = (0.75, 0.015)
case 'custom':
# TODO: Get rotation and position from user input & check if valid
rotation = 0
position = (0.5, 0.5)
case _:
warnings.warn(f'Location "{location}" is not a defined '
'location, TagPlot uses location "east" '
'instead.')
rotation = 90
position = (0.975, 0.35)
option_container = PlotOptions(figs, prefix, id_method,
rotation, position)
option_container.validate_input()
match engine:
case 'matplotlib' | 'pyplot':
return tagplot_matplotlib(option_container)
case _:
raise ValueError(
f'The plot engine "{engine}" is not supported.')
# -*- coding: utf-8 -*-
# from fcn_help.FST_colors import Colors
import matplotlib
import matplotlib.pyplot as plt
import create_id
# plt.style.use('./fcn_help/FST.mplstyle')
def TagPlot_matplotlib(figs, prefix, method, rotation, position):
"""
Add IDs to figures with matplotlib.
The ID is placed visual on the figure window and
as Tag (Property of figure).
TagPlot can tag multiple figures at once
"""
# Check if figs is a valid figure or a list of valid figures
if isinstance(figs, matplotlib.figure.Figure):
pass
elif isinstance(figs, list):
for figure in figs:
if isinstance(figure, matplotlib.figure.Figure):
pass
else:
raise TypeError('Figure is not a valid matplotlib-figure.')
fontsize = 'small'
color = 'grey'
IDs = []
# Loop to create and position the IDs
for fig in figs:
ID = create_id.create_id(method)
ID = prefix + str(ID)
IDs.append(ID)
plt.figure(fig.number)
plt.figtext(x=position[0], y=position[1], s=ID, ha='left', wrap=True,
rotation=rotation, fontsize=fontsize, color=color)
fig.tight_layout()
return [figs, IDs]
File moved
File moved
File moved
File moved
File moved
......@@ -8,6 +8,7 @@ Includes starting all tests and measuring the code coverage.
import sys
import unittest
import coverage
from sys import exit
cov = coverage.Coverage()
cov.start()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment