master > master: src - für notebook wk10
This commit is contained in:
parent
0384334ce0
commit
847e7744ff
@ -6,6 +6,7 @@
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
from src.maths.diagrams.sets import *;
|
from src.maths.diagrams.sets import *;
|
||||||
|
from src.maths.diagrams.signal import *;
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# EXPORTS
|
# EXPORTS
|
||||||
@ -14,4 +15,5 @@ from src.maths.diagrams.sets import *;
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
'Function',
|
'Function',
|
||||||
'Functions',
|
'Functions',
|
||||||
|
'display_signal',
|
||||||
];
|
];
|
||||||
|
48
src/maths/diagrams/signal.py
Normal file
48
src/maths/diagrams/signal.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# IMPORTS
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
from __future__ import annotations;
|
||||||
|
|
||||||
|
from src.thirdparty.code import *;
|
||||||
|
from src.thirdparty.types import *;
|
||||||
|
from src.thirdparty.maths import *;
|
||||||
|
from src.thirdparty.plots import *;
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# EXPORTS
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'display_signal',
|
||||||
|
];
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
# CONSTANTS / VARIABLES
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
def display_signal(
|
||||||
|
u: np.ndarray,
|
||||||
|
title: str,
|
||||||
|
max_labels = 10,
|
||||||
|
):
|
||||||
|
n = len(u);
|
||||||
|
if n <= max_labels:
|
||||||
|
x_axis = list(range(n));
|
||||||
|
else:
|
||||||
|
skip = int(n/max_labels);
|
||||||
|
x_axis = [ k*skip for k in range(max_labels) ];
|
||||||
|
|
||||||
|
fig, axs = mplot.subplots(1, 1, constrained_layout=True);
|
||||||
|
mplot.title(title);
|
||||||
|
mplot.xlabel('»Zeit« [=Indizes]');
|
||||||
|
mplot.ylabel('Werte [=Einträge]');
|
||||||
|
axs.stem(linspace(0,n-1,n), np.real(u), label='reeller Teil', linefmt='red');
|
||||||
|
axs.stem(linspace(0,n-1,n) + 0.05, np.imag(u), label='imaginärer Teil', linefmt='lime');
|
||||||
|
mplot.legend();
|
||||||
|
axs.set_xticks(x_axis, labels=[ str(index) for index in x_axis]);
|
||||||
|
mplot.show();
|
||||||
|
return;
|
16
src/thirdparty/maths.py
vendored
16
src/thirdparty/maths.py
vendored
@ -6,10 +6,17 @@
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
from fractions import Fraction;
|
from fractions import Fraction;
|
||||||
|
from numpy import cos;
|
||||||
|
from numpy import exp;
|
||||||
|
from numpy import linalg;
|
||||||
|
from numpy import linspace;
|
||||||
|
from numpy import pi;
|
||||||
|
from numpy import sin;
|
||||||
|
from numpy import sqrt;
|
||||||
|
from typing import TypeVar;
|
||||||
import math;
|
import math;
|
||||||
import numpy as np;
|
import numpy as np;
|
||||||
import random;
|
import random;
|
||||||
from typing import TypeVar;
|
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# MODIFICATIONS
|
# MODIFICATIONS
|
||||||
@ -39,8 +46,15 @@ def sample(
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'Fraction',
|
'Fraction',
|
||||||
|
'cos',
|
||||||
|
'exp',
|
||||||
|
'linalg',
|
||||||
|
'linspace',
|
||||||
'math',
|
'math',
|
||||||
'np',
|
'np',
|
||||||
|
'pi',
|
||||||
'random',
|
'random',
|
||||||
'sample',
|
'sample',
|
||||||
|
'sin',
|
||||||
|
'sqrt',
|
||||||
];
|
];
|
||||||
|
4
src/thirdparty/render.py
vendored
4
src/thirdparty/render.py
vendored
@ -19,11 +19,11 @@ from qiskit.visualization import array_to_latex;
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
'Latex',
|
||||||
'array_to_latex',
|
'array_to_latex',
|
||||||
|
'display',
|
||||||
'display_latex',
|
'display_latex',
|
||||||
'display_markdown',
|
'display_markdown',
|
||||||
'display_png',
|
'display_png',
|
||||||
'display',
|
|
||||||
'Latex',
|
|
||||||
'widgets',
|
'widgets',
|
||||||
];
|
];
|
||||||
|
4
src/thirdparty/types.py
vendored
4
src/thirdparty/types.py
vendored
@ -38,8 +38,8 @@ from typing import Generic;
|
|||||||
from typing import Optional;
|
from typing import Optional;
|
||||||
from typing import Type;
|
from typing import Type;
|
||||||
from typing import TypeVar;
|
from typing import TypeVar;
|
||||||
from typing_extensions import Concatenate;
|
from typing import Concatenate;
|
||||||
from typing_extensions import ParamSpec;
|
from typing import ParamSpec;
|
||||||
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
# EXPORTS
|
# EXPORTS
|
||||||
|
Loading…
Reference in New Issue
Block a user