Browse Source

[MNT] Format code

tags/v0.3.2
Gene 3 years ago
parent
commit
b411ac3670
3 changed files with 16 additions and 16 deletions
  1. +1
    -1
      learnware/market/__init__.py
  2. +11
    -11
      learnware/market/anchor.py
  3. +4
    -4
      learnware/market/base.py

+ 1
- 1
learnware/market/__init__.py View File

@@ -1,2 +1,2 @@
from .base import BaseUserInfo, BaseMarket from .base import BaseUserInfo, BaseMarket
from .anchor import AnchoredUserInfo, AnchoredMarket
from .anchor import AnchoredUserInfo, AnchoredMarket

+ 11
- 11
learnware/market/anchor.py View File

@@ -15,8 +15,8 @@ class AnchoredUserInfo(BaseUserInfo):


def __init__(self, id: str, property: dict = dict(), stat_info: dict = dict()): def __init__(self, id: str, property: dict = dict(), stat_info: dict = dict()):
super(AnchoredUserInfo, self).__init__(id, property, stat_info) super(AnchoredUserInfo, self).__init__(id, property, stat_info)
self.anchor_learnware_list = {} # id: Learnware
self.anchor_learnware_list = {} # id: Learnware
def add_anchor_learnware(self, learnware_id: str, learnware: Learnware): def add_anchor_learnware(self, learnware_id: str, learnware: Learnware):
"""Add the anchor learnware acquired from the market """Add the anchor learnware acquired from the market


@@ -28,7 +28,7 @@ class AnchoredUserInfo(BaseUserInfo):
Anchor learnware for capturing user requirements Anchor learnware for capturing user requirements
""" """
self.anchor_learnware_list[learnware_id] = learnware self.anchor_learnware_list[learnware_id] = learnware
def update_stat_info(self, name: str, item: Any): def update_stat_info(self, name: str, item: Any):
"""Update stat_info based on anchor learnwares """Update stat_info based on anchor learnwares


@@ -50,11 +50,11 @@ class AnchoredMarket(BaseMarket):
BaseMarket : _type_ BaseMarket : _type_
Basic market version Basic market version
""" """
def __init__(self): def __init__(self):
super(AnchoredMarket, self).__init__() super(AnchoredMarket, self).__init__()
self.anchor_learnware_list = {} # anchor_id: anchor learnware
self.anchor_learnware_list = {} # anchor_id: anchor learnware
def _update_anchor_learnware(self, anchor_id: str, anchor_learnware: Learnware): def _update_anchor_learnware(self, anchor_id: str, anchor_learnware: Learnware):
"""Update anchor_learnware_list """Update anchor_learnware_list


@@ -66,7 +66,7 @@ class AnchoredMarket(BaseMarket):
Anchor learnware Anchor learnware
""" """
self.anchor_learnware_list[anchor_id] = anchor_learnware self.anchor_learnware_list[anchor_id] = anchor_learnware
def _delete_anchor_learnware(self, anchor_id: str) -> bool: def _delete_anchor_learnware(self, anchor_id: str) -> bool:
"""Delete anchor learnware in anchor_learnware_list """Delete anchor learnware in anchor_learnware_list


@@ -90,7 +90,7 @@ class AnchoredMarket(BaseMarket):


self.anchor_learnware_list.pop(anchor_id) self.anchor_learnware_list.pop(anchor_id)
return True return True
def update_anchor_learnware_list(self, learnware_list: Dict[str, Learnware]): def update_anchor_learnware_list(self, learnware_list: Dict[str, Learnware]):
"""Update anchor_learnware_list """Update anchor_learnware_list


@@ -100,7 +100,7 @@ class AnchoredMarket(BaseMarket):
Learnwares for updating anchor_learnware_list Learnwares for updating anchor_learnware_list
""" """
pass pass
def search_anchor_learnware(self, user_info: AnchoredUserInfo) -> Tuple[Any, List[Learnware]]: def search_anchor_learnware(self, user_info: AnchoredUserInfo) -> Tuple[Any, List[Learnware]]:
"""Search anchor Learnwares from anchor_learnware_list based on user_info """Search anchor Learnwares from anchor_learnware_list based on user_info


@@ -119,7 +119,7 @@ class AnchoredMarket(BaseMarket):
- second is a list of anchor learnwares - second is a list of anchor learnwares
""" """
pass pass
def search_learnware(self, user_info: AnchoredUserInfo) -> Tuple[Any, List[Learnware]]: def search_learnware(self, user_info: AnchoredUserInfo) -> Tuple[Any, List[Learnware]]:
"""Find helpful learnwares from learnware_list based on user_info """Find helpful learnwares from learnware_list based on user_info


@@ -137,4 +137,4 @@ class AnchoredMarket(BaseMarket):
- first is recommended combination, None when no recommended combination is calculated or statistical specification is not provided. - first is recommended combination, None when no recommended combination is calculated or statistical specification is not provided.
- second is a list of matched learnwares - second is a list of matched learnwares
""" """
pass
pass

+ 4
- 4
learnware/market/base.py View File

@@ -30,7 +30,7 @@ class BaseUserInfo:
self.id = id self.id = id
self.property = property self.property = property
self.stat_info = stat_info self.stat_info = stat_info
def get_property(self) -> dict: def get_property(self) -> dict:
"""Return user properties """Return user properties


@@ -40,7 +40,7 @@ class BaseUserInfo:
user properties user properties
""" """
return self.property return self.property
def get_stat_info(self, name: str): def get_stat_info(self, name: str):
return self.stat_info.get(name, None) return self.stat_info.get(name, None)


@@ -109,7 +109,7 @@ class BaseMarket:
A flag indicating whether the learnware can be accepted. A flag indicating whether the learnware can be accepted.
""" """
return True return True
def add_learnware( def add_learnware(
self, learnware_name: str, model_path: str, stat_spec_path: str, property: dict, desc: str self, learnware_name: str, model_path: str, stat_spec_path: str, property: dict, desc: str
) -> Tuple[str, bool]: ) -> Tuple[str, bool]:
@@ -203,7 +203,7 @@ class BaseMarket:
------ ------
Exception Exception
Raise an excpetion when given id is NOT found in learnware list Raise an excpetion when given id is NOT found in learnware list
"""
"""
if not id in self.learnware_list: if not id in self.learnware_list:
raise Exception("Learnware id:{} NOT Found!".format(id)) raise Exception("Learnware id:{} NOT Found!".format(id))




Loading…
Cancel
Save