Skip to content

Commit

Permalink
refactor: refer ProMCDA models instead of ranking-service models
Browse files Browse the repository at this point in the history
  • Loading branch information
kapil-agnihotri committed Sep 10, 2024
1 parent 943f2c6 commit a809166
Show file tree
Hide file tree
Showing 35 changed files with 243 additions and 89 deletions.
1 change: 0 additions & 1 deletion mcda/mcda_ranking_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ProMCDA.mcda.utils.utils_for_main import *
from ProMCDA.mcda.utils.utils_for_plotting import *
from ProMCDA.mcda.utils.utils_for_parallelization import *
from ProMCDA.models.configuration import Configuration

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion mcda/mcda_with_robustness.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np

from ProMCDA.mcda.utils.application_enums import MonteCarloMarginalDistributions
from ProMCDA.models.configuration import Configuration
from ProMCDA.mcda.models import Configuration

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion mcda/mcda_without_robustness.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ProMCDA.mcda.configuration.config import Config
from ProMCDA.mcda.mcda_functions.normalization import Normalization
from ProMCDA.mcda.mcda_functions.aggregation import Aggregation
from ProMCDA.models.configuration import Configuration
from ProMCDA.mcda.models import Configuration

log = logging.getLogger(__name__)

Expand Down
6 changes: 6 additions & 0 deletions mcda/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# coding: utf-8

# flake8: noqa
from __future__ import absolute_import
# import models into model package
from ProMCDA.mcda.models.log_normal_indicator_values import LogNormalIndicatorValues
2 changes: 1 addition & 1 deletion models/base_model_.py → mcda/models/base_model_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import six
import typing

from swagger_server import util
from ProMCDA.mcda import util

T = typing.TypeVar('T')

Expand Down
10 changes: 5 additions & 5 deletions models/configuration.py → mcda/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server.models.configuration_monte_carlo_sampling import ConfigurationMonteCarloSampling # noqa: F401,E501
from swagger_server.models.configuration_robustness import ConfigurationRobustness # noqa: F401,E501
from swagger_server.models.configuration_sensitivity import ConfigurationSensitivity # noqa: F401,E501
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda.models.configuration_monte_carlo_sampling import ConfigurationMonteCarloSampling # noqa: F401,E501
from ProMCDA.mcda.models.configuration_robustness import ConfigurationRobustness # noqa: F401,E501
from ProMCDA.mcda.models.configuration_sensitivity import ConfigurationSensitivity # noqa: F401,E501
from ProMCDA.mcda import util


class Configuration(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server.models.configuration_modified_input_monte_carlo_sampling import ConfigurationModifiedInputMonteCarloSampling # noqa: F401,E501
from swagger_server.models.configuration_modified_input_robustness import ConfigurationModifiedInputRobustness # noqa: F401,E501
from swagger_server.models.configuration_modified_input_sensitivity import ConfigurationModifiedInputSensitivity # noqa: F401,E501
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda.models.configuration_modified_input_monte_carlo_sampling import ConfigurationModifiedInputMonteCarloSampling # noqa: F401,E501
from ProMCDA.mcda.models.configuration_modified_input_robustness import ConfigurationModifiedInputRobustness # noqa: F401,E501
from ProMCDA.mcda.models.configuration_modified_input_sensitivity import ConfigurationModifiedInputSensitivity # noqa: F401,E501
from ProMCDA.mcda import util


class ConfigurationModifiedInput(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class ConfigurationModifiedInputMonteCarloSampling(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class ConfigurationModifiedInputRobustness(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class ConfigurationModifiedInputSensitivity(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class ConfigurationMonteCarloSampling(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class ConfigurationRobustness(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class ConfigurationSensitivity(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class ConvertCsvToJsonBody(Model):
Expand Down
4 changes: 2 additions & 2 deletions models/error.py → mcda/models/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class Error(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class ExactIndicatorValues(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class InlineResponse200(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class InlineResponse2001(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class InlineResponse2002(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class LogNormalIndicatorValues(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class NormalIndicatorValues(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class PoissonIndicatorValues(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server.models.sensitivity_ranked_alternatives import SensitivityRankedAlternatives # noqa: F401,E501
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda.models.sensitivity_ranked_alternatives import SensitivityRankedAlternatives # noqa: F401,E501
from ProMCDA.mcda import util


class SensitivityMCDA(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server.models.sensitivity_ranked_alternatives import SensitivityRankedAlternatives # noqa: F401,E501
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda.models.sensitivity_ranked_alternatives import SensitivityRankedAlternatives # noqa: F401,E501
from ProMCDA.mcda import util


class SensitivityProMCDA(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server.models.sensitivity_ranked_alternatives_inner import SensitivityRankedAlternativesInner # noqa: F401,E501
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda.models.sensitivity_ranked_alternatives_inner import SensitivityRankedAlternativesInner # noqa: F401,E501
from ProMCDA.mcda import util


class SensitivityRankedAlternatives(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class SensitivityRankedAlternativesInner(Model):
Expand Down
4 changes: 2 additions & 2 deletions models/simple_mcda.py → mcda/models/simple_mcda.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class SimpleMCDA(Model):
Expand Down
4 changes: 2 additions & 2 deletions models/simple_pro_mcda.py → mcda/models/simple_pro_mcda.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class SimpleProMCDA(Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List, Dict # noqa: F401

from swagger_server.models.base_model_ import Model
from swagger_server import util
from ProMCDA.mcda.models.base_model_ import Model
from ProMCDA.mcda import util


class UniformIndicatorValues(Model):
Expand Down
32 changes: 32 additions & 0 deletions mcda/type_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# coding: utf-8

import sys

if sys.version_info < (3, 7):
import typing

def is_generic(klass):
""" Determine whether klass is a generic class """
return type(klass) == typing.GenericMeta

def is_dict(klass):
""" Determine whether klass is a Dict """
return klass.__extra__ == dict

def is_list(klass):
""" Determine whether klass is a List """
return klass.__extra__ == list

else:

def is_generic(klass):
""" Determine whether klass is a generic class """
return hasattr(klass, '__origin__')

def is_dict(klass):
""" Determine whether klass is a Dict """
return klass.__origin__ == dict

def is_list(klass):
""" Determine whether klass is a List """
return klass.__origin__ == list
Loading

0 comments on commit a809166

Please sign in to comment.