Skip to content
Snippets Groups Projects
Commit 5130f6f9 authored by AxelCarayon's avatar AxelCarayon
Browse files

fix code type

parent bcc24404
Branches
Tags 1.3.0
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="Python" name="Python">
<configuration sdkName="Python 3.10 (venv)" />
</facet>
</component>
</module>
\ No newline at end of file
......@@ -7,65 +7,74 @@ OUTPUT_FOLDER = 'src/main/resources/pythonOutput'
JAR_LOCATION = 'out/artifacts/SMA_SEIR_jar/SMA-SEIR.jar'
YAML_FILE = 'src/main/resources/parameters.yaml'
def readCSV(fileName):
with open(fileName, 'r') as csvfile:
def read_csv(filename):
with open(filename, 'r') as csvfile:
reader = csv.reader(csvfile)
return list(reader)
def getValues() :
def get_values():
with open(YAML_FILE, 'r') as file:
data = yaml.safe_load(file)
incubation = data['incubationRate']
infection = data['infectionRate']
recovery = data['recoveryRate']
looseImmunity = data['looseImmunityRate']
return f"incubationRate : {incubation} InfectionRate : {infection}\n RecoveryRate : {recovery} LooseImmunityRate : {looseImmunity}"
loose_immunity = data['looseImmunityRate']
return f"incubationRate : {incubation} InfectionRate : {infection}\n " \
f"RecoveryRate : {recovery} LooseImmunityRate : {loose_immunity}"
def makeDiagram(fileName):
data = readCSV(fileName)
def make_diagram(filename):
data = read_csv(filename)
suceptible = []
exposed = []
recovred = []
recovered = []
infected = []
for row in data[1:]:
suceptible.append(int(row[0]))
exposed.append(int(row[1]))
recovred.append(int(row[2]))
recovered.append(int(row[2]))
infected.append(int(row[3]))
plt.title(getValues())
plt.title(get_values())
plt.plot(suceptible, label='Suceptible', color='gray')
plt.plot(exposed, label='Exposed', color='yellow')
plt.plot(infected, label='Infected', color='red')
plt.plot(recovred, label='Recovered', color='green')
plt.plot(recovered, label='Recovered', color='green')
plt.xlabel('Cycles')
plt.ylabel('Peoples')
plt.legend()
plt.savefig(f'{fileName.split(".")[0]}.png')
#plt.show()
plt.savefig(f'{filename.split(".")[0]}.png')
# plt.show()
plt.close()
def runJavaJar(fileName):
def run_java_jar(filename):
import subprocess
subprocess.call(['java', '-jar', fileName])
subprocess.call(['java', '-jar', filename])
def copyToOutputFolder(fileName):
def copy_to_output_folder(filename):
import shutil
shutil.copy(OUTPUT_FILE_LOCATION, f"{OUTPUT_FOLDER}/{fileName}")
def createFile():
shutil.copy(OUTPUT_FILE_LOCATION, f"{OUTPUT_FOLDER}/{filename}")
def create_file():
with open(OUTPUT_FILE_LOCATION, 'w') as file:
file.write('')
def editYaml(key,value):
def edit_yaml(key, value):
with open(YAML_FILE, 'r') as file:
data = yaml.safe_load(file)
data[key] = value
with open(YAML_FILE, 'w') as file:
yaml.dump(data, file)
# if __name__ == "__main__":
# for i in range(10):
# editYaml("infectionRate", 0.05+(0.05*i))
......@@ -73,5 +82,5 @@ def editYaml(key,value):
# copyToOutputFolder(f"output{i}.csv")
# makeDiagram(f"{OUTPUT_FOLDER}/output{i}.csv")
runJavaJar(JAR_LOCATION)
makeDiagram(OUTPUT_FILE_LOCATION)
\ No newline at end of file
run_java_jar(JAR_LOCATION)
make_diagram(OUTPUT_FILE_LOCATION)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment