-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(radiance.properties): Add Radiance Properties Schema. (#76)
* feat(radiance): Adding initial radiance schema materials. * feat(radiance): Add more materials, and ModifierBase. For WIP discussion only. Not to be merged. * docs(radiance): Clarifying recursion error. * fix(radiance.material): Fix self-ref, and other PR changes. * feat(radiance.properties): Add Radiance Properties Schema. * feat(modfiersset): Add Radiance.ModifiersSet object. * feat(radiance): Change material.py to modfier.py, add subclass. * fix(radiance): Fix based on latest PR comments. Add IDdRadianceBaseModel, abridged and non-abridged versions for all ModifierSet objects,, Properties inheritiance changed. * feat(tests): modifier, modifierset changes and modifier tests. * tests(Radiance): Tests for Radiance and PR update. * fix(Radiance): Add Optionals to schema types with None as default. * fix(Radiance): fix RoomRadianceProperties. * fix(Modifier): Make modifers arg nullable. Change to make modifiers consistent with jsons. * docs(Modifier): Change Void to None in modifierbase modifier default. Based on recent discussions re: Void. * fix(Optional): Remove Optional for all fields with None as default.
- Loading branch information
Showing
8 changed files
with
597 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Base class used by radiance schema objects.""" | ||
from pydantic import Field, validator, BaseModel | ||
import re | ||
from .._base import NoExtraBaseModel | ||
|
||
|
||
class IDdRadianceBaseModel(NoExtraBaseModel): | ||
"""Base class for all objects requiring a valid Radiance identifier.""" | ||
|
||
identifier: str = Field( | ||
..., | ||
description='Text string for a unique Radiance object. Must not contain spaces ' | ||
'or special characters. This will be used to identify the object ' | ||
'across a model and in the exported Radiance files.' | ||
) | ||
|
||
@validator('identifier') | ||
def valid_rad_string(cls, value): | ||
"""Check that a string is valid for Radiance. | ||
This method is modified from the honeybee-core.typing.valid_rad_string method. | ||
""" | ||
try: | ||
illegal_match = re.search(r'[^.A-Za-z0-9_-]', value) | ||
except TypeError: | ||
raise TypeError('Identifier must be a text string. Got {}: {}.'.format( | ||
type(value), value)) | ||
assert illegal_match is None, \ | ||
'Illegal character "{}" found in identifier'.format(illegal_match.group(0)) | ||
assert len(value) > 0, \ | ||
'Input identifier "{}" contains no characters.'.format(value) | ||
return value | ||
|
||
display_name: str = Field( | ||
default=None, | ||
description='Display name of the object with no character restrictions.' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.