Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 9, 2023
1 parent d705712 commit 322567b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
3 changes: 0 additions & 3 deletions graph_weather/models/graphs/ico.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ def generate_icosphere_mapping(lat_lons, resolutions=(1, 2, 4, 8, 16), bidirecti
generate_icosphere_mapping([(0, 0), (0, 1), (1, 0), (1, 1)])





def generate_latent_ico_graph(h3_mapping, h3_distances):
"""
Generate latent h3 graph.
Expand Down
14 changes: 5 additions & 9 deletions graph_weather/models/graphs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ def add_node_features(graph: Data, pos: Tensor) -> Data:
return graph


def generate_grid_to_mesh(lat_lons: torch.Tensor, mesh: Data, max_edge_length: Optional[float] = None) -> HeteroData:
def generate_grid_to_mesh(
lat_lons: torch.Tensor, mesh: Data, max_edge_length: Optional[float] = None
) -> HeteroData:
if max_edge_length is None:
max_edge_len = np.max(
get_edge_len(mesh.pos[mesh.edge_index[:, 0]], mesh.pos[mesh.edge_index[:, 1]])
Expand Down Expand Up @@ -359,17 +361,11 @@ def generate_mesh_to_grid(lat_lons: torch.Tensor, mesh: Data):
# create the mesh2grid bipartite graph
cartesian_grid = latlon2xyz(lat_lons)
n_nbrs = 1
neighbors = NearestNeighbors(n_neighbors=n_nbrs).fit(
mesh.pos
)
neighbors = NearestNeighbors(n_neighbors=n_nbrs).fit(mesh.pos)
_, indices = neighbors.kneighbors(cartesian_grid)
indices = indices.flatten()

src = [
p
for i in indices
for p in mesh.pos[i]
]
src = [p for i in indices for p in mesh.pos[i]]
dst = [i for i in range(len(cartesian_grid)) for _ in range(3)]

mesh2grid = HeteroData()
Expand Down

0 comments on commit 322567b

Please sign in to comment.