Skip to content

Commit

Permalink
Codestyle fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Jul 20, 2024
1 parent 9d6eb46 commit 8bb7b8d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
24 changes: 12 additions & 12 deletions glue_wwt/viewer/jupyter_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,22 @@ def __init__(self, viewer_state, available_layers):
self.widget_constellation_boundaries = LinkedDropdown(self.state, 'constellation_boundaries',
label="Boundaries:")
self.widget_constellation_boundary_color = linked_color_picker(self.state, 'constellation_boundary_color',

Check warning on line 92 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L92

Added line #L92 was not covered by tests
description="Boundary")
description="Boundary")
dlink((self.widget_constellation_boundaries, 'value'), (self.widget_constellation_boundary_color, 'disabled'),
lambda value: value != "All")
self.widget_constellation_selection_color = linked_color_picker(self.state, 'constellation_selection_color',

Check warning on line 96 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L96

Added line #L96 was not covered by tests
description="Selection")
description="Selection")
dlink((self.widget_constellation_boundaries, 'value'), (self.widget_constellation_selection_color, 'disabled'),
lambda value: value == "None")

self.widget_constellation_figures = linked_checkbox(self.state, 'constellation_figures', description="Figures")
self.widget_constellation_figure_color = linked_color_picker(self.state, 'constellation_figure_color',

Check warning on line 102 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L101-L102

Added lines #L101 - L102 were not covered by tests
description="Figure")
description="Figure")
set_enabled_from_checkbox(self.widget_constellation_figure_color, self.widget_constellation_figures)
self.widget_constellation_labels = linked_checkbox(self.state, 'constellation_labels', description="Labels")
self.widget_constellation_pictures = linked_checkbox(self.state, 'constellation_pictures', description="Pictures")
self.widget_constellation_labels = linked_checkbox(self.state, 'constellation_labels',

Check warning on line 105 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L104-L105

Added lines #L104 - L105 were not covered by tests
description="Labels")
self.widget_constellation_pictures = linked_checkbox(self.state, 'constellation_pictures',

Check warning on line 107 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L107

Added line #L107 was not covered by tests
description="Pictures")

constellations_hbox_layout = Layout(gap="10px", justify_content="space-between")
constellations_vbox_layout = Layout(height="fit-content", gap="2px", padding="5px", flex_direction="column")
Expand Down Expand Up @@ -150,26 +152,24 @@ def __init__(self, viewer_state, available_layers):
self.widget_min_time = NaiveDatetimePicker(description="Min Time:")
link((self.state, 'min_time'), (self.widget_min_time, 'value'),

Check warning on line 153 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L152-L153

Added lines #L152 - L153 were not covered by tests
lambda time: self._datetime64_to_utc_datetime(time),
lambda value: datetime64(value)
)
lambda value: datetime64(value))
self.widget_max_time = NaiveDatetimePicker(description="Max Time:")
link((self.state, 'max_time'), (self.widget_max_time, 'value'),

Check warning on line 157 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L156-L157

Added lines #L156 - L157 were not covered by tests
lambda time: self._datetime64_to_utc_datetime(time),
lambda value: datetime64(value)
)
lambda value: datetime64(value))

self.other_settings = VBox(children=[

Check warning on line 161 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L161

Added line #L161 was not covered by tests
GridBox(children=[self.widget_ecliptic_label, self.widget_ecliptic,
self.widget_ecliptic_color, self.widget_precession_chart_label,
self.widget_precession_chart, self.widget_precession_chart_color],
self.widget_precession_chart,
self.widget_precession_chart_color],
layout=Layout(grid_template_columns="60% 20% 20%", width="100%",
grid_gap="2px 10px")),
VBox(children=[self.widget_play_time, self.widget_clock_rate,
self.widget_current_time_label, self.widget_current_time,
self.widget_min_time, self.widget_max_time])
])


self.settings = Accordion(children=[self.general_settings, self.grid_settings,
self.constellation_settings, self.other_settings],
layout=Layout(width="350px"))
Expand Down Expand Up @@ -232,7 +232,7 @@ def __init__(self, layer_state):
self.state = layer_state
self.color_widgets = Color(state=self.state)
self.size_widgets = Size(state=self.state)

self.widget_time_series = linked_checkbox(self.state, 'time_series', description="Time series")
self.widget_time_att = LinkedDropdown(self.state, 'time_att', 'Time att')
self.widget_time_decay_value = linked_float_text(self.state, 'time_decay_value',

Check warning on line 238 in glue_wwt/viewer/jupyter_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/jupyter_viewer.py#L236-L238

Added lines #L236 - L238 were not covered by tests
Expand Down
17 changes: 9 additions & 8 deletions glue_wwt/viewer/options_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def _setup_widget_dependencies(self):
set_enabled_from_checkbox(self.ui.color_precession_chart_color, self.ui.bool_precession_chart)

enabled_if_combosel_in(self.ui.color_constellation_boundary_color,
self.ui.combosel_constellation_boundaries,
['All'])
self.ui.combosel_constellation_boundaries,
['All'])
enabled_if_combosel_in(self.ui.color_constellation_selection_color,
self.ui.combosel_constellation_boundaries,
['All', 'Selection only'])
self.ui.combosel_constellation_boundaries,
['All', 'Selection only'])

def _update_visible_options(self, *args, **kwargs):

Expand Down Expand Up @@ -96,7 +96,8 @@ def _update_visible_options(self, *args, **kwargs):
self.ui.label_lat_att.setText('Latitude')

def _update_slider_fraction(self, *args):
fraction = (self._viewer_state.current_time - self._viewer_state.min_time) / (self._viewer_state.max_time - self._viewer_state.min_time)
fraction = (self._viewer_state.current_time - self._viewer_state.min_time) / \
(self._viewer_state.max_time - self._viewer_state.min_time)
slider_min = self.ui.slider_current_time.minimum()
slider_max = self.ui.slider_current_time.maximum()
value = round(slider_min + fraction * (slider_max - slider_min))
Expand All @@ -107,7 +108,7 @@ def _on_current_time_update(self, time):
self._update_slider_fraction()
try:
self.ui.label_current_time.setText(f"Current Time: {time.astype('datetime64[ms]')}")
except:
except Exception:
pass

Check warning on line 112 in glue_wwt/viewer/options_widget.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/options_widget.py#L111-L112

Added lines #L111 - L112 were not covered by tests

def _on_slider_changed(self, *args):
Expand All @@ -118,7 +119,8 @@ def _on_slider_changed(self, *args):
slider_min = self.ui.slider_current_time.minimum()
slider_max = self.ui.slider_current_time.maximum()
fraction = (value - slider_min) / (slider_max - slider_min)
self._viewer_state.current_time = self._viewer_state.min_time + fraction * (self._viewer_state.max_time - self._viewer_state.min_time)
self._viewer_state.current_time = self._viewer_state.min_time + \

Check warning on line 122 in glue_wwt/viewer/options_widget.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/options_widget.py#L118-L122

Added lines #L118 - L122 were not covered by tests
fraction * (self._viewer_state.max_time - self._viewer_state.min_time)

def _update_time_bounds(self, *args):
min_time = self._viewer_state.min_time
Expand All @@ -130,4 +132,3 @@ def _update_time_bounds(self, *args):

self._viewer_state.min_time = min_time
self._viewer_state.max_time = max_time

6 changes: 4 additions & 2 deletions glue_wwt/viewer/table_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ def _update_presentation(self, force=False, **kwargs):

if self.state.time_series and self.state.time_att is not None:
try:

Check warning on line 253 in glue_wwt/viewer/table_layer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/table_layer.py#L253

Added line #L253 was not covered by tests
# Providing datetime objects as the time values offers noticeably better performance than either datetime strings or astropy Time objects
# Providing datetime objects as the time values offers noticeably better performance
# than either datetime strings or astropy Time objects.
# This is likely due to the time attribute value validation in pywwt
time_values = [datetime.fromisoformat(datetime_as_string(t, unit='s', timezone='UTC')) for t in self.layer[self.state.time_att]]
time_values = [datetime.fromisoformat(datetime_as_string(t, unit='s', timezone='UTC'))

Check warning on line 257 in glue_wwt/viewer/table_layer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/table_layer.py#L257

Added line #L257 was not covered by tests
for t in self.layer[self.state.time_att]]
except IncompatibleAttribute:
self.disable_invalid_attributes(self.state.time_att)
return

Check warning on line 261 in glue_wwt/viewer/table_layer.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/table_layer.py#L259-L261

Added lines #L259 - L261 were not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion glue_wwt/viewer/time_dialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from datetime import datetime
from datetime import datetime

Check warning on line 2 in glue_wwt/viewer/time_dialog.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/time_dialog.py#L1-L2

Added lines #L1 - L2 were not covered by tests

from qtpy.QtCore import QDate, QTime
from qtpy.QtWidgets import QDialog

Check warning on line 5 in glue_wwt/viewer/time_dialog.py

View check run for this annotation

Codecov / codecov/patch

glue_wwt/viewer/time_dialog.py#L4-L5

Added lines #L4 - L5 were not covered by tests
Expand Down
1 change: 0 additions & 1 deletion glue_wwt/viewer/viewer_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,3 @@ def _on_current_time_update(self, time):
elif time > self.max_time:
self.current_time = self.max_time
self.play_time = False

0 comments on commit 8bb7b8d

Please sign in to comment.