Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishavlin committed Dec 9, 2024
1 parent 2c2f744 commit db21fa6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
39 changes: 21 additions & 18 deletions yt_idv/scene_components/base_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SceneComponent(traitlets.HasTraits):
_program1_invalid = True
_program2_invalid = True
_cmap_bounds_invalid = True
_data_geometry = traitlets.Unicode(default_value='cartesian')
_data_geometry = traitlets.Unicode(default_value="cartesian")

display_name = traitlets.Unicode(allow_none=True)

Expand All @@ -83,29 +83,32 @@ class SceneComponent(traitlets.HasTraits):
active = traitlets.Bool(True)

@traitlets.observe("_data_geometry")
def _update_geometry_pp_directives(self, change):
if change['new'] == 'spherical' and change['old'] == 'cartesian':
# this should only happen once on initial data load, so only handling the
# change from the default value.
current_shader = component_shaders[self.name][self.render_method]
with self.hold_trait_notifications():
for shd in ('vertex', 'geometry', 'fragment'):
# update the preprocessor directive state for this shader
self._program1_pp_defs.add_definition(shd, ("SPHERICAL_GEOM", ""))
pp_defs = self._program1_pp_defs[shd]

# update shader attributes of self
new_shader_tuple = (current_shader[f"first_{shd}"], pp_defs)
def _update_geometry_pp_directives(self, change):
if change["new"] == "spherical" and change["old"] == "cartesian":
# this should only happen once on initial data load, so only handling the
# change from the default value.
current_shader = component_shaders[self.name][self.render_method]
with self.hold_trait_notifications():
for shd in ("vertex", "geometry", "fragment"):
# update the preprocessor directive state for this shader
self._program1_pp_defs.add_definition(shd, ("SPHERICAL_GEOM", ""))
pp_defs = self._program1_pp_defs[shd]

# update shader attributes of self
new_shader_tuple = (current_shader[f"first_{shd}"], pp_defs)
setattr(self, f"{shd}_shader", new_shader_tuple)

# all of the above shader attribute changes will trigger further
# traitlet changes that cause _recompile_shader to run
self._data_geometry = change['new']
# traitlet changes that cause _recompile_shader to run

self._data_geometry = change["new"]

@traitlets.observe("data")
def _update_geometry(self, change):
if hasattr(change["new"], '_yt_geom_str') and change["new"]._yt_geom_str == 'spherical':
if (
hasattr(change["new"], "_yt_geom_str")
and change["new"]._yt_geom_str == "spherical"
):
self._data_geometry = change["new"]._yt_geom_str

@traitlets.observe("display_bounds")
Expand Down
2 changes: 1 addition & 1 deletion yt_idv/scene_components/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def draw(self, scene, program):
with bitmap_tex.bind(target=1):
GL.glDrawArrays(GL.GL_POINTS, tex_ind * each, each)

def _set_uniforms(self, scene, shader_program):
def _set_uniforms(self, scene, shader_program):
if self.data._yt_geom_str == "spherical":
axis_id = self.data.data_source.ds.coordinates.axis_id
shader_program._set_uniform("id_theta", axis_id["theta"])
Expand Down
7 changes: 3 additions & 4 deletions yt_idv/scene_data/block_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BlockCollection(SceneData):
scale = traitlets.Bool(False)
blocks_by_grid = traitlets.Instance(defaultdict, (list,))
grids_by_block = traitlets.Dict(default_value=())
_yt_geom_str = traitlets.Unicode('cartesian')
_yt_geom_str = traitlets.Unicode("cartesian")

@traitlets.default("vertex_array")
def _default_vertex_array(self):
Expand All @@ -44,8 +44,7 @@ def add_data(self, field, no_ghost=False):
# note: casting to string for compatibility with new and old geometry
# attributes (now an enum member in latest yt),
# see https://github.com/yt-project/yt/pull/4244



# Every time we change our data source, we wipe all existing ones.
# We now set up our vertices into our current data source.
vert, dx, le, re = [], [], [], []
Expand Down Expand Up @@ -114,7 +113,7 @@ def add_data(self, field, no_ghost=False):
)

# Now we set up our textures
self._load_textures()
self._load_textures()

def _set_geometry_attributes(self, le, re):
# set any vertex_array attributes that depend on the yt geometry type
Expand Down
2 changes: 1 addition & 1 deletion yt_idv/shaders/grid_expand.geom.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void main() {
left_edge_cart = vleft_edge_cart[0];
right_edge_cart = vright_edge_cart[0];
#endif

dx = vdx[0];
v_model = newPos;
texture_offset = ivec3(0);
Expand Down
1 change: 0 additions & 1 deletion yt_idv/shaders/known_uniforms.inc.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ uniform float cart_bbox_max_width;
// draw outline control
uniform float draw_boundary;
uniform vec4 boundary_color;

2 changes: 1 addition & 1 deletion yt_idv/shaders/ray_tracing.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void main()
while(t <= t1) {

// texture position
#ifdef SPHERICAL_GEOM
#ifdef SPHERICAL_GEOM
ray_position_native = cart_to_sphere_vec3(ray_position);
within_el = within_bb(ray_position_native);
#else
Expand Down

0 comments on commit db21fa6

Please sign in to comment.