Skip to content

Commit f43e282

Browse files
authored
MAINT: Repalce row_stack with vstack (pydata#202)
1 parent ae3e8cb commit f43e282

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

.github/workflows/tox.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches:
66
- "*"
7+
pull_request:
8+
branches:
9+
- "*"
710

811
jobs:
912
build:

doc/stateful-transforms.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ just similar enough for you to miss the problem until it's too late.)
102102
{"x": data["x"][2:]}]
103103
dinfo = incr_dbuilder("naive_center(x)", lambda: iter(data_chunked))
104104
# Broken!
105-
np.row_stack([build_design_matrices([dinfo], chunk)[0]
105+
np.vstack([build_design_matrices([dinfo], chunk)[0]
106106
for chunk in data_chunked])
107107
108108
But if we use the proper stateful transform, this just works:
@@ -111,7 +111,7 @@ But if we use the proper stateful transform, this just works:
111111
112112
dinfo = incr_dbuilder("center(x)", lambda: iter(data_chunked))
113113
# Correct!
114-
np.row_stack([build_design_matrices([dinfo], chunk)[0]
114+
np.vstack([build_design_matrices([dinfo], chunk)[0]
115115
for chunk in data_chunked])
116116
117117
.. note::

patsy/constraint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def combine(cls, constraints):
8686
for constraint in constraints:
8787
if constraint.variable_names != variable_names:
8888
raise ValueError("variable names don't match")
89-
coefs = np.row_stack([c.coefs for c in constraints])
90-
constants = np.row_stack([c.constants for c in constraints])
89+
coefs = np.vstack([c.coefs for c in constraints])
90+
constants = np.vstack([c.constants for c in constraints])
9191
return cls(variable_names, coefs, constants)
9292

9393
def test_LinearConstraint():

patsy/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def stateful_transform_wrapper(*args, **kwargs):
5959
# self._kwargs = kwargs
6060
#
6161
# def memorize_finish(self):
62-
# all_data = np.row_stack(self._data)
62+
# all_data = np.vstack(self._data)
6363
# args = self._args
6464
# kwargs = self._kwargs
6565
# del self._data

patsy/test_state.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def check_stateful(cls, accepts_multicolumn, input, output, *args, **kwargs):
9090
elif all_outputs[0].ndim == 1:
9191
all_output1 = np.concatenate(all_outputs)
9292
else:
93-
all_output1 = np.row_stack(all_outputs)
93+
all_output1 = np.vstack(all_outputs)
9494
assert all_output1.shape[0] == len(input)
9595
# output_obj_reshaped = np.asarray(output_obj).reshape(all_output1.shape)
9696
# assert np.allclose(all_output1, output_obj_reshaped)
@@ -101,11 +101,11 @@ def check_stateful(cls, accepts_multicolumn, input, output, *args, **kwargs):
101101
# handles both Series and DataFrames
102102
all_input = pandas.concat(input_obj)
103103
elif np.asarray(input_obj[0]).ndim == 1:
104-
# Don't use row_stack, because that would turn this into a 1xn
104+
# Don't use vstack, because that would turn this into a 1xn
105105
# matrix:
106106
all_input = np.concatenate(input_obj)
107107
else:
108-
all_input = np.row_stack(input_obj)
108+
all_input = np.vstack(input_obj)
109109
all_output2 = t.transform(all_input, *args, **kwargs)
110110
if have_pandas and isinstance(input_obj[0], pandas_type):
111111
assert np.array_equal(all_output2.index, pandas_index)

0 commit comments

Comments
 (0)