Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address most lint issues #103

Merged
merged 7 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This document highlights high-level changes made to this program.
+ Formatted code with `black`.
+ Removed `__future__` imports now that we no longer support Python 2; reorder
and fix imports to not use `.` notation. Removed encoding pragma.
+ Addressed some lint issues; removed Py2 `xrange` hack.


## 1.1.2 / 2019-10-14
Expand Down
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,31 @@ The easiest way to use this to to:

0. Import the `wm_app` module:

```python
```pycon
>>> import wm_app
```

1. Set up your data as a list of (grid_x, grid_y, value) tuples:

```python
>>> data = [(grid_x_1, grid_y_1, data_1), # 1st die
... (grid_x_2, grid_y_2, data_2), # 2nd die
... (grid_x_3, grid_y_3, data_3) # 3rd die and so on
... ]
```pycon
>>> data = [
... (grid_x_1, grid_y_1, data_1), # 1st die
... (grid_x_2, grid_y_2, data_2), # 2nd die
... (grid_x_3, grid_y_3, data_3), # 3rd die and so on
... ]
```

2. Call `wm_app.WaferMapApp`.

```python
>>> wm_app.WaferMapApp(data,
... die_size,
... center_xy,
... dia,
... edge_excl,
... flat_excl)
```pycon
>>> wm_app.WaferMapApp(
... data,
... die_size,
... center_xy,
... dia,
... edge_excl,
... flat_excl,
... )
```

The input parameters for WaferMapApp are:
Expand Down
9 changes: 0 additions & 9 deletions src/wafer_map/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@
Determines the python version and monkeypatches wx.Colour.
"""
import os
import sys


### Constants ###############################################################
# __all__ = ['wm_app', 'wm_constants', 'wm_core', 'wm_frame', 'wm_info',
# 'wm_legend', 'wm_utils']


if sys.version_info < (3,):
PY2 = True
elif sys.version_info < (2, 6):
raise RuntimeError("Only Python >= 2.7 is supported.")
else:
PY2 = False


# if we're building docs, don't try and import or monkeypatch wxPython.
if os.getenv("READTHEDOCS", "False") == "True":
pass
Expand Down
6 changes: 0 additions & 6 deletions src/wafer_map/gen_fake_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@
import math
import random

from wafer_map import PY2
from wafer_map import wm_constants as wm_const
from wafer_map import wm_info
from wafer_map import wm_utils


# Python2 Compatibility
if PY2:
range = xrange


def generate_fake_data(**kwargs):
"""
Generate fake data for wafer_map.
Expand Down
2 changes: 1 addition & 1 deletion src/wafer_map/wm_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def draw_die_gridlines(wf):
line_coords = list([(x, -edge), (x, edge)] for x in x_values)
line_coords.extend([(-edge, y), (edge, y)] for y in y_values)

lines = [FloatCanvas.Line(l, LineColor=grey) for l in line_coords]
lines = [FloatCanvas.Line(_line, LineColor=grey) for _line in line_coords]

return FloatCanvas.Group(list(lines))

Expand Down
5 changes: 0 additions & 5 deletions src/wafer_map/wm_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@
import wx.lib.colourselect as csel
from wx.lib.floatcanvas import FloatCanvas

from wafer_map import PY2
from wafer_map import wm_constants as wm_const
from wafer_map import wm_utils

# TODO: Update to Bezier Curves for colors. See http://bsou.io/p/3

# Python2 Compatibility
if PY2:
range = xrange


class Legend(object):
"""
Expand Down
29 changes: 11 additions & 18 deletions src/wafer_map/wm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
import numpy as np
from colour import Color

from wafer_map import PY2


# Python2 Compatibility
if PY2:
range = xrange


class Gradient(object):
"""
Expand Down Expand Up @@ -196,12 +189,12 @@ def linear_gradient(initial_color, dest_color, value):
h2, s2, l2 = c2.hsl

# Perform the linear interpolation
h = rescale(value, (0, 1), (h1, h2))
s = rescale(value, (0, 1), (s1, s2))
l = rescale(value, (0, 1), (l1, l2))
hue = rescale(value, (0, 1), (h1, h2))
saturation = rescale(value, (0, 1), (s1, s2))
lightness = rescale(value, (0, 1), (l1, l2))

# Convert back to 0-255 for wxPython
r, g, b = (int(_c * 255) for _c in Color(hsl=(h, s, l)).rgb)
r, g, b = (int(_c * 255) for _c in Color(hsl=(hue, saturation, lightness)).rgb)

return (r, g, b)

Expand All @@ -215,8 +208,8 @@ def polylinear_gradient(colors, value):
Value is the 0-1 value between colors[0] and colors[-1].
Assumes uniform spacing between all colors.
"""
n = len(colors)
if n == 2:
num_colors = len(colors)
if num_colors == 2:
return linear_gradient(colors[0], colors[1], value)

if value >= 1:
Expand All @@ -225,18 +218,18 @@ def polylinear_gradient(colors, value):
return colors[0]

# divide up our range into n - 1 segments, where n is the number of colors
l = 1 / (n - 1) # float division
segment_size = 1 / (num_colors - 1) # float division

# figure out which segment we're in - determines start and end colors
m = int(value // l) # Note floor division
segment = int(value // segment_size) # Note floor division

low = m * l
high = (m + 1) * l
low = segment * segment_size
high = (segment + 1) * segment_size

# calculate where our value lies within that particular gradient
v2 = rescale(value, (low, high), (0, 1))

return linear_gradient(colors[m], colors[m + 1], v2)
return linear_gradient(colors[segment], colors[segment + 1], v2)


def beizer_gradient(initial_color, arc_color, dest_color, value):
Expand Down
Loading