Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dynamic): Add simplified option #123

Merged
merged 1 commit into from
Jul 18, 2023
Merged
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
11 changes: 7 additions & 4 deletions honeybee_radiance_postprocess/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,17 @@ def filter_by_identifiers(self, identifiers):
filter_dyn_sch.add_aperture_group_schedule(group)
return filter_dyn_sch

def to_dict(self):
def to_dict(self, simplified=False):
"""Return DynamicSchedule as a dictionary."""
base = {}
for identifier, group in self.dynamic_schedule.items():
base[identifier] = group.to_dict()
if not simplified:
base[identifier] = group.to_dict()
else:
base[identifier] = group.to_dict()['schedule']
return base

def to_json(self, folder=None, file_name=None, indent=None):
def to_json(self, folder=None, file_name=None, indent=None, simplified=False):
"""Write a DynamicSchedule to JSON.

Args:
Expand All @@ -213,7 +216,7 @@ def to_json(self, folder=None, file_name=None, indent=None):
json_file: Path to JSON file.
"""
# create dictionary of the DynamicSchedule
dyn_sch_dict = self.to_dict()
dyn_sch_dict = self.to_dict(simplified=simplified)

# set up name and folder for the JSON
file_name = file_name if file_name else 'dynamic_schedule'
Expand Down
Loading