Repository: scipy/scipy

Issue:
Chebyshev weights
It seems that the chebyshev distance weights are not used in the calculation, or i am doing something wrong but looking at the following source code, i think there is an omission
```
def chebyshev(u, v, w=None):
    u = _validate_vector(u)
    v = _validate_vector(v)
    if w is not None:
        w = _validate_weights(w)
        has_weight = w > 0
        if has_weight.sum() < w.size:
            u = u[has_weight]
            v = v[has_weight]
    return max(abs(u - v))
```
for example:
```
from scipy.spatial import distance
distance.chebyshev([10, 0, 0], [0, 1, 0], w=np.array([1,20,1]))
10
```
i was expecting it to return 20


Discussion:
I haven't managed to find a formula online that even uses weights for the Chebyshev Distance - does it need to be weighted? They all just indicate that it's max(abs(u - v))
the formula is the same just with weights: `max(weigths * abs(u-v))`
Do you have a source? I can't find a weighted formula in any textbooks. Or is there a "Weighted Chebyshev Distance"? 
i do not have any source but it is the same idea than any other weighted distance:
exemple: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.sqeuclidean.html#scipy.spatial.distance.sqeuclidean

why is there a weight argument otherwise??

look at the documentation:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.chebyshev.html#scipy.spatial.distance.chebyshev
That definitely makes sense and it doesn't seem like it's weighting anything - I can attempt a fix for this.
@bensdm 

Does this look more correct? 

```python 
def chebyshev(u, v, w=None):
    u = _validate_vector(u)
    v = _validate_vector(v)
    l1_diff = abs(u-v)
    if w is not None:
        w = _validate_weights(w)
        l1_diff = w * l1_diff
    return max(l1_diff)

a = np.array([10,0,0])
b = np.array([0,1,0]) 
w = np.array([1,20,1]) 

chebyshev(a, b, w)
> 20.0
Yes sounds good, not sure why there was a `has_weight` variable since if the weight is <0 it will not be the max 
I think the discussion here is a little misguided, and the code is correct. The docstring is misleading though, the description for `w` should read:
```
Unused, as 'max' is a weightless operation. Here for API consistency.
```
This is what the original PR for weighted distance functions (gh-6931) said.

Looking at other distance functions, what the weights are doing is taking a _weighted average_. So `w.sum()` is in the denominator of the answer. Clearly for `max()` that doesn't make sense, hence the current implementation - the only thing it's doing is taking away elements with weight zero.


Resolving patch:
diff --git a/scipy/spatial/distance.py b/scipy/spatial/distance.py
--- a/scipy/spatial/distance.py
+++ b/scipy/spatial/distance.py
@@ -1096,8 +1096,7 @@ def chebyshev(u, v, w=None):
     v : (N,) array_like
         Input vector.
     w : (N,) array_like, optional
-        The weights for each value in `u` and `v`. Default is None,
-        which gives each value a weight of 1.0
+        Unused, as 'max' is a weightless operation. Here for API consistency.
 
     Returns
     -------


Test patch: