Switch to ruff (#1939)

* `isort` -> `ruff`

* `pylint` -> `ruff`

* Remove line

* More minor cleanup

* Better documentation for rules we are enabling

* Fix gitignore, run black

* vscode settings

---------

Co-authored-by: Matt Tancik <mattt4001@gmail.com>
This commit is contained in:
Brent YiandMatt Tancik authored and GitHub committed 2023-05-17 10:08:14 -07:00
1 parent 814db32ec4
commit d542646c72
79 files changed
+158 -237

No files matched your search

@@ -104,7 +104,6 @@ class TemporalHashMLPDensityField(Field):
},
)
# pylint: disable=arguments-differ
def density_fn(self, positions: Float[Tensor, "*bs 3"], times: Float[Tensor, "bs 1"]) -> Float[Tensor, "*bs 1"]:
"""Returns only the density. Used primarily with the density grid.
@@ -201,7 +201,6 @@ class NerfplayerNGPField(Field):
rgb = self.mlp_head(h).view(*ray_samples.frustums.directions.shape[:-1], -1).to(directions)
return {FieldHeadNames.RGB: rgb}
# pylint: disable=arguments-differ
def density_fn(self, positions: Float[Tensor, "*bs 3"], times: Float[Tensor, "*bs 1"]) -> Float[Tensor, "*bs 1"]:
"""Returns only the density. Used primarily with the density grid.
Overwrite this function since density is time dependent now.
+19 -19
View File
@@ -191,13 +191,13 @@ class SDFField(Field):
dims = [in_dim] + dims + [3]
self.num_layers_color = len(dims)
for l in range(0, self.num_layers_color - 1):
out_dim = dims[l + 1]
lin = nn.Linear(dims[l], out_dim)
for layer in range(0, self.num_layers_color - 1):
out_dim = dims[layer + 1]
lin = nn.Linear(dims[layer], out_dim)
if self.config.weight_norm:
lin = nn.utils.weight_norm(lin)
setattr(self, "clin" + str(l), lin)
setattr(self, "clin" + str(layer), lin)
self.softplus = nn.Softplus(beta=100)
self.relu = nn.ReLU()
@@ -216,27 +216,27 @@ class SDFField(Field):
self.num_layers = len(dims)
self.skip_in = [4]
for l in range(0, self.num_layers - 1):
if l + 1 in self.skip_in:
out_dim = dims[l + 1] - dims[0]
for layer in range(0, self.num_layers - 1):
if layer + 1 in self.skip_in:
out_dim = dims[layer + 1] - dims[0]
else:
out_dim = dims[l + 1]
out_dim = dims[layer + 1]
lin = nn.Linear(dims[l], out_dim)
lin = nn.Linear(dims[layer], out_dim)
if self.config.geometric_init:
if l == self.num_layers - 2:
if layer == self.num_layers - 2:
if not self.config.inside_outside:
torch.nn.init.normal_(lin.weight, mean=np.sqrt(np.pi) / np.sqrt(dims[l]), std=0.0001)
torch.nn.init.normal_(lin.weight, mean=np.sqrt(np.pi) / np.sqrt(dims[layer]), std=0.0001)
torch.nn.init.constant_(lin.bias, -self.config.bias)
else:
torch.nn.init.normal_(lin.weight, mean=-np.sqrt(np.pi) / np.sqrt(dims[l]), std=0.0001)
torch.nn.init.normal_(lin.weight, mean=-np.sqrt(np.pi) / np.sqrt(dims[layer]), std=0.0001)
torch.nn.init.constant_(lin.bias, self.config.bias)
elif l == 0:
elif layer == 0:
torch.nn.init.constant_(lin.bias, 0.0)
torch.nn.init.constant_(lin.weight[:, 3:], 0.0)
torch.nn.init.normal_(lin.weight[:, :3], 0.0, np.sqrt(2) / np.sqrt(out_dim))
elif l in self.skip_in:
elif layer in self.skip_in:
torch.nn.init.constant_(lin.bias, 0.0)
torch.nn.init.normal_(lin.weight, 0.0, np.sqrt(2) / np.sqrt(out_dim))
torch.nn.init.constant_(lin.weight[:, -(dims[0] - 3) :], 0.0)
@@ -246,7 +246,7 @@ class SDFField(Field):
if self.config.weight_norm:
lin = nn.utils.weight_norm(lin)
setattr(self, "glin" + str(l), lin)
setattr(self, "glin" + str(layer), lin)
def set_cos_anneal_ratio(self, anneal: float) -> None:
"""Set the anneal value for the proposal network."""
@@ -269,15 +269,15 @@ class SDFField(Field):
# Pass through layers
outputs = inputs
for l in range(0, self.num_layers - 1):
lin = getattr(self, "glin" + str(l))
for layer in range(0, self.num_layers - 1):
lin = getattr(self, "glin" + str(layer))
if l in self.skip_in:
if layer in self.skip_in:
outputs = torch.cat([outputs, inputs], 1) / np.sqrt(2)
outputs = lin(outputs)
if l < self.num_layers - 2:
if layer < self.num_layers - 2:
outputs = self.softplus(outputs)
return outputs