Skip to content

Commit

Permalink
Renames package to RATapi (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenNneji authored Jul 16, 2024
1 parent c707549 commit 7dcfc1d
Show file tree
Hide file tree
Showing 63 changed files with 393 additions and 393 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
- name: Install and Test with pytest
run: |
python -m pip install -e .[Dev]
pytest tests/ --cov=RATpy --cov-report=term
pytest tests/ --cov=RATapi --cov-report=term
8 changes: 8 additions & 0 deletions RATapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from RATapi import events, models
from RATapi.classlist import ClassList
from RATapi.controls import Controls
from RATapi.project import Project
from RATapi.run import run
from RATapi.utils import plotting

__all__ = ["models", "events", "ClassList", "Controls", "Project", "run", "plotting"]
File renamed without changes.
4 changes: 2 additions & 2 deletions RATpy/controls.py → RATapi/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
model_validator,
)

from RATpy.utils.custom_errors import custom_pydantic_validation_error
from RATpy.utils.enums import BoundHandling, Display, Parallel, Procedures, Strategies
from RATapi.utils.custom_errors import custom_pydantic_validation_error
from RATapi.utils.enums import BoundHandling, Display, Parallel, Procedures, Strategies

common_fields = ["procedure", "parallel", "calcSldDuringFit", "resampleParams", "display"]
update_fields = ["updateFreq", "updatePlotFreq"]
Expand Down
2 changes: 1 addition & 1 deletion RATpy/events.py → RATapi/events.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import Callable, List, Union

from RATpy.rat_core import EventBridge, EventTypes, PlotEventData, ProgressEventData
from RATapi.rat_core import EventBridge, EventTypes, PlotEventData, ProgressEventData


def notify(event_type: EventTypes, data: Union[str, PlotEventData, ProgressEventData]) -> None:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np

import RATpy as RAT
import RATapi as RAT

problem = RAT.Project(
name="Absorption example",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pathlib

import RATpy as RAT
import RATapi as RAT

problem = RAT.Project(calculation="domains", model="custom xy", geometry="substrate/liquid")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pathlib

import RATpy as RAT
import RATapi as RAT

problem = RAT.Project(calculation="domains", model="custom layers", geometry="substrate/liquid")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import RATpy as RAT
import RATapi as RAT

problem = RAT.Project(calculation="domains")

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import setup_problem

import RATpy as RAT
import RATapi as RAT

path = pathlib.Path(__file__).parent.resolve()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numpy as np

import RATpy as RAT
import RATapi as RAT


def make_example_problem():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import numpy as np

import RATpy as RAT
import RATapi as RAT

# Start by making the class and setting it to a custom layers type:
problem = RAT.Project(name="Orso lipid example - custom XY", model="custom xy", geometry="substrate/liquid")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numpy as np

import RATpy as RAT
import RATapi as RAT

problem = RAT.Project(name="Orso lipid example - custom layers", model="custom layers", geometry="substrate/liquid")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np

import RATpy as RAT
import RATapi as RAT

problem = RAT.Project(
name="original_dspc_bilayer",
Expand Down
File renamed without changes.
40 changes: 20 additions & 20 deletions RATpy/inputs.py → RATapi/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import pathlib
from typing import Callable, Union

import RATpy
import RATpy.controls
import RATpy.wrappers
from RATpy.rat_core import Cells, Checks, Control, Limits, Priors, ProblemDefinition
from RATpy.utils.enums import Calculations, Languages, LayerModels, TypeOptions
import RATapi
import RATapi.controls
import RATapi.wrappers
from RATapi.rat_core import Cells, Checks, Control, Limits, Priors, ProblemDefinition
from RATapi.utils.enums import Calculations, Languages, LayerModels, TypeOptions


def make_input(
project: RATpy.Project, controls: RATpy.Controls
project: RATapi.Project, controls: RATapi.Controls
) -> tuple[ProblemDefinition, Cells, Limits, Priors, Control]:
"""Constructs the inputs required for the compiled RAT code using the data defined in the input project and
controls.
Expand Down Expand Up @@ -67,7 +67,7 @@ def make_input(
limits = Limits()
priors = Priors()

for class_list in RATpy.project.parameter_class_lists:
for class_list in RATapi.project.parameter_class_lists:
setattr(checks, checks_field[class_list], [int(element.fit) for element in getattr(project, class_list)])
setattr(
limits,
Expand All @@ -86,11 +86,11 @@ def make_input(
priors.qzshift = []

priors.priorNames = [
param.name for class_list in RATpy.project.parameter_class_lists for param in getattr(project, class_list)
param.name for class_list in RATapi.project.parameter_class_lists for param in getattr(project, class_list)
]
priors.priorValues = [
[prior_id[param.prior_type], param.mu, param.sigma]
for class_list in RATpy.project.parameter_class_lists
for class_list in RATapi.project.parameter_class_lists
for param in getattr(project, class_list)
]

Expand All @@ -102,7 +102,7 @@ def make_input(
return problem, cells, limits, priors, cpp_controls


def make_problem(project: RATpy.Project) -> ProblemDefinition:
def make_problem(project: RATapi.Project) -> ProblemDefinition:
"""Constructs the problem input required for the compiled RAT code.
Parameters
Expand Down Expand Up @@ -180,25 +180,25 @@ def make_problem(project: RATpy.Project) -> ProblemDefinition:
problem.numberOfDomainContrasts = len(project.domain_contrasts)
problem.fitParams = [
param.value
for class_list in RATpy.project.parameter_class_lists
for class_list in RATapi.project.parameter_class_lists
for param in getattr(project, class_list)
if param.fit
]
problem.fitLimits = [
[param.min, param.max]
for class_list in RATpy.project.parameter_class_lists
for class_list in RATapi.project.parameter_class_lists
for param in getattr(project, class_list)
if param.fit
]
problem.otherParams = [
param.value
for class_list in RATpy.project.parameter_class_lists
for class_list in RATapi.project.parameter_class_lists
for param in getattr(project, class_list)
if not param.fit
]
problem.otherLimits = [
[param.min, param.max]
for class_list in RATpy.project.parameter_class_lists
for class_list in RATapi.project.parameter_class_lists
for param in getattr(project, class_list)
if not param.fit
]
Expand All @@ -208,7 +208,7 @@ def make_problem(project: RATpy.Project) -> ProblemDefinition:
return problem


def make_resample(project: RATpy.Project) -> list[int]:
def make_resample(project: RATapi.Project) -> list[int]:
"""Constructs the "resample" field of the problem input required for the compiled RAT code.
Parameters
Expand All @@ -225,7 +225,7 @@ def make_resample(project: RATpy.Project) -> list[int]:
return [contrast.resample for contrast in project.contrasts]


def make_data_present(project: RATpy.Project) -> list[int]:
def make_data_present(project: RATapi.Project) -> list[int]:
"""Constructs the "dataPresent" field of the problem input required for the compiled RAT code.
Parameters
Expand Down Expand Up @@ -281,7 +281,7 @@ def check_indices(problem: ProblemDefinition) -> None:
)


def make_cells(project: RATpy.Project) -> Cells:
def make_cells(project: RATapi.Project) -> Cells:
"""Constructs the cells input required for the compiled RAT code.
Note that the order of the inputs (i.e, f1 to f20) has been hard--coded into the compiled RAT code.
Expand Down Expand Up @@ -352,9 +352,9 @@ def make_cells(project: RATpy.Project) -> Cells:
if custom_file.language == Languages.Python:
file_handles.append(get_python_handle(custom_file.filename, custom_file.function_name, custom_file.path))
elif custom_file.language == Languages.Matlab:
file_handles.append(RATpy.wrappers.MatlabWrapper(full_path).getHandle())
file_handles.append(RATapi.wrappers.MatlabWrapper(full_path).getHandle())
elif custom_file.language == Languages.Cpp:
file_handles.append(RATpy.wrappers.DylibWrapper(full_path, custom_file.function_name).getHandle())
file_handles.append(RATapi.wrappers.DylibWrapper(full_path, custom_file.function_name).getHandle())

# Populate the set of cells
cells = Cells()
Expand Down Expand Up @@ -416,7 +416,7 @@ def get_python_handle(file_name: str, function_name: str, path: Union[str, pathl
return handle


def make_controls(input_controls: RATpy.Controls, checks: Checks) -> Control:
def make_controls(input_controls: RATapi.Controls, checks: Checks) -> Control:
"""Converts the controls object to the format required by the compiled RAT code.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion RATpy/models.py → RATapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import prettytable
from pydantic import BaseModel, Field, ValidationInfo, field_validator, model_validator

from RATpy.utils.enums import BackgroundActions, Hydration, Languages, Priors, TypeOptions
from RATapi.utils.enums import BackgroundActions, Hydration, Languages, Priors, TypeOptions

try:
from enum import StrEnum
Expand Down
8 changes: 4 additions & 4 deletions RATpy/outputs.py → RATapi/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import numpy as np

import RATpy.rat_core
from RATpy.utils.enums import Procedures
import RATapi.rat_core
from RATapi.utils.enums import Procedures


@dataclass
Expand Down Expand Up @@ -110,8 +110,8 @@ class BayesResults(Results):

def make_results(
procedure: Procedures,
output_results: RATpy.rat_core.OutputResult,
bayes_results: Optional[RATpy.rat_core.BayesResults] = None,
output_results: RATapi.rat_core.OutputResult,
bayes_results: Optional[RATapi.rat_core.BayesResults] = None,
) -> Union[Results, BayesResults]:
"""Initialise a python Results or BayesResults object using the outputs from a RAT calculation."""
calculation_results = CalculationResults(
Expand Down
Loading

0 comments on commit 7dcfc1d

Please sign in to comment.