Skip to content

Commit

Permalink
Merge pull request #655 from crecine/add_top_dir
Browse files Browse the repository at this point in the history
adding aviary's top dir as something that can be imported
  • Loading branch information
crecine authored Jan 30, 2025
2 parents 620cf65 + 0c5fde0 commit 59f7f0b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aviary/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from aviary.interface.utils.check_phase_info import check_phase_info
from aviary.utils.engine_deck_conversion import EngineDeckConverter
from aviary.utils.fortran_to_aviary import fortran_to_aviary
from aviary.utils.functions import set_aviary_input_defaults, set_aviary_initial_values, get_path
from aviary.utils.functions import set_aviary_input_defaults, set_aviary_initial_values, get_path, top_dir
from aviary.utils.options import list_options
from aviary.constants import GRAV_METRIC_GASP, GRAV_ENGLISH_GASP, GRAV_METRIC_FLOPS, GRAV_ENGLISH_FLOPS, GRAV_ENGLISH_LBM, RHO_SEA_LEVEL_ENGLISH, RHO_SEA_LEVEL_METRIC, MU_TAKEOFF, MU_LANDING, PSLS_PSF, TSLS_DEGR, RADIUS_EARTH_METRIC
from aviary.subsystems.test.subsystem_tester import TestSubsystemBuilderBase, skipIfMissingDependencies
Expand Down
2 changes: 1 addition & 1 deletion aviary/docs/developer_guide/doctape_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you want to glue the name of a variable, instead of the value that variable holds, you can use the {glue:md}`get_variable_name` to extract it.\n",
"If you want to glue the name of a variable, instead of the value that variable holds, you can use the {glue:md}`get_variable_name` function to extract it.\n",
"\n",
"For example:\n",
"Using {glue:md}`var_value_code` will result in {glue:md}`value`, whereas using {glue:md}`var_name_code` will result in {glue:md}`Aircraft.Design.EMPTY_MASS`\n",
Expand Down
3 changes: 3 additions & 0 deletions aviary/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ def get_path(path: Union[str, Path], verbose: bool = False) -> Path:
return path


top_dir = Path(get_aviary_resource_path(''))


def wrapped_convert_units(val_unit_tuple, new_units):
"""
Wrapper for OpenMDAO's convert_units function.
Expand Down
7 changes: 7 additions & 0 deletions aviary/utils/test/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from aviary.variable_info.options import get_option_defaults
from aviary.variable_info.variables import Aircraft, Mission
from aviary.utils.functions import add_opts2vals, create_opts2vals, get_path
from aviary.api import top_dir


class TestOpts2Vals(unittest.TestCase):
Expand Down Expand Up @@ -104,5 +105,11 @@ def test_non_existent_path(self):
get_path('nonexistentfile.txt')


class TestTopDir(unittest.TestCase):
def test_top_dir(self):
result = Path(__file__).parent.parent.parent
self.assertEqual(result, top_dir)


if __name__ == "__main__":
unittest.main()

0 comments on commit 59f7f0b

Please sign in to comment.