Added 'sample_app.py' code

This commit is contained in:
2026-04-07 11:40:42 +02:00
parent cc773e7ccf
commit 99de79c9f0

View File

@@ -1,15 +1,23 @@
# This function was automatically generated. When modifying its signature, take care to apply import numpy as np
# modifications also to the descriptor files in the repository. import matplotlib.pyplot as plt
def main(numbers_files, multiplier): def main(numbers_files, multiplier):
""" """
Main function for application: PYTHONSAMPLEAPPMULTIPLEFILES Example Python application that reads the given numbers_files and multiplies
the content (numbers) by the supplied multiplier
Arguments: Arguments:
numbers_files: path to input file of type 'text_data' numbers_files: list of paths to input files of type 'text_data'
multiplier: parameter of type 'INTEGER' multiplier: number by which the arrays of numbers are multiplied
Returns: Returns:
File(s) named 'multiplied_numbers_plot.png' of type 'image_data' and format 'PNG' from working directory A file named 'multiplied_numbers_plot.png' containing a plot of multiplied
numbers.
""" """
# TODO: Put your application code here plt.figure()
for numbers_file in numbers_files:
numbers = np.genfromtxt(numbers_file, comments="#", delimiter=",", unpack=False)
numbers = numbers[~np.isnan(numbers)]
numbers = np.array(numbers).flatten()
multiplied_numbers = numbers * multiplier
plt.plot(multiplied_numbers)
plt.savefig('multiplied_numbers_plot.png')