Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions PySDM/products/impl/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class Product:
def __init__(self, *, unit: str, name: Optional[str] = None):
self.non_default_name = name is not None
self.name = name or camel_case_to_words(self.__class__.__name__)

self._unit = self._parse_unit(unit)
Expand Down Expand Up @@ -87,6 +88,12 @@ def __check_unit(self):
f" for product {type(self).__name__}"
)

if self._unit != default_unit and not self.non_default_name:
raise AssertionError(
f"custom non-SI unit specified for product {type(self).__name__}"
" requires a custom name (intention: include the custom unit in the name)"
)

@property
def unit(self):
return str(self._unit)
Expand Down
Loading