Skip to content

Commit

Permalink
FIX-#2596: Revert fix for binary ops
Browse files Browse the repository at this point in the history
Signed-off-by: Igoshev, Yaroslav <yaroslav.igoshev@intel.com>
  • Loading branch information
YarShev committed Feb 4, 2021
1 parent 825228b commit 10fcd0e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 48 deletions.
32 changes: 24 additions & 8 deletions asv_bench/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,65 @@
// The version of the config file format. Do not change, unless
// you know what you are doing.
"version": 1,

// The name of the project being benchmarked
"project": "modin",

// The project's homepage
"project_url": "https://modin.readthedocs.io/",

// The URL or local path of the source code repository for the
// project being benchmarked
"repo": "..",

// The Python project's subdirectory in your repo. If missing or
// the empty string, the project is assumed to be located at the root
// of the repository.
// "repo_subdir": "",

// Customizable commands for building, installing, and
// uninstalling the project. See asv.conf.json documentation.
//
"install_command": [
"in-dir={env_dir} python -mpip install {wheel_file}[ray]"
],
"install_command": ["in-dir={env_dir} python -mpip install {wheel_file}[ray]"],
// "uninstall_command": ["return-code=any python -mpip uninstall -y {project}"],
// "build_command": [
// "python setup.py build",
// "PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
// ],

// List of branches to benchmark. If not provided, defaults to "master"
// (for git) or "default" (for mercurial).
// "branches": ["master"], // for git
// "branches": ["default"], // for mercurial

// The DVCS being used. If not set, it will be automatically
// determined from "repo" by looking at the protocol in the URL
// (if remote), or by looking for special directories, such as
// ".git" (if local).
// "dvcs": "git",

// The tool to use to create environments. May be "conda",
// "virtualenv" or other value depending on the plugins in use.
// If missing or the empty string, the tool will be automatically
// determined by looking for tools on the PATH environment
// variable.
"environment_type": "conda",

// timeout in seconds for installing any dependencies in environment
// defaults to 10 min
//"install_timeout": 600,

// the base URL to show a commit for the project.
"show_commit_url": "https://github.com/modin-project/modin/commit/",

// The Pythons you'd like to test against. If not provided, defaults
// to the current version of Python used to run `asv`.
// "pythons": ["3.7"],

// The list of conda channel names to be searched for benchmark
// dependency packages in the specified order
"conda_channels": [
"conda-forge",
"defaults"
],
"conda_channels": ["conda-forge", "defaults"],

// The matrix of dependencies to test. Each key is the name of a
// package (in PyPI) and the values are version numbers. An empty
// list or empty string indicates to just test against the default
Expand Down Expand Up @@ -98,24 +106,31 @@
// // additional env if run on windows+conda
// {"platform": "win32", "environment_type": "conda", "python": "2.7", "libpython": ""},
// ],

// The directory (relative to the current directory) that benchmarks are
// stored in. If not provided, defaults to "benchmarks"
// "benchmark_dir": "benchmarks",

// The directory (relative to the current directory) to cache the Python
// environments in. If not provided, defaults to "env"
"env_dir": ".asv/env",

// The directory (relative to the current directory) that raw benchmark
// results are stored in. If not provided, defaults to "results".
"results_dir": ".asv/results",

// The directory (relative to the current directory) that the html tree
// should be written to. If not provided, defaults to "html".
"html_dir": ".asv/html",

// The number of characters to retain in the commit hashes.
// "hash_length": 8,

// `asv` will cache results of the recent builds in each
// environment, making them faster to install next time. This is
// the number of builds to keep, per environment.
// "build_cache_size": 2,

// The commits after which the regression search in `asv publish`
// should start looking for regressions. Dictionary whose keys are
// regexps matching to benchmark names, and values corresponding to
Expand All @@ -128,6 +143,7 @@
// "some_benchmark": "352cdf", // Consider regressions only after this commit
// "another_benchmark": null, // Skip regression detection altogether
// },

// The thresholds for relative change in results, after which `asv
// publish` starts reporting regressions. Dictionary of the same
// form as in ``regressions_first_commits``, with values
Expand All @@ -138,4 +154,4 @@
// "some_benchmark": 0.01, // Threshold of 1%
// "another_benchmark": 0.5, // Threshold of 50%
// },
}
}
29 changes: 1 addition & 28 deletions modin/data_management/functions/binary_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def caller(query_compiler, other, *args, **kwargs):
axis = kwargs.get("axis", 0)
broadcast = kwargs.pop("broadcast", False)
join_type = call_kwds.get("join_type", "outer")
squeeze_self = kwargs.pop("squeeze_self", None)
if isinstance(other, type(query_compiler)):
if broadcast:
assert (
Expand Down Expand Up @@ -55,37 +54,11 @@ def caller(query_compiler, other, *args, **kwargs):
)
else:
if isinstance(other, (list, np.ndarray, pandas.Series)):
if len(query_compiler.columns) == 1:

def _apply_func(df):
result = func(
df.squeeze(axis=1) if squeeze_self else df,
other,
*args,
**kwargs
)
return pandas.DataFrame(result)

apply_func = _apply_func
build_mapreduce_func = False
else:

def _apply_func(df):
return func(
df.squeeze(axis=1) if squeeze_self else df,
other,
*args,
**kwargs
)

apply_func = _apply_func
build_mapreduce_func = True
new_modin_frame = query_compiler._modin_frame._apply_full_axis(
axis,
apply_func,
lambda df: func(df, other, *args, **kwargs),
new_index=query_compiler.index,
new_columns=query_compiler.columns,
build_mapreduce_func=build_mapreduce_func,
)
else:
new_modin_frame = query_compiler._modin_frame._map(
Expand Down
7 changes: 1 addition & 6 deletions modin/engines/base/frame/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,6 @@ def _apply_full_axis(
new_index=None,
new_columns=None,
dtypes=None,
build_mapreduce_func=True,
):
"""
Perform a function across an entire axis.
Expand Down Expand Up @@ -1310,7 +1309,6 @@ def _apply_full_axis(
new_columns=new_columns,
dtypes=dtypes,
other=None,
build_mapreduce_func=build_mapreduce_func,
)

def _apply_full_axis_select_indices(
Expand Down Expand Up @@ -1645,7 +1643,6 @@ def broadcast_apply_full_axis(
apply_indices=None,
enumerate_partitions=False,
dtypes=None,
build_mapreduce_func=True,
):
"""Broadcast partitions of other dataframe partitions and apply a function along full axis.
Expand Down Expand Up @@ -1691,9 +1688,7 @@ def broadcast_apply_full_axis(
axis=axis,
left=self._partitions,
right=other,
apply_func=self._build_mapreduce_func(axis, func)
if build_mapreduce_func
else func,
apply_func=self._build_mapreduce_func(axis, func),
apply_indices=apply_indices,
enumerate_partitions=enumerate_partitions,
keep_partitioning=True,
Expand Down
24 changes: 18 additions & 6 deletions modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,16 @@ def __radd__(self, left):
return self.add(left)

def __and__(self, other):
if isinstance(other, (list, np.ndarray, pandas.Series)):
return self._default_to_pandas(pandas.Series.__and__, other)
new_self, new_other = self._prepare_inter_op(other)
return new_self._binary_op("__and__", new_other, axis=0, squeeze_self=True)
return super(Series, new_self).__and__(new_other)

def __rand__(self, other):
if isinstance(other, (list, np.ndarray, pandas.Series)):
return self._default_to_pandas(pandas.Series.__rand__, other)
new_self, new_other = self._prepare_inter_op(other)
return self._binary_op("__rand__", other, axis=0, squeeze_self=True)
return super(Series, new_self).__rand__(new_other)

def __array__(self, dtype=None):
return super(Series, self).__array__(dtype).flatten()
Expand Down Expand Up @@ -215,20 +219,28 @@ def __rmul__(self, left):
return self.rmul(left)

def __or__(self, other):
if isinstance(other, (list, np.ndarray, pandas.Series)):
return self._default_to_pandas(pandas.Series.__or__, other)
new_self, new_other = self._prepare_inter_op(other)
return new_self._binary_op("__or__", new_other, axis=0, squeeze_self=True)
return super(Series, new_self).__or__(new_other)

def __ror__(self, other):
if isinstance(other, (list, np.ndarray, pandas.Series)):
return self._default_to_pandas(pandas.Series.__ror__, other)
new_self, new_other = self._prepare_inter_op(other)
return self._binary_op("__ror__", other, axis=0, squeeze_self=True)
return super(Series, new_self).__ror__(new_other)

def __xor__(self, other):
if isinstance(other, (list, np.ndarray, pandas.Series)):
return self._default_to_pandas(pandas.Series.__xor__, other)
new_self, new_other = self._prepare_inter_op(other)
return new_self._binary_op("__xor__", new_other, axis=0, squeeze_self=True)
return super(Series, new_self).__xor__(new_other)

def __rxor__(self, other):
if isinstance(other, (list, np.ndarray, pandas.Series)):
return self._default_to_pandas(pandas.Series.__rxor__, other)
new_self, new_other = self._prepare_inter_op(other)
return new_self._binary_op("__rxor__", new_other, axis=0, squeeze_self=True)
return super(Series, new_self).__rxor__(new_other)

def __pow__(self, right):
return self.pow(right)
Expand Down

0 comments on commit 10fcd0e

Please sign in to comment.