Repository: dayyass/calculus-of-variations (language: python)

Issue:
fix relative paths
remove all **"TODO: fix it"**


Discussion / hints:

Fix patch:
diff --git a/examples.sh b/examples.sh
index a986fc1..cd78d99 100755
--- a/examples.sh
+++ b/examples.sh
@@ -1,32 +1,32 @@
 # simplest problem
-python src/calculus_of_variations/simplest_problem.py -L "x_diff ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1"
-python src/calculus_of_variations/simplest_problem.py -L "x_diff ** 2 + t * x" -t0 "0" -t1 "1" -x0 "0" -x1 "0"
-python src/calculus_of_variations/simplest_problem.py -L "t * x_diff ** 2" -t0 "1" -t1 "E" -x0 "0" -x1 "1"
-python src/calculus_of_variations/simplest_problem.py -L "x_diff ** 2 + x_diff * x + 12 * t * x" -t0 "0" -t1 "1" -x0 "0" -x1 "0"
-python src/calculus_of_variations/simplest_problem.py -L "x_diff ** 2 - t ** 2 * x" -t0 "0" -t1 "1" -x0 "0" -x1 "0"
+python -m src.calculus_of_variations.simplest_problem -L "x_diff ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1"
+python -m src.calculus_of_variations.simplest_problem -L "x_diff ** 2 + t * x" -t0 "0" -t1 "1" -x0 "0" -x1 "0"
+python -m src.calculus_of_variations.simplest_problem -L "t * x_diff ** 2" -t0 "1" -t1 "E" -x0 "0" -x1 "1"
+python -m src.calculus_of_variations.simplest_problem -L "x_diff ** 2 + x_diff * x + 12 * t * x" -t0 "0" -t1 "1" -x0 "0" -x1 "0"
+python -m src.calculus_of_variations.simplest_problem -L "x_diff ** 2 - t ** 2 * x" -t0 "0" -t1 "1" -x0 "0" -x1 "0"
 
 # boltz problem
-python src/calculus_of_variations/boltz_problem.py -L "x_diff ** 2 + 2 * x" -l "x_t0 ** 2" -t0 "0" -t1 "1"
-python src/calculus_of_variations/boltz_problem.py -L "x_diff ** 2 - x" -l "-x_t1 ** 2 / 2" -t0 "0" -t1 "1"
-python src/calculus_of_variations/boltz_problem.py -L "t ** 2 * x_diff ** 2" -l "-2 * x_t0 + x_t1 ** 2" -t0 "1" -t1 "2"
-python src/calculus_of_variations/boltz_problem.py -L "2 * (t * x_diff ** 2 + x_diff * x)" -l "3 * x_t0 ** 2 - x_t1 ** 2 - 4 * x_t1" -t0 "1" -t1 "E"
+python -m src.calculus_of_variations.boltz_problem -L "x_diff ** 2 + 2 * x" -l "x_t0 ** 2" -t0 "0" -t1 "1"
+python -m src.calculus_of_variations.boltz_problem -L "x_diff ** 2 - x" -l "-x_t1 ** 2 / 2" -t0 "0" -t1 "1"
+python -m src.calculus_of_variations.boltz_problem -L "t ** 2 * x_diff ** 2" -l "-2 * x_t0 + x_t1 ** 2" -t0 "1" -t1 "2"
+python -m src.calculus_of_variations.boltz_problem -L "2 * (t * x_diff ** 2 + x_diff * x)" -l "3 * x_t0 ** 2 - x_t1 ** 2 - 4 * x_t1" -t0 "1" -t1 "E"
 
 # isoperimetric problem
-python src/calculus_of_variations/isoperimetric_problem.py -f0 "x_diff ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1" -f_list "x" -alpha_list "0"
-python src/calculus_of_variations/isoperimetric_problem.py -f0 "x_diff ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1" -f_list "t * x" -alpha_list "0"
-python src/calculus_of_variations/isoperimetric_problem.py -f0 "x_diff ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "0" -f_list "x, t * x" -alpha_list "1, 0"
-python src/calculus_of_variations/isoperimetric_problem.py -f0 "x_diff ** 2" -t0 "0" -t1 "pi" -x0 "1" -x1 "-1" -f_list "x * cos(t)" -alpha_list "pi / 2"
-python src/calculus_of_variations/isoperimetric_problem.py -f0 "t ** 2 * x_diff ** 2" -t0 "1" -t1 "2" -x0 "1" -x1 "2" -f_list "t * x" -alpha_list "7 / 3"
+python -m src.calculus_of_variations.isoperimetric_problem -f0 "x_diff ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1" -f_list "x" -alpha_list "0"
+python -m src.calculus_of_variations.isoperimetric_problem -f0 "x_diff ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1" -f_list "t * x" -alpha_list "0"
+python -m src.calculus_of_variations.isoperimetric_problem -f0 "x_diff ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "0" -f_list "x, t * x" -alpha_list "1, 0"
+python -m src.calculus_of_variations.isoperimetric_problem -f0 "x_diff ** 2" -t0 "0" -t1 "pi" -x0 "1" -x1 "-1" -f_list "x * cos(t)" -alpha_list "pi / 2"
+python -m src.calculus_of_variations.isoperimetric_problem -f0 "t ** 2 * x_diff ** 2" -t0 "1" -t1 "2" -x0 "1" -x1 "2" -f_list "t * x" -alpha_list "7 / 3"
 
 # higher derivatives problem
-python src/calculus_of_variations/higher_derivatives_problem.py -n "2" -L "x_diff_2 ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "0" -x0_array "0" -x1_array "1"
-python src/calculus_of_variations/higher_derivatives_problem.py -n "2" -L "x_diff_2 ** 2 - 48 * x" -t0 "0" -t1 "1" -x0 "1" -x1 "0" -x0_array "-4" -x1_array "0"
-python src/calculus_of_variations/higher_derivatives_problem.py -n "3" -L "x_diff_3 ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1" -x0_array "0, 0" -x1_array "3, 6"
-python src/calculus_of_variations/higher_derivatives_problem.py -n "4" -L "x_diff_4 ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1" -x0_array "0, 0, 0" -x1_array "3, 6, 10"
+python -m src.calculus_of_variations.higher_derivatives_problem -n "2" -L "x_diff_2 ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "0" -x0_array "0" -x1_array "1"
+python -m src.calculus_of_variations.higher_derivatives_problem -n "2" -L "x_diff_2 ** 2 - 48 * x" -t0 "0" -t1 "1" -x0 "1" -x1 "0" -x0_array "-4" -x1_array "0"
+python -m src.calculus_of_variations.higher_derivatives_problem -n "3" -L "x_diff_3 ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1" -x0_array "0, 0" -x1_array "3, 6"
+python -m src.calculus_of_variations.higher_derivatives_problem -n "4" -L "x_diff_4 ** 2" -t0 "0" -t1 "1" -x0 "0" -x1 "1" -x0_array "0, 0, 0" -x1_array "3, 6, 10"
 
 # multidimensional problem
-python src/calculus_of_variations/multidimensional_problem.py -L "x1_diff**2 + x2_diff**2" -t0 "0" -t1 "1" -x1_0 "0" -x1_1 "1" -x2_0 "0" -x2_1 "1"
-python src/calculus_of_variations/multidimensional_problem.py -L "x1_diff ** 2 + x2_diff ** 2" -t0 "0" -t1 "1" -x1_0 "0" -x1_1 "1" -x2_0 "1" -x2_1 "E"
-python src/calculus_of_variations/multidimensional_problem.py -L "x2 ** 2 + x1_diff ** 2 + x2_diff ** 2" -t0 "0" -t1 "1" -x1_0 "0" -x1_1 "1" -x2_0 "1" -x2_1 "E"
-python src/calculus_of_variations/multidimensional_problem.py -L "x1_diff * x2_diff - x1 * x2" -t0 "0" -t1 "pi / 2" -x1_0 "0" -x1_1 "1" -x2_0 "1" -x2_1 "0"
-python src/calculus_of_variations/multidimensional_problem.py -L "2 * x1 + x2 ** 2 + x1_diff ** 2 + x2_diff ** 2" -t0 "0" -t1 "1" -x1_0 "0" -x1_1 "0.5" -x2_0 "1" -x2_1 "exp(-1)"
+python -m src.calculus_of_variations.multidimensional_problem -L "x1_diff**2 + x2_diff**2" -t0 "0" -t1 "1" -x1_0 "0" -x1_1 "1" -x2_0 "0" -x2_1 "1"
+python -m src.calculus_of_variations.multidimensional_problem -L "x1_diff ** 2 + x2_diff ** 2" -t0 "0" -t1 "1" -x1_0 "0" -x1_1 "1" -x2_0 "1" -x2_1 "E"
+python -m src.calculus_of_variations.multidimensional_problem -L "x2 ** 2 + x1_diff ** 2 + x2_diff ** 2" -t0 "0" -t1 "1" -x1_0 "0" -x1_1 "1" -x2_0 "1" -x2_1 "E"
+python -m src.calculus_of_variations.multidimensional_problem -L "x1_diff * x2_diff - x1 * x2" -t0 "0" -t1 "pi / 2" -x1_0 "0" -x1_1 "1" -x2_0 "1" -x2_1 "0"
+python -m src.calculus_of_variations.multidimensional_problem -L "2 * x1 + x2 ** 2 + x1_diff ** 2 + x2_diff ** 2" -t0 "0" -t1 "1" -x1_0 "0" -x1_1 "0.5" -x2_0 "1" -x2_1 "exp(-1)"
diff --git a/src/calculus_of_variations/boltz_problem.py b/src/calculus_of_variations/boltz_problem.py
index 4802c0b..8ece556 100644
--- a/src/calculus_of_variations/boltz_problem.py
+++ b/src/calculus_of_variations/boltz_problem.py
@@ -1,12 +1,9 @@
-import sys
 from argparse import ArgumentParser
 
 from sympy import diff, dsolve, integrate, solve, var
 
-# TODO: fix it
-sys.path.append("./")
-from src.calculus_of_variations.abstract_problem import AbstractSolver
-from src.calculus_of_variations.utils import sympy_eval, t, x, x_diff, x_t0, x_t1
+from .abstract_problem import AbstractSolver
+from .utils import sympy_eval, t, x, x_diff, x_t0, x_t1
 
 
 class BoltzSolver(AbstractSolver):
diff --git a/src/calculus_of_variations/higher_derivatives_problem.py b/src/calculus_of_variations/higher_derivatives_problem.py
index 53a57b0..ee54293 100644
--- a/src/calculus_of_variations/higher_derivatives_problem.py
+++ b/src/calculus_of_variations/higher_derivatives_problem.py
@@ -1,12 +1,9 @@
-import sys
 from argparse import ArgumentParser
 
 from sympy import diff, dsolve, integrate, solve, var
 
-# TODO: fix it
-sys.path.append("./")
-from src.calculus_of_variations.abstract_problem import AbstractSolver
-from src.calculus_of_variations.utils import (  # noqa: F401
+from .abstract_problem import AbstractSolver
+from .utils import (  # noqa: F401
     sympy_eval,
     t,
     x,
diff --git a/src/calculus_of_variations/isoperimetric_problem.py b/src/calculus_of_variations/isoperimetric_problem.py
index b42e7ab..f12d7db 100644
--- a/src/calculus_of_variations/isoperimetric_problem.py
+++ b/src/calculus_of_variations/isoperimetric_problem.py
@@ -1,12 +1,9 @@
-import sys
 from argparse import ArgumentParser
 
 from sympy import diff, dsolve, integrate, solve, var
 
-# TODO: fix it
-sys.path.append("./")
-from src.calculus_of_variations.abstract_problem import AbstractSolver
-from src.calculus_of_variations.utils import sympy_eval, t, x, x_diff
+from .abstract_problem import AbstractSolver
+from .utils import sympy_eval, t, x, x_diff
 
 
 class IsoperimetricSolver(AbstractSolver):
diff --git a/src/calculus_of_variations/multidimensional_problem.py b/src/calculus_of_variations/multidimensional_problem.py
index 60b77e6..eb2b2fc 100644
--- a/src/calculus_of_variations/multidimensional_problem.py
+++ b/src/calculus_of_variations/multidimensional_problem.py
@@ -1,12 +1,9 @@
-import sys
 from argparse import ArgumentParser
 
 from sympy import diff, dsolve, integrate, solve, var
 
-# TODO: fix it
-sys.path.append("./")
-from src.calculus_of_variations.abstract_problem import AbstractSolver
-from src.calculus_of_variations.utils import sympy_eval, t, x1, x1_diff, x2, x2_diff
+from .abstract_problem import AbstractSolver
+from .utils import sympy_eval, t, x1, x1_diff, x2, x2_diff
 
 
 class MultidimensionalSolver(AbstractSolver):
diff --git a/src/calculus_of_variations/simplest_problem.py b/src/calculus_of_variations/simplest_problem.py
index fcd2e29..4f88b87 100644
--- a/src/calculus_of_variations/simplest_problem.py
+++ b/src/calculus_of_variations/simplest_problem.py
@@ -1,12 +1,9 @@
-import sys
 from argparse import ArgumentParser
 
 from sympy import diff, dsolve, integrate, solve, var
 
-# TODO: fix it
-sys.path.append("./")
-from src.calculus_of_variations.abstract_problem import AbstractSolver
-from src.calculus_of_variations.utils import sympy_eval, t, x, x_diff
+from .abstract_problem import AbstractSolver
+from .utils import sympy_eval, t, x, x_diff
 
 
 class SimplestSolver(AbstractSolver):
diff --git a/web_interface/boltz_problem_dash.py b/web_interface/boltz_problem_dash.py
index 124b87c..7dd7007 100644
--- a/web_interface/boltz_problem_dash.py
+++ b/web_interface/boltz_problem_dash.py
@@ -1,14 +1,11 @@
-import sys
-
 import dash
 import dash_core_components as dcc
 import dash_html_components as html
 from dash.dependencies import Input, Output, State
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import BoltzSolver
-from web_interface.utils import dash_answer, dash_boltz_problem, get_argparse
+
+from .utils import dash_answer, dash_boltz_problem, get_argparse
 
 external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]
 app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
diff --git a/web_interface/higher_derivatives_problem_dash.py b/web_interface/higher_derivatives_problem_dash.py
index 15e1b27..a65a85f 100644
--- a/web_interface/higher_derivatives_problem_dash.py
+++ b/web_interface/higher_derivatives_problem_dash.py
@@ -1,18 +1,11 @@
-import sys
-
 import dash
 import dash_core_components as dcc
 import dash_html_components as html
 from dash.dependencies import Input, Output, State
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import HigherDerivativesSolver
-from web_interface.utils import (
-    dash_answer,
-    dash_higher_derivatives_problem,
-    get_argparse,
-)
+
+from .utils import dash_answer, dash_higher_derivatives_problem, get_argparse
 
 external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]
 app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
diff --git a/web_interface/isoperimetric_problem_dash.py b/web_interface/isoperimetric_problem_dash.py
index 4e35e89..f4fa97f 100644
--- a/web_interface/isoperimetric_problem_dash.py
+++ b/web_interface/isoperimetric_problem_dash.py
@@ -1,14 +1,11 @@
-import sys
-
 import dash
 import dash_core_components as dcc
 import dash_html_components as html
 from dash.dependencies import Input, Output, State
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import IsoperimetricSolver
-from web_interface.utils import dash_answer, dash_isoperimetric_problem, get_argparse
+
+from .utils import dash_answer, dash_isoperimetric_problem, get_argparse
 
 external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]
 app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
diff --git a/web_interface/multidimensional_problem_dash.py b/web_interface/multidimensional_problem_dash.py
index cdbff57..d5429ef 100644
--- a/web_interface/multidimensional_problem_dash.py
+++ b/web_interface/multidimensional_problem_dash.py
@@ -1,14 +1,11 @@
-import sys
-
 import dash
 import dash_core_components as dcc
 import dash_html_components as html
 from dash.dependencies import Input, Output, State
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import MultidimensionalSolver
-from web_interface.utils import (
+
+from .utils import (
     dash_multidimensional_answer,
     dash_multidimensional_problem,
     get_argparse,
diff --git a/web_interface/simplest_problem_dash.py b/web_interface/simplest_problem_dash.py
index 5a40ba7..5320d04 100644
--- a/web_interface/simplest_problem_dash.py
+++ b/web_interface/simplest_problem_dash.py
@@ -1,14 +1,11 @@
-import sys
-
 import dash
 import dash_core_components as dcc
 import dash_html_components as html
 from dash.dependencies import Input, Output, State
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import SimplestSolver
-from web_interface.utils import dash_answer, dash_simplest_problem, get_argparse
+
+from .utils import dash_answer, dash_simplest_problem, get_argparse
 
 external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]
 app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
diff --git a/web_interface/utils.py b/web_interface/utils.py
index 63abe3b..ce002f3 100644
--- a/web_interface/utils.py
+++ b/web_interface/utils.py
@@ -1,4 +1,3 @@
-import sys
 from argparse import ArgumentParser
 from typing import Dict, Union
 
@@ -6,8 +5,6 @@
 import dash_html_components as html
 from sympy.core.symbol import Symbol
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import (
     BoltzSolver,
     HigherDerivativesSolver,


Test patch:
diff --git a/tests/test_boltz_problem.py b/tests/test_boltz_problem.py
index 821d488..33740fb 100644
--- a/tests/test_boltz_problem.py
+++ b/tests/test_boltz_problem.py
@@ -1,10 +1,7 @@
-import sys
 import unittest
 
 from parameterized import parameterized_class
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import BoltzSolver
 from src.calculus_of_variations.utils import log, t
 
diff --git a/tests/test_higher_derivatives_problem.py b/tests/test_higher_derivatives_problem.py
index e917313..22db6b1 100644
--- a/tests/test_higher_derivatives_problem.py
+++ b/tests/test_higher_derivatives_problem.py
@@ -1,10 +1,7 @@
-import sys
 import unittest
 
 from parameterized import parameterized_class
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import HigherDerivativesSolver
 from src.calculus_of_variations.utils import t, var
 
diff --git a/tests/test_isoperimetric_problem.py b/tests/test_isoperimetric_problem.py
index ff614be..6c2990e 100644
--- a/tests/test_isoperimetric_problem.py
+++ b/tests/test_isoperimetric_problem.py
@@ -1,10 +1,7 @@
-import sys
 import unittest
 
 from parameterized import parameterized_class
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import IsoperimetricSolver
 from src.calculus_of_variations.utils import cos, pi, t, var
 
diff --git a/tests/test_multidimensional_problem.py b/tests/test_multidimensional_problem.py
index 581be18..2d186bc 100644
--- a/tests/test_multidimensional_problem.py
+++ b/tests/test_multidimensional_problem.py
@@ -1,10 +1,7 @@
-import sys
 import unittest
 
 from parameterized import parameterized_class
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import MultidimensionalSolver
 from src.calculus_of_variations.utils import E, I, exp, t
 
diff --git a/tests/test_simplest_problem.py b/tests/test_simplest_problem.py
index 3742db8..2494d2a 100644
--- a/tests/test_simplest_problem.py
+++ b/tests/test_simplest_problem.py
@@ -1,10 +1,7 @@
-import sys
 import unittest
 
 from parameterized import parameterized_class
 
-# TODO: fix it
-sys.path.append("./")
 from src.calculus_of_variations import SimplestSolver
 from src.calculus_of_variations.utils import log, t