Skip to content

Commit 9c11ff5

Browse files
author
Benjamin Chrétien
committed
Rename scales ---> scaling.
1 parent 2f70d62 commit 9c11ff5

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

src/roboptim/core/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ def argumentBounds(self, value):
308308
setArgumentBounds (self._problem, value)
309309

310310
@property
311-
def argumentScales(self):
312-
return getArgumentScales (self._problem)
311+
def argumentScaling(self):
312+
return getArgumentScaling (self._problem)
313313

314-
@argumentScales.setter
315-
def argumentScales(self, value):
316-
setArgumentScales (self._problem, value)
314+
@argumentScaling.setter
315+
def argumentScaling(self, value):
316+
setArgumentScaling (self._problem, value)
317317

318318
def addConstraint (self, constraint, bounds):
319319
addConstraint (self._problem, constraint._function, bounds)

src/wrap.cc

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,7 @@ setArgumentBounds (PyObject*, PyObject* args)
18571857
}
18581858

18591859
static PyObject*
1860-
getArgumentScales (PyObject*, PyObject* args)
1860+
getArgumentScaling (PyObject*, PyObject* args)
18611861
{
18621862
problem_t* problem = 0;
18631863
if (!PyArg_ParseTuple (args, "O&", &detail::problemConverter, &problem))
@@ -1870,56 +1870,56 @@ getArgumentScales (PyObject*, PyObject* args)
18701870

18711871
npy_intp inputSize =
18721872
static_cast<npy_intp> (problem->function ().inputSize ());
1873-
PyObject* scalesNumpy = PyArray_SimpleNew (1, &inputSize, NPY_DOUBLE);
1873+
PyObject* scalingNumpy = PyArray_SimpleNew (1, &inputSize, NPY_DOUBLE);
18741874

1875-
Eigen::Map<Function::vector_t> scalesEigen
1876-
(static_cast<double*> (PyArray_DATA (scalesNumpy)),
1875+
Eigen::Map<Function::vector_t> scalingEigen
1876+
(static_cast<double*> (PyArray_DATA (scalingNumpy)),
18771877
problem->function ().inputSize ());
18781878

18791879
for (Function::size_type i = 0; i < inputSize; ++i)
1880-
scalesEigen[i] = problem->argumentScales ()[i];
1881-
return scalesNumpy;
1880+
scalingEigen[i] = problem->argumentScaling ()[i];
1881+
return scalingNumpy;
18821882
}
18831883

18841884
static PyObject*
1885-
setArgumentScales (PyObject*, PyObject* args)
1885+
setArgumentScaling (PyObject*, PyObject* args)
18861886
{
18871887
problem_t* problem = 0;
1888-
PyObject* scales = 0;
1888+
PyObject* scaling = 0;
18891889
if (!PyArg_ParseTuple
1890-
(args, "O&O", &detail::problemConverter, &problem, &scales))
1890+
(args, "O&O", &detail::problemConverter, &problem, &scaling))
18911891
return 0;
18921892
if (!problem)
18931893
{
18941894
PyErr_SetString (PyExc_TypeError, "1st argument must be a problem");
18951895
return 0;
18961896
}
1897-
PyObject* scalesNumpy =
1897+
PyObject* scalingNumpy =
18981898
PyArray_FROM_OTF
1899-
(scales, NPY_DOUBLE, NPY_IN_ARRAY & ::roboptim::core::python::NPY_STORAGE_ORDER);
1900-
if (!scalesNumpy)
1899+
(scaling, NPY_DOUBLE, NPY_IN_ARRAY & ::roboptim::core::python::NPY_STORAGE_ORDER);
1900+
if (!scalingNumpy)
19011901
{
1902-
Py_XDECREF (scalesNumpy);
1902+
Py_XDECREF (scalingNumpy);
19031903
PyErr_SetString (PyExc_TypeError,
19041904
"failed to build numpy array from 2st argument");
19051905
return 0;
19061906
}
19071907

1908-
if (PyArray_DIM (scalesNumpy, 0) != problem->function ().inputSize ())
1908+
if (PyArray_DIM (scalingNumpy, 0) != problem->function ().inputSize ())
19091909
{
19101910
PyErr_SetString (PyExc_TypeError, "invalid size");
19111911
return 0;
19121912
}
19131913

1914-
Eigen::Map<Function::vector_t> scalesEigen
1915-
(static_cast<double*> (PyArray_DATA (scalesNumpy)),
1914+
Eigen::Map<Function::vector_t> scalingEigen
1915+
(static_cast<double*> (PyArray_DATA (scalingNumpy)),
19161916
problem->function ().inputSize ());
19171917

19181918
for (size_t i = 0; i < static_cast<size_t> (problem->function ().inputSize ()); ++i)
1919-
problem->argumentScales ()[i] = scalesEigen[i];
1919+
problem->argumentScaling ()[i] = scalingEigen[i];
19201920

19211921
// Clean up.
1922-
Py_DECREF (scalesNumpy);
1922+
Py_DECREF (scalingNumpy);
19231923

19241924
Py_INCREF (Py_None);
19251925
return Py_None;
@@ -2009,9 +2009,9 @@ addConstraint (PyObject*, PyObject* args)
20092009
&& PyArray_DIMS (py_bounds)[1] == 2)
20102010
{
20112011
typedef problem_t::intervals_t intervals_t;
2012-
typedef problem_t::scales_t scales_t;
2012+
typedef problem_t::scaling_t scaling_t;
20132013

2014-
scales_t scales (constraint->outputSize (), 1.);
2014+
scaling_t scaling (constraint->outputSize (), 1.);
20152015
intervals_t bounds (constraint->outputSize ());
20162016

20172017
for (Function::size_type i = 0; i < constraint->outputSize (); ++i)
@@ -2021,7 +2021,7 @@ addConstraint (PyObject*, PyObject* args)
20212021
bounds[i].second = * (double*) (PyArray_GETPTR2 (py_bounds, i, 1));
20222022
}
20232023

2024-
problem->addConstraint (constraint, bounds, scales);
2024+
problem->addConstraint (constraint, bounds, scaling);
20252025
}
20262026
else
20272027
{
@@ -2999,10 +2999,10 @@ static PyMethodDef RobOptimCoreMethods[] =
29992999
"Get the problem argument bounds."},
30003000
{"setArgumentBounds", setArgumentBounds, METH_VARARGS,
30013001
"Set the problem argument bounds."},
3002-
{"getArgumentScales", getArgumentScales, METH_VARARGS,
3003-
"Get the problem scales."},
3004-
{"setArgumentScales", setArgumentScales, METH_VARARGS,
3005-
"Set the problem scales."},
3002+
{"getArgumentScaling", getArgumentScaling, METH_VARARGS,
3003+
"Get the problem scaling."},
3004+
{"setArgumentScaling", setArgumentScaling, METH_VARARGS,
3005+
"Set the problem scaling."},
30063006
{"addConstraint", addConstraint, METH_VARARGS,
30073007
"Add a constraint to the problem."},
30083008

tests/function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ def test_solver(self):
158158
problem.argumentBounds = numpy.array([[-3.,4.],])
159159
numpy.testing.assert_almost_equal (problem.argumentBounds, [[-3.,4.],])
160160

161-
problem.argumentScales = numpy.array([2.,])
162-
numpy.testing.assert_almost_equal (problem.argumentScales, [2.,])
161+
problem.argumentScaling = numpy.array([2.,])
162+
numpy.testing.assert_almost_equal (problem.argumentScaling, [2.,])
163163

164164
g1 = Square ()
165165
problem.addConstraint (g1, [-1., 10.,])

0 commit comments

Comments
 (0)