flake8 fixup
This commit is contained in:
		
							parent
							
								
									a94c2cae67
								
							
						
					
					
						commit
						3e4e6eead3
					
				
							
								
								
									
										29
									
								
								.flake8
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								.flake8
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | [flake8] | ||||||
|  | ignore = | ||||||
|  |     # E501 line too long | ||||||
|  |     E501, | ||||||
|  |     # W391 newlines at EOF | ||||||
|  |     W391, | ||||||
|  |     # E241 multiple spaces after comma | ||||||
|  |     E241, | ||||||
|  |     # E302 expected 2 newlines | ||||||
|  |     E302, | ||||||
|  |     # W503 line break before binary operator (to be deprecated) | ||||||
|  |     W503, | ||||||
|  |     # E265 block comment should start with '# ' | ||||||
|  |     E265, | ||||||
|  |     # E123 closing bracket does not match indentation of opening bracket's line | ||||||
|  |     E123, | ||||||
|  |     # E124 closing bracket does not match visual indentation | ||||||
|  |     E124, | ||||||
|  |     # E221 multiple spaces before operator | ||||||
|  |     E221, | ||||||
|  |     # E201 whitespace after '[' | ||||||
|  |     E201, | ||||||
|  |     # E741 ambiguous variable name 'I' | ||||||
|  |     E741, | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | per-file-ignores = | ||||||
|  |     # F401 import without use | ||||||
|  |     */__init__.py: F401, | ||||||
| @ -59,7 +59,7 @@ def draw_polygons( | |||||||
|     for i, polygon in enumerate(polygons): |     for i, polygon in enumerate(polygons): | ||||||
|         malformed = f'Malformed polygon: ({i})' |         malformed = f'Malformed polygon: ({i})' | ||||||
|         if polygon.shape[1] not in (2, 3): |         if polygon.shape[1] not in (2, 3): | ||||||
|                 raise GridError(malformed + 'must be a Nx2 or Nx3 ndarray') |             raise GridError(malformed + 'must be a Nx2 or Nx3 ndarray') | ||||||
|         if polygon.shape[1] == 3: |         if polygon.shape[1] == 3: | ||||||
|             polygon = polygon[surface, :] |             polygon = polygon[surface, :] | ||||||
| 
 | 
 | ||||||
| @ -72,7 +72,7 @@ def draw_polygons( | |||||||
|     # Broadcast foreground where necessary |     # Broadcast foreground where necessary | ||||||
|     foregrounds: Sequence[foreground_callable_t] | Sequence[float] |     foregrounds: Sequence[foreground_callable_t] | Sequence[float] | ||||||
|     if numpy.size(foreground) == 1:     # type: ignore |     if numpy.size(foreground) == 1:     # type: ignore | ||||||
|         foregrounds = [foreground] * len(cell_data) # type: ignore |         foregrounds = [foreground] * len(cell_data)  # type: ignore | ||||||
|     elif isinstance(foreground, numpy.ndarray): |     elif isinstance(foreground, numpy.ndarray): | ||||||
|         raise GridError('ndarray not supported for foreground') |         raise GridError('ndarray not supported for foreground') | ||||||
|     else: |     else: | ||||||
| @ -113,7 +113,7 @@ def draw_polygons( | |||||||
|         foregrounds_i = foregrounds[i] |         foregrounds_i = foregrounds[i] | ||||||
|         if callable(foregrounds_i): |         if callable(foregrounds_i): | ||||||
|             # meshgrid over the (shifted) domain |             # meshgrid over the (shifted) domain | ||||||
|             domain = [self.shifted_xyz(i)[k][bdi_min[k]:bdi_max[k]+1] for k in range(3)] |             domain = [self.shifted_xyz(i)[k][bdi_min[k]:bdi_max[k] + 1] for k in range(3)] | ||||||
|             (x0, y0, z0) = numpy.meshgrid(*domain, indexing='ij') |             (x0, y0, z0) = numpy.meshgrid(*domain, indexing='ij') | ||||||
| 
 | 
 | ||||||
|             # evaluate on the meshgrid |             # evaluate on the meshgrid | ||||||
| @ -319,7 +319,7 @@ def draw_cylinder( | |||||||
|         num_points: The circle is approximated by a polygon with `num_points` vertices |         num_points: The circle is approximated by a polygon with `num_points` vertices | ||||||
|         foreground: Value to draw with ('brush color'). See `draw_polygons()` for details. |         foreground: Value to draw with ('brush color'). See `draw_polygons()` for details. | ||||||
|     """ |     """ | ||||||
|     theta = numpy.linspace(0, 2*numpy.pi, num_points, endpoint=False) |     theta = numpy.linspace(0, 2 * numpy.pi, num_points, endpoint=False) | ||||||
|     x = radius * numpy.sin(theta) |     x = radius * numpy.sin(theta) | ||||||
|     y = radius * numpy.cos(theta) |     y = radius * numpy.cos(theta) | ||||||
|     polygon = numpy.hstack((x[:, None], y[:, None])) |     polygon = numpy.hstack((x[:, None], y[:, None])) | ||||||
| @ -360,8 +360,8 @@ def draw_extrude_rectangle( | |||||||
|     surface = numpy.delete(range(3), direction) |     surface = numpy.delete(range(3), direction) | ||||||
| 
 | 
 | ||||||
|     dim = numpy.fabs(numpy.diff(rectangle, axis=0).T)[surface] |     dim = numpy.fabs(numpy.diff(rectangle, axis=0).T)[surface] | ||||||
|     p = numpy.vstack((numpy.array([-1, -1, 1, 1], dtype=float) * dim[0]/2.0, |     p = numpy.vstack((numpy.array([-1, -1, 1, 1], dtype=float) * dim[0] * 0.5, | ||||||
|                       numpy.array([-1, 1, 1, -1], dtype=float) * dim[1]/2.0)).T |                       numpy.array([-1, 1, 1, -1], dtype=float) * dim[1] * 0.5)).T | ||||||
|     thickness = distance |     thickness = distance | ||||||
| 
 | 
 | ||||||
|     foreground_func = [] |     foreground_func = [] | ||||||
| @ -371,7 +371,7 @@ def draw_extrude_rectangle( | |||||||
|         ind = [int(numpy.floor(z)) if i == direction else slice(None) for i in range(3)] |         ind = [int(numpy.floor(z)) if i == direction else slice(None) for i in range(3)] | ||||||
| 
 | 
 | ||||||
|         fpart = z - numpy.floor(z) |         fpart = z - numpy.floor(z) | ||||||
|         mult = [1-fpart, fpart][::s]  # reverses if s negative |         mult = [1 - fpart, fpart][::s]  # reverses if s negative | ||||||
| 
 | 
 | ||||||
|         foreground = mult[0] * grid[tuple(ind)] |         foreground = mult[0] * grid[tuple(ind)] | ||||||
|         ind[direction] += 1                         # type: ignore #(known safe) |         ind[direction] += 1                         # type: ignore #(known safe) | ||||||
|  | |||||||
| @ -2,7 +2,6 @@ from typing import Callable, Sequence, ClassVar, Self | |||||||
| 
 | 
 | ||||||
| import numpy | import numpy | ||||||
| from numpy.typing import NDArray, ArrayLike | from numpy.typing import NDArray, ArrayLike | ||||||
| from numpy import diff, floor, ceil, zeros, hstack, newaxis |  | ||||||
| 
 | 
 | ||||||
| import pickle | import pickle | ||||||
| import warnings | import warnings | ||||||
|  | |||||||
| @ -99,7 +99,7 @@ def pos2ind( | |||||||
| 
 | 
 | ||||||
|     grid_pos = numpy.zeros((3,)) |     grid_pos = numpy.zeros((3,)) | ||||||
|     for a in range(3): |     for a in range(3): | ||||||
|         xi = numpy.digitize(r[a], sexyz[a]) - 1 # Figure out which cell we're in |         xi = numpy.digitize(r[a], sexyz[a]) - 1  # Figure out which cell we're in | ||||||
|         xi_clipped = numpy.clip(xi, 0, sexyz[a].size - 2)  # Clip back into grid bounds |         xi_clipped = numpy.clip(xi, 0, sexyz[a].size - 2)  # Clip back into grid bounds | ||||||
| 
 | 
 | ||||||
|         # No need to interpolate if round_ind is true or we were outside the grid |         # No need to interpolate if round_ind is true or we were outside the grid | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ Readback and visualization methods for Grid class | |||||||
| from typing import Any, TYPE_CHECKING | from typing import Any, TYPE_CHECKING | ||||||
| 
 | 
 | ||||||
| import numpy | import numpy | ||||||
| from numpy.typing import NDArray, ArrayLike | from numpy.typing import NDArray | ||||||
| 
 | 
 | ||||||
| from . import GridError | from . import GridError | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user