Skip to content

Commit

Permalink
apply ruff check --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
satos committed Sep 8, 2024
1 parent 800ac94 commit 348144e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 38 deletions.
7 changes: 3 additions & 4 deletions misc/MV_python_integrator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-

from abc import ABC
import sys, random
import sys
import socket
import pickle
import copy
from py4j.java_gateway import JavaGateway, GatewayParameters, CallbackServerParameters
from aalpy.base import Automaton, AutomatonState
from aalpy.SULs import MdpSUL
from aalpy.utils import load_automaton_from_file
from StrategyBridge import StrategyBridge
Expand All @@ -24,8 +23,8 @@ def __init__(self):
)
self.sul = MdpSUL(mdp)
# == デバッグ用 ==
self.prism_model_path = f"/Users/bo40/workspace/python/mc_exp.prism"
self.prism_adv_path = f"/Users/bo40/workspace/python/adv.tra"
self.prism_model_path = "/Users/bo40/workspace/python/mc_exp.prism"
self.prism_adv_path = "/Users/bo40/workspace/python/adv.tra"
# ====
self.strategy_bridge = StrategyBridge(
self.prism_adv_path, self.prism_model_path
Expand Down
1 change: 0 additions & 1 deletion misc/dfa_lean.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from aalpy.utils import (
load_automaton_from_file,
save_automaton_to_file,
visualize_automaton,
generate_random_dfa,
Expand Down
4 changes: 0 additions & 4 deletions misc/learn_then_model_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
from aalpy.oracles import RandomWalkEqOracle, RandomWordEqOracle
from aalpy.learning_algs import run_stochastic_Lstar
from aalpy.utils import (
visualize_automaton,
load_automaton_from_file,
model_check_experiment,
get_properties_file,
get_correct_prop_values,
mdp_2_prism_format,
)
from aalpy.automata.StochasticMealyMachine import smm_to_mdp_conversion
Expand Down
1 change: 0 additions & 1 deletion misc/mdp_model_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from aalpy.oracles import RandomWalkEqOracle, RandomWordEqOracle
from aalpy.learning_algs import run_stochastic_Lstar
from aalpy.utils import (
visualize_automaton,
load_automaton_from_file,
model_check_experiment,
get_properties_file,
Expand Down
9 changes: 2 additions & 7 deletions src/ProbBlackBoxChecking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
import collections
import os
import shutil
from sys import prefix
from typing import List
import aalpy.paths
from aalpy.base import Oracle, SUL
from aalpy.base import SUL
from aalpy.automata import StochasticMealyMachine
from aalpy.SULs import MdpSUL
from aalpy.oracles import RandomWalkEqOracle, RandomWordEqOracle
from aalpy.oracles import RandomWalkEqOracle
from aalpy.learning_algs import run_stochastic_Lstar
from aalpy.utils import (
load_automaton_from_file,
mdp_2_prism_format,
get_properties_file,
get_correct_prop_values,
)
from aalpy.automata.StochasticMealyMachine import smm_to_mdp_conversion
from aalpy.utils.HelperFunctions import print_observation_table

from Smc import StatisticalModelChecker
from StrategyBridge import StrategyBridge
Expand Down
3 changes: 1 addition & 2 deletions src/StrategyBridge.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
import random
import numpy as np
from typing import Dict, Tuple, Set, List
from typing import Dict, Tuple, List

# Stateは多分本当はint
State = int
Expand Down
2 changes: 1 addition & 1 deletion src/prism_export_to_dot_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main():
name = name_of_labels[idx]
if name == "init":
initial_state = m[1]
if not name in except_names:
if name not in except_names:
label_names.append(name)
labels[m[1]] = "__".join(label_names)

Expand Down
12 changes: 6 additions & 6 deletions src/tests/Smc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def test_initialize(self):
automaton_type="mdp",
)
sul = MdpSUL(mdp)
sample_prism_model = f"/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = f"/Users/bo40/workspace/python/adv_sample.tra"
sample_prism_model = "/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = "/Users/bo40/workspace/python/adv_sample.tra"
sb = StrategyBridge(sample_prism_adv, sample_prism_model)

spec_path = f"/Users/bo40/workspace/python/sandbox/shared_coin.ltl"
spec_path = "/Users/bo40/workspace/python/sandbox/shared_coin.ltl"
smc = StatisticalModelChecker(sul, sb, spec_path)

custom_print(smc.spec_monitor)
Expand All @@ -77,11 +77,11 @@ def test_smc_run(self):
automaton_type="mdp",
)
sul = MdpSUL(mdp)
sample_prism_model = f"/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = f"/Users/bo40/workspace/python/adv_sample.tra"
sample_prism_model = "/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = "/Users/bo40/workspace/python/adv_sample.tra"
sb = StrategyBridge(sample_prism_adv, sample_prism_model)

spec_path = f"/Users/bo40/workspace/python/sandbox/shared_coin.ltl"
spec_path = "/Users/bo40/workspace/python/sandbox/shared_coin.ltl"
smc = StatisticalModelChecker(sul, sb, spec_path, num_exec=5000)

smc.run()
Expand Down
16 changes: 8 additions & 8 deletions src/tests/StrategyBridge_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class StrategyBridgeTestCase(unittest.TestCase):
def test_initialize(self):
sample_prism_model = f"/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = f"/Users/bo40/workspace/python/adv_sample.tra"
sample_prism_model = "/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = "/Users/bo40/workspace/python/adv_sample.tra"
sb = StrategyBridge(sample_prism_adv, sample_prism_model)

self.assertEqual(sb.initial_state, 0)
Expand All @@ -25,8 +25,8 @@ def test_initialize(self):
)

def test_next(self):
sample_prism_model = f"/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = f"/Users/bo40/workspace/python/adv_sample.tra"
sample_prism_model = "/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = "/Users/bo40/workspace/python/adv_sample.tra"
sb = StrategyBridge(sample_prism_adv, sample_prism_model)

self.assertEqual(sb.next_action(), "go2")
Expand All @@ -38,8 +38,8 @@ def test_next(self):
# self.assertEqual(sb.history, [("go2", 'agree__c1_tails__c2_tails__six'), ("go2", 'agree__c1_tails__c2_tails__five')])

def test_reset(self):
sample_prism_model = f"/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = f"/Users/bo40/workspace/python/adv_sample.tra"
sample_prism_model = "/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = "/Users/bo40/workspace/python/adv_sample.tra"
sb = StrategyBridge(sample_prism_adv, sample_prism_model)

sb.update_state("go2", "agree__c1_tails__c2_tails__six")
Expand All @@ -52,8 +52,8 @@ def test_reset(self):
# self.assertEqual(sb.history, [])

def test_update_state_false(self):
sample_prism_model = f"/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = f"/Users/bo40/workspace/python/adv_sample.tra"
sample_prism_model = "/Users/bo40/workspace/python/mc_exp_sample.prism"
sample_prism_adv = "/Users/bo40/workspace/python/adv_sample.tra"
sb = StrategyBridge(sample_prism_adv, sample_prism_model)

# TODO : implement this test
Expand Down
4 changes: 0 additions & 4 deletions stat/scripts/plot_graph.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import sys
import os
import math
import numpy as np
import matplotlib
from matplotlib import pyplot as plt

# Gaussian process regression
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import WhiteKernel, RBF

stat_file = sys.argv[1]
baseline_file = sys.argv[2]
Expand Down

0 comments on commit 348144e

Please sign in to comment.