Skip to content

Commit

Permalink
Revert "Bottlechest, bottleneck"
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazZupan authored Jul 4, 2016
1 parent fa9b426 commit a326d23
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 217 deletions.
4 changes: 0 additions & 4 deletions Orange/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from .misc.lazy_module import _LazyModule
from .misc.datasets import _DatasetInfo

# bottlechest patches bottleneck
from .misc import bottlechest # pylint: disable=unused-import

from .version import \
short_version as __version__, git_revision as __git_version__

Expand Down
8 changes: 5 additions & 3 deletions Orange/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import numpy as np
import scipy
import bottlechest as bn

from Orange.data import Table, Storage, Instance, Value
from Orange.preprocess import (RemoveNaNClasses, Continuize,
RemoveNaNColumns, SklImpute)
from Orange.misc.wrapper_meta import WrapperMeta
from Orange.util import one_hot

__all__ = ["Learner", "Model", "SklLearner", "SklModel"]

Expand Down Expand Up @@ -157,9 +157,11 @@ def __call__(self, data, ret=Value):
for c in self.domain.class_vars)
probs = np.zeros(value.shape + (max_card,), float)
for i, cvar in enumerate(self.domain.class_vars):
probs[:, i, :] = one_hot(value[:, i])
probs[:, i, :], _ = bn.bincount(np.atleast_2d(value[:, i]),
max_card - 1)
else:
probs = one_hot(value)
probs, _ = bn.bincount(np.atleast_2d(value),
len(self.domain.class_var.values) - 1)
if ret == Model.ValueProbs:
return value, probs
else:
Expand Down
2 changes: 1 addition & 1 deletion Orange/data/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from ..misc.enum import Enum
import numpy as np
import bottleneck as bn
import bottlechest as bn
from Orange.data import Instance, Storage, Variable


Expand Down
2 changes: 1 addition & 1 deletion Orange/data/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from urllib.parse import urlparse, unquote as urlunquote
from urllib.request import urlopen

import bottleneck as bn
import bottlechest as bn
import numpy as np
from chardet.universaldetector import UniversalDetector

Expand Down
9 changes: 7 additions & 2 deletions Orange/data/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from urllib.request import urlopen
from urllib.error import URLError

import bottleneck as bn
import bottlechest as bn
from scipy import sparse as sp

from .instance import *
Expand Down Expand Up @@ -935,7 +935,12 @@ def __determine_density(data):
if data is None:
return Storage.Missing
if data is not None and sp.issparse(data):
return Storage.SPARSE_BOOL if (data.data == 1).all() else Storage.SPARSE
try:
if bn.bincount(data.data, 1)[0][0] == 0:
return Storage.SPARSE_BOOL
except ValueError as e:
pass
return Storage.SPARSE
else:
return Storage.DENSE

Expand Down
179 changes: 0 additions & 179 deletions Orange/misc/bottlechest.py

This file was deleted.

6 changes: 3 additions & 3 deletions Orange/preprocess/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import numpy as np
import sklearn.preprocessing as skl_preprocessing
import bottleneck as bn
import bottlechest

import Orange.data
from Orange.data import Table
Expand Down Expand Up @@ -198,8 +198,8 @@ def __call__(self, data):
data : an input data set
"""

oks = bn.nanmin(data.X, axis=0) != \
bn.nanmax(data.X, axis=0)
oks = bottlechest.nanmin(data.X, axis=0) != \
bottlechest.nanmax(data.X, axis=0)
atts = [data.domain.attributes[i] for i, ok in enumerate(oks) if ok]
domain = Orange.data.Domain(atts, data.domain.class_vars,
data.domain.metas)
Expand Down
8 changes: 4 additions & 4 deletions Orange/tests/test_contingency.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _construct_sparse():
def test_sparse(self):
d = self._construct_sparse()
cont = contingency.Discrete(d, 5)
np.testing.assert_almost_equal(cont[0], [2, 0, 0])
np.testing.assert_almost_equal(cont[0], [1, 0, 0])
np.testing.assert_almost_equal(cont["b"], [0, 1, 1])
np.testing.assert_almost_equal(cont[2], [1, 0, 0])

Expand Down Expand Up @@ -193,7 +193,7 @@ def test_get_contingency(self):
d = self._construct_sparse()
cont = contingency.get_contingency(d, 5)
self.assertIsInstance(cont, contingency.Discrete)
np.testing.assert_almost_equal(cont[0], [2, 0, 0])
np.testing.assert_almost_equal(cont[0], [1, 0, 0])
np.testing.assert_almost_equal(cont["b"], [0, 1, 1])
np.testing.assert_almost_equal(cont[2], [1, 0, 0])

Expand All @@ -218,7 +218,7 @@ def test_get_contingencies(self):

cont = conts[5]
self.assertIsInstance(cont, contingency.Discrete)
np.testing.assert_almost_equal(cont[0], [2, 0, 0])
np.testing.assert_almost_equal(cont[0], [1, 0, 0])
np.testing.assert_almost_equal(cont["b"], [0, 1, 1])
np.testing.assert_almost_equal(cont[2], [1, 0, 0])

Expand All @@ -240,7 +240,7 @@ def test_get_contingencies(self):
self.assertEqual(len(conts), 10)
cont = conts[5]
self.assertIsInstance(cont, contingency.Discrete)
np.testing.assert_almost_equal(cont[0], [2, 0, 0])
np.testing.assert_almost_equal(cont[0], [1, 0, 0])
np.testing.assert_almost_equal(cont["b"], [0, 1, 1])
np.testing.assert_almost_equal(cont[2], [1, 0, 0])

Expand Down
16 changes: 0 additions & 16 deletions Orange/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,6 @@ def scale(values, min=0, max=1):
return (-np.nanmin(values) + values) / ptp * (max - min) + min


def one_hot(values, dtype=float):
"""Return a one-hot transform of values
Parameters
----------
values : 1d array
Integer values (hopefully 0-max).
Returns
-------
result
2d array with ones in respective indicator columns.
"""
return np.eye(np.max(values) + 1, dtype=dtype)[np.asanyarray(values, dtype=int)]


class Registry(type):
"""Metaclass that registers subtypes."""
def __new__(cls, name, bases, attrs):
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/classify/tests/test_owlogisticregression.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

import bottleneck as bn
import bottlechest as bn

from Orange.data import Table
from Orange.classification import LogisticRegressionLearner
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ coverage:
status:
patch:
default:
target: '90'
target: '95'
project:
default:
target: auto
Expand Down
2 changes: 1 addition & 1 deletion requirements-core.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy>=1.9.0
scipy>=0.11.0
scikit-learn>=0.17
bottleneck>=1.0.0
bottlechest>=0.7.1
# Reading Excel files
xlrd>=0.9.2
# Encoding detection
Expand Down
6 changes: 6 additions & 0 deletions scripts/build-osx-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ echo "Installing/updating setuptools and pip"
echo "======================================"
"$PIP" install 'setuptools==18.*' 'pip==7.*'

echo "Installing Bottlechest"
echo "======================"
"$PIP" install --find-links http://orange.biolab.si/download/files/wheelhouse/ \
--use-wheel --trusted-host orange.biolab.si \
Bottlechest

echo "Installing orangeqt"
echo "==================="
FDIR=$TEMPLATE/Contents/Frameworks
Expand Down
6 changes: 5 additions & 1 deletion scripts/windows/build-win-application.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ touch "$BUILDBASE"/requirements.txt
echo "
#:wheel: scikit-learn https://pypi.python.org/packages/b8/9a/02d5d76be66c57aaa9f917c87007b9b0bf486992cc7701512464d1ce11e9/scikit_learn-0.17.1-cp34-cp34m-win32.whl#md5=ab00daed7cdac4cb16ad0613b91be07e
scikit-learn==0.17.1
#:wheel: Bottlecheset https://dl.dropboxusercontent.com/u/100248799/Bottlechest-0.7.1-cp34-none-win32.whl#md5=629ba2a148dfa784d0e6817497d42e97
--find-links https://dl.dropboxusercontent.com/u/100248799/Bottlechest-0.7.1-cp34-none-win32.whl
Bottlechest==0.7.1
" > "$BUILDBASE"/requirements.txt

function __download_url {
Expand Down Expand Up @@ -287,7 +291,7 @@ function prepare_orange {
bdist_wheel -d "$BUILDBASE/wheelhouse"

# Ensure all install dependencies are available in the wheelhouse
prepare_req --only-binary numpy,scipy,scikit-learn .
prepare_req --only-binary numpy,scipy,scikit-learn,bottlechest .

echo "# Orange " >> "$BUILDBASE/requirements.txt"
echo "$name==$version" >> "$BUILDBASE/requirements.txt"
Expand Down

0 comments on commit a326d23

Please sign in to comment.