Skip to content

Commit

Permalink
reorganized main packages
Browse files Browse the repository at this point in the history
  • Loading branch information
danbryce committed Dec 23, 2022
1 parent 92194b1 commit 6970c59
Show file tree
Hide file tree
Showing 50 changed files with 758 additions and 753 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ CMD_UPDATE_VERSION = sed -i -E 's/^__version__ = \"[0-9]+\.[0-9]+\.[0-9]+((a|b|r

USING_PODMAN := $(shell docker --version | grep -q podman && echo 1 || echo 0)

.PHONY: docs

venv:
test -d .venv || python -m venv .venv
source .venv/bin/activate && pip install -Ur requirements-dev.txt
source .venv/bin/activate && pip install -Ur requirements-dev-extras.txt

docs:
sphinx-apidoc -f -o ./docs/source ./src/funman -t ./docs/apidoc_templates --no-toc --module-first
sphinx-apidoc -f -o ./docs/source ./src/funman -t ./docs/apidoc_templates --no-toc --module-first
mkdir -p ./docs/source/_static
mkdir -p ./docs/source/_templates
pyreverse \
Expand Down
4 changes: 2 additions & 2 deletions auxiliary_packages/funman_demo/src/funman_demo/box_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from matplotlib.lines import Line2D

from funman.model import Parameter
from funman.search_episode import BoxSearchEpisode, SearchEpisode
from funman.utils.search_utils import Box, Interval, Point
from funman.search import SearchEpisode
from funman.search.representation import Box, Interval, Point

l = logging.getLogger(__file__)
l.setLevel(logging.INFO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ParameterSynthesisScenario,
ParameterSynthesisScenarioResult,
)
from funman.utils.search_utils import ResultCombinedHandler, SearchConfig
from funman.search.representation import ResultCombinedHandler, SearchConfig

from ..plot import plot_parameter_space

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

from funman import Funman
from funman.model import Parameter, QueryLE, QueryTrue
from funman.model2smtlib.bilayer.translate import (
BilayerEncoder,
BilayerEncodingOptions,
)
from funman.model.bilayer import Bilayer, BilayerMeasurement, BilayerModel
from funman.scenario.consistency import ConsistencyScenario
from funman.scenario.parameter_synthesis import ParameterSynthesisScenario
from funman.utils.search_utils import ResultCombinedHandler, SearchConfig
from funman.search.representation import ResultCombinedHandler, SearchConfig
from funman.translate.bilayer.bilayer import (
BilayerEncoder,
BilayerEncodingOptions,
)


def run_chime_bilayer_example(output_path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@

from funman import Funman
from funman.model import Parameter, QueryLE, QueryTrue
from funman.model2smtlib.bilayer.translate import (
BilayerEncoder,
BilayerEncodingOptions,
)
from funman.model.bilayer import Bilayer, BilayerMeasurement, BilayerModel
from funman.scenario.consistency import ConsistencyScenario
from funman.scenario.parameter_synthesis import ParameterSynthesisScenario
from funman.search import BoxSearch, SMTCheck
from funman.search_episode import DRealSearchEpisode
from funman.utils.search_utils import (
from funman.search.representation import (
Point,
ResultCombinedHandler,
SearchConfig,
)
from funman.search.search_episode import DRealSearchEpisode
from funman.translate.bilayer.bilayer import (
BilayerEncoder,
BilayerEncodingOptions,
)


class Scenario1(object):
Expand Down
2 changes: 1 addition & 1 deletion auxiliary_packages/funman_demo/src/funman_demo/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from IPython.display import Image, display

from funman.model import Parameter
from funman.utils.search_utils import (
from funman.search.representation import (
Box,
Point,
ResultHandler,
Expand Down
2 changes: 1 addition & 1 deletion auxiliary_packages/funman_demo/src/funman_demo/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from matplotlib.lines import Line2D

from funman.parameter_space import ParameterSpace
from funman.utils.search_utils import Box, Point, decode_labeled_object
from funman.search.representation import Box, Point, decode_labeled_object

from .box_plotter import BoxPlotter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from funman.model.encoded import EncodedModel
from funman.scenario.parameter_synthesis import ParameterSynthesisScenario
from funman.search import BoxSearch
from funman.utils.search_utils import SearchConfig
from funman.search.representation import SearchConfig

l = logging.getLogger(__file__)
l.setLevel(logging.INFO)
Expand Down
16 changes: 8 additions & 8 deletions auxiliary_packages/funman_dreal/test/test_chime_bilayer_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@

from funman import Funman
from funman.model import Model, Parameter, QueryLE
from funman.model2smtlib.bilayer.translate import (
Bilayer,
BilayerEncoder,
BilayerEncodingOptions,
BilayerMeasurement,
BilayerModel,
)
from funman.scenario.consistency import ConsistencyScenario
from funman.scenario.parameter_synthesis import ParameterSynthesisScenario
from funman.search import BoxSearch, SMTCheck
from funman.utils.search_utils import (
from funman.search.representation import (
Point,
ResultCombinedHandler,
SearchConfig,
)
from funman.translate.bilayer.bilayer import (
Bilayer,
BilayerEncoder,
BilayerEncodingOptions,
BilayerMeasurement,
BilayerModel,
)
from funman.utils.smtlib_utils import smtlibscript_from_formula

l = logging.getLogger(__file__)
Expand Down
10 changes: 7 additions & 3 deletions docs/apidoc_templates/package.rst_t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{%- endfor %}
{%- endmacro %}

{%- macro toctree(docnames) -%}
{%- macro toctree(docnames, maxdepth) -%}
.. toctree::
:maxdepth: {{ maxdepth }}
{% for docname in docnames %}
Expand All @@ -31,8 +31,12 @@
Subpackages
-----------

{{ toctree(subpackages) }}
{% endif %}
{{ toctree(subpackages, maxdepth=2) }}
{% for subpackage in subpackages %}
{{- subpackage | e | heading(3) }}
{{ automodule(subpackage, automodule_options) }}
{% endfor %}
{%- endif %}

{%- if submodules %}
Submodules
Expand Down
10 changes: 10 additions & 0 deletions docs/source/funman.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ funman.model.encoded
:members:
:undoc-members:
:show-inheritance:

funman.model.query
------------------
.. inheritance-diagram:: funman.model.query
:parts: 1

.. automodule:: funman.model.query
:members:
:undoc-members:
:show-inheritance:
14 changes: 13 additions & 1 deletion docs/source/funman.model2smtlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@ Subpackages
-----------

.. toctree::
:maxdepth: 4
:maxdepth: 2

funman.model2smtlib.bilayer
funman.model2smtlib.gromet
funman.model2smtlib.bilayer
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: funman.model2smtlib.bilayer
:members:
:undoc-members:
:show-inheritance:
funman.model2smtlib.gromet
~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: funman.model2smtlib.gromet
:members:
:undoc-members:
:show-inheritance:

Submodules
----------
Expand Down
2 changes: 1 addition & 1 deletion scratch/CHIME/test_CHIME_SIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from funman_demo.sim.CHIME.CHIME_SIR import main as run_CHIME_SIR

from funman.model2smtlib.gromet.translate import QueryableGromet
from funman.translate.gromet.gromet import QueryableGromet

RESOURCES = os.path.join("resources")
GROMET_FILE = os.path.join(
Expand Down
2 changes: 1 addition & 1 deletion scratch/CHIME/test_CHIME_parameter_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import unittest
from multiprocessing.heap import Arena

from funman.model2smtlib.gromet.translate import QueryableGromet
from funman.parameter_space import ParameterSpace
from funman.translate.gromet.gromet import QueryableGromet

RESOURCES = os.path.join("resources")
GROMET_FILE_1 = os.path.join(
Expand Down
2 changes: 1 addition & 1 deletion scratch/CHIME/test_cached_parameter_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from funman.model.encoded import EncodedModel
from funman.scenario.parameter_synthesis import ParameterSynthesisScenario
from funman.search import BoxSearch
from funman.utils.search_utils import ResultCombinedHandler, SearchConfig
from funman.search.representation import ResultCombinedHandler, SearchConfig

l = logging.getLogger(__file__)
l.setLevel(logging.ERROR)
Expand Down
2 changes: 1 addition & 1 deletion scratch/model2smtlib/test_fn2smt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pysmt.shortcuts import Symbol, get_model
from pysmt.typing import INT

from funman.model2smtlib.gromet.translate import QueryableGromet
from funman.translate.gromet.gromet import QueryableGromet

RESOURCES = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "../resources"
Expand Down
2 changes: 1 addition & 1 deletion scratch/model2smtlib/test_parseGroMEtJSON.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest

from funman.model2smtlib.gromet.translate import QueryableGromet
from funman.translate.gromet.gromet import QueryableGromet

RESOURCES = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "../resources"
Expand Down
50 changes: 2 additions & 48 deletions src/funman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,6 @@
- Parameter Synthesis: Generating feasible values for model parameters.
"""

import logging

import funman
from funman._version import __version__
from funman.config import Config
from funman.scenario import AnalysisScenario, AnalysisScenarioResult

l = logging.getLogger(__file__)
l.setLevel(logging.ERROR)


class Funman(object):
"""
The Funman FUNctional Model ANalysis class is the main entry point for
performing analysis on models. The main entry point Funman.solve() performs
analysis of an funman.scenario.AnalysisScenario, subject to a set of configuration
options in the funman.search.SearchConfig class.
"""

def solve(
self, problem: AnalysisScenario, config: Config = None
) -> AnalysisScenarioResult:
"""
This method is the main entry point for Funman analysis. Its inputs
describe an AnalysisScenario and SearchConfig that setup the problem and
analysis technique. The return value is an AnalysisScenarioResult,
which comprises all relevant output pertaining to the AnalysisScenario.
Parameters
----------
problem : AnalysisScenario
The problem is a description of the analysis to be performed, and typically describes a Model and a Query.
config : SearchConfig, optional
The configuration for the search algorithm applied to analyze the problem, by default SearchConfig()
Returns
-------
AnalysisScenarioResult
The resulting data, statistics, and other relevant information produced by the analysis.
"""
return problem.solve(config)


def main():
return funman.Funman()


if __name__ == "main":
main()
from ._version import __version__
from .funman import *
7 changes: 0 additions & 7 deletions src/funman/config.py

This file was deleted.

38 changes: 38 additions & 0 deletions src/funman/funman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import logging

from funman.scenario import AnalysisScenario, AnalysisScenarioResult, Config

l = logging.getLogger(__file__)
l.setLevel(logging.ERROR)


class Funman(object):
"""
The Funman FUNctional Model ANalysis class is the main entry point for
performing analysis on models. The main entry point Funman.solve() performs
analysis of an funman.scenario.AnalysisScenario, subject to a set of configuration
options in the funman.search.SearchConfig class.
"""

def solve(
self, problem: AnalysisScenario, config: Config = None
) -> AnalysisScenarioResult:
"""
This method is the main entry point for Funman analysis. Its inputs
describe an AnalysisScenario and SearchConfig that setup the problem and
analysis technique. The return value is an AnalysisScenarioResult,
which comprises all relevant output pertaining to the AnalysisScenario.
Parameters
----------
problem : AnalysisScenario
The problem is a description of the analysis to be performed, and typically describes a Model and a Query.
config : SearchConfig, optional
The configuration for the search algorithm applied to analyze the problem, by default SearchConfig()
Returns
-------
AnalysisScenarioResult
The resulting data, statistics, and other relevant information produced by the analysis.
"""
return problem.solve(config)
Loading

0 comments on commit 6970c59

Please sign in to comment.