Skip to content

Commit

Permalink
v0.5.0 (#954)
Browse files Browse the repository at this point in the history
* preparation for version 0.5
* remove unused gitmodules file
* update release notes
* following coverage, remove unused code
* add mailing list / chatroom links
* pylint
* gpkit version 0.5.0.2 as uploaded to pypi
* pylint

* update release notes

* unitstr -> latex_unitstr, small refactors (#973)

* rename varkey.unitstr to varkey.latex_unitstr
* minor improvements from #965 review
  • Loading branch information
bqpd authored Dec 2, 2016
1 parent d1c9591 commit 94283c5
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 131 deletions.
Empty file removed .gitmodules
Empty file.
26 changes: 14 additions & 12 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
setup.py
gpkit/__init__.py
gpkit/_cvxopt.py
gpkit/build.py
gpkit/feasibility.py
gpkit/geometric_program.py
gpkit/keydict.py
gpkit/exceptions.py
gpkit/modified_ctypesgen.py
gpkit/repr_conventions.py
gpkit/small_classes.py
gpkit/small_scripts.py
gpkit/solution_array.py
gpkit/varkey.py
gpkit/_mosek/__init__.py
gpkit/_mosek/cli_expopt.py
gpkit/_mosek/expopt.py
gpkit/build.py
gpkit/constraints/__init__.py
gpkit/constraints/array.py
gpkit/constraints/bounded.py
gpkit/constraints/costed.py
gpkit/constraints/linked.py
gpkit/constraints/model.py
gpkit/constraints/prog_factories.py
gpkit/constraints/relax.py
gpkit/constraints/set.py
gpkit/constraints/sigeq.py
gpkit/constraints/signomial_program.py
gpkit/constraints/single_equation.py
gpkit/constraints/tight.py
gpkit/exceptions.py
gpkit/geometric_program.py
gpkit/interactive/__init__.py
gpkit/interactive/chartjs.py
gpkit/interactive/linking_diagram.py
gpkit/interactive/plotting.py
gpkit/interactive/ractor.py
gpkit/interactive/sensitivity_map.py
gpkit/interactive/widgets.py
gpkit/keydict.py
gpkit/modified_ctypesgen.py
gpkit/nomials/__init__.py
gpkit/nomials/array.py
gpkit/nomials/data.py
Expand All @@ -40,6 +36,10 @@ gpkit/nomials/nomial_math.py
gpkit/nomials/substitution.py
gpkit/nomials/variables.py
gpkit/pint/usd_cpi.txt
gpkit/repr_conventions.py
gpkit/small_classes.py
gpkit/small_scripts.py
gpkit/solution_array.py
gpkit/tests/__init__.py
gpkit/tests/helpers.py
gpkit/tests/run_tests.py
Expand All @@ -57,3 +57,5 @@ gpkit/tests/t_vars.py
gpkit/tools/__init__.py
gpkit/tools/fmincon.py
gpkit/tools/tools.py
gpkit/varkey.py
setup.py
2 changes: 1 addition & 1 deletion docs/source/citinggpkit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ If you use GPkit, please cite it with the following bibtex::
title={GPkit software for geometric programming},
howpublished={\url{https://github.com/hoburg/gpkit}},
year={2016},
note={Version 0.4.2}
note={Version 0.5.0}
}
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
version = '0.4'
version = '0.5'
# The full version, including alpha/beta/rc tags.
release = '0.4.2'
release = '0.5.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Supported solvers are
`MOSEK <http://mosek.com>`_
and `CVXOPT <http://cvxopt.org>`_.

Join our `mailing list <https://mailman.mit.edu/mailman/listinfo/gpkit-users/>`_ and/or `chatroom <https://gitter.im/gpkit-users/Lobby>`_ for support and examples.

Table of contents
====================
.. toctree::
Expand Down
4 changes: 2 additions & 2 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Install GPkit
- Run ``pip install gpkit`` at the command line (for system python installs, use ``sudo pip``)
- Run ``pip install ipywidgets`` for interactive control of models (recommended)
- Run ``python -c "import gpkit.tests; gpkit.tests.run()"`` to run the tests; if any tests do not pass, please email ``[email protected]`` or `raise a GitHub issue <http://github.com/hoburg/gpkit/issues/new>`_.
- *Optional:* to install gpkit into an isolated python environment, install ``virtualenv``, run ``virtualenv $DESTINATION_DIR`` then activate it with ``source $DESTINATION_DIR/bin/activate``
- Join our `mailing list <https://mailman.mit.edu/mailman/listinfo/gpkit-users/>`_ and/or `chatroom <https://gitter.im/gpkit-users/Lobby>`_ for support and examples.


Debugging installation
Expand All @@ -124,7 +124,7 @@ You may need to rebuild GPkit if any of the following occur:
- You delete the ``.gpkit`` folder from your home directory
- You see ``Could not load settings file.`` when importing GPkit, or
- ``Could not load MOSEK library: ImportError('$HOME/.gpkit/expopt.so not found.')``
To rebuild GPkit, do the following:
To rebuild GPkit, first try running ``python -c "from gpkit.build import rebuild; rebuild()"``. If that doesn't work then try the following:
- Run ``pip uninstall gpkit``
- Run ``pip install --no-cache-dir --no-deps gpkit``
- Run ``python -c "import gpkit.tests; gpkit.tests.run()"``
Expand Down
33 changes: 27 additions & 6 deletions docs/source/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,29 @@ Release Notes

This page lists the changes made in each point version of gpkit.

Version 0.5.0
=============
* No longer recommend the use of linked variables and subinplace
* Switched default solver to MOSEK
* Added Linked Variable diagram (PR #915)
* Dropped operator overloading with pint (PR #938)
* Added and documented debugging tools (PR #933)
* Added and documented vectorization tools
* Documented modular model construction
* 3200 lines of code, 1800 lines of tests, 1700 lines of docstring. (not counting `interactive`)

Changes to named models / Model inheritance
-------------------------------------------
We are deprecating the creation of named submodels with custom ``__init__`` methods. Previously, variables created during ``__init__`` in any class inheriting from Model were replaced by a copy with ``__class__.__name__`` added as varkey metadata. This was slow, a bit irregular, and hacky.

We're moving to an explicitly-irregular ``setup`` method, which (if declared for a class inheriting from Model) is automatically called during ``Model.__init__`` inside a ``NamedVariables(self.__class__.__name__)`` environment. This 1) handles the naming of variables more explicitly and efficiently, and 2) allows us to capture variables created within ``setup``, so that constants that are not a part of any constraint can be used directly (several examples of such template models are in the new `Building Complex Models` documentation).

``Model.__init__`` calls ``setup`` with the arguments given to the constructor, with the exception of ``substitutions``, which is a reserved keyword. This allows for the easy creation of a named model with custom parameter values (as in the documentation's Beam example). ``setup`` methods should return an iterable (list, tuple, ConstraintSet, ...) of constraints or nothing if the model contains no constraints. To declare a submodel cost, set ``self.cost`` during ``setup``. However, we often find declaring a model's cost explicitly just before solving to be a more legible practice.

In addition to permitting us to name variables at creation, and include unconstrained variables in a model, we hope that ``setup`` methods will clarify the side effects of named model creation.

Version 0.4.2
-------------
=============
* prototype handling of SignomialEquality constraints
* fix an issue where solution tables printed incorrect units (despite the units being correct in the ``SolutionArray`` data structure)
* fix ``controlpanel`` slider display for newer versions of ipywidgets
Expand All @@ -22,14 +43,14 @@ Version 0.4.2
* SP sweep compatibility

Version 0.4.0
-------------
=============
* New model for considering constraints: all constraints are considered as sets of constraints which may contain other constraints, and are asked for their substitutions / posynomial less than 1 representation as late as possible.
* Support for calling external code during an SP solve.
* New class KeyDict to allow referring to variables by name or with objects.
* Many many other bug fixes, speed ups, and refactors under the hood.

Version 0.3.4
-------------
=============
* Modular / model composition fixes and improvements
* Working controlpanel() for Model
* ipynb and numpy dependency fixes
Expand All @@ -38,15 +59,15 @@ Version 0.3.4
* slider widgets now have units

Version 0.3.2
-------------
=============
* Assorted bug fixes
* Assorted internal improvements and simplifications
* Refactor signomial constraints, resulting in smarter SP heuristic
* Simplify and strengthen equality testing for nomials
* Not counting submodules, went from 2400 to 2500 lines of code and from 1050 to 1170 lines of docstrings and comments.

Version 0.3
-----------
===========
* Integrated GP and SP creation under the Model class
* Improved and simplified under-the-hood internals of GPs and SPs
* New experimental SP heuristic
Expand All @@ -63,7 +84,7 @@ Version 0.3
* Simplified solver logging and printing, making it easier to access solver output.

Version 0.2
-----------
===========

* Various bug fixes
* Python 3 compatibility
Expand Down
2 changes: 1 addition & 1 deletion gpkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from os.path import dirname as os_path_dirname
SETTINGS_PATH = os_sep.join([os_path_dirname(__file__), "env", "settings"])

__version__ = "0.4.2"
__version__ = "0.5.0"
UNIT_REGISTRY = None
SIGNOMIALS_ENABLED = False

Expand Down
13 changes: 6 additions & 7 deletions gpkit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,15 @@ def build(self):

return True

def rebuild():
"Changes to the installed gpkit directory and runs build_gpkit()"
import gpkit
log("# Moving to the directory from which GPkit was imported.")
os.chdir(gpkit.__path__[0])
build_gpkit()

def build_gpkit():
"Builds GPkit"
try:
import gpkit
log("# Moving to the directory from which GPkit was imported.")
os.chdir(gpkit.__path__[0])
except ImportError:
pass

if isfile("__init__.py"):
#call("ls")
log("# Don't want to be in a folder with __init__.py, going up!")
Expand Down
6 changes: 0 additions & 6 deletions gpkit/constraints/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class ConstraintsRelaxedEqually(ConstraintSet):
"""

def __init__(self, constraints):
if not isinstance(constraints, ConstraintSet):
constraints = ConstraintSet(constraints)
substitutions = dict(constraints.substitutions)
posynomials = constraints.as_posyslt1()
with NamedVariables("Relax"):
Expand Down Expand Up @@ -64,8 +62,6 @@ class ConstraintsRelaxed(ConstraintSet):
"""

def __init__(self, constraints):
if not isinstance(constraints, ConstraintSet):
constraints = ConstraintSet(constraints)
substitutions = dict(constraints.substitutions)
posynomials = constraints.as_posyslt1()
N = len(posynomials)
Expand Down Expand Up @@ -105,8 +101,6 @@ class ConstantsRelaxed(ConstraintSet):
def __init__(self, constraints, include_only=None, exclude=None):
exclude = frozenset(exclude) if exclude else frozenset()
include_only = frozenset(include_only) if include_only else frozenset()
if not isinstance(constraints, ConstraintSet):
constraints = ConstraintSet(constraints)
substitutions = KeyDict(constraints.substitutions)
constants, _, _ = parse_subs(constraints.varkeys,
constraints.substitutions)
Expand Down
13 changes: 7 additions & 6 deletions gpkit/geometric_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from time import time
import numpy as np
from .nomials import NomialData
from .small_classes import CootMatrix, HashVector
from .small_classes import CootMatrix, HashVector, SolverLog
from .keydict import FastKeyDict
from .small_classes import SolverLog
from .small_scripts import mag


DEFAULT_SOLVER_KWARGS = {"cvxopt": {"kktsolver": "ldl"}}
Expand Down Expand Up @@ -58,9 +58,6 @@ def __init__(self, cost, constraints, substitutions=None, verbosity=1):

for constraint in constraints:
constr_posys = constraint.as_posyslt1(self.substitutions)
if not all(constr_posys):
raise ValueError("%s is an invalid constraint for a"
" GeometricProgram" % constraint)
start_idx, ps_added = len(self.posynomials), len(constr_posys)
self.constr_idxs.append(range(start_idx, start_idx + ps_added))
self.posynomials.extend(constr_posys)
Expand Down Expand Up @@ -266,7 +263,11 @@ def _compile_result(self, solver_out):
else:
# use self.posynomials[0] because the cost may have had constants
freev = result["freevariables"]
result["cost"] = self.posynomials[0].subsummag(freev)
cost = self.posynomials[0].sub(freev)
if cost.varkeys:
raise ValueError("cost contains unsolved variables %s"
% cost.varkeys.keys())
result["cost"] = mag(cost.c)

## Get sensitivities
result["sensitivities"] = {"nu": nu, "la": la}
Expand Down
2 changes: 1 addition & 1 deletion gpkit/interactive/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def modelcontrolpanel(model, *args, **kwargs):
sliderboxes = []
for sl in sliders.children:
cb = widgets.Checkbox(value=True)
unit_latex = sl.varkey.unitstr()
unit_latex = sl.varkey.latex_unitstr()
if unit_latex:
unit_latex = r"$\scriptsize"+unit_latex+"$"
units = widgets.Latex(value=unit_latex)
Expand Down
6 changes: 1 addition & 5 deletions gpkit/nomials/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ def wrapped_func(self, other):
"Creates array constraint from vectorized operator."
if not self.shape:
return func(self.flatten()[0], other)
if isinstance(other, Quantity):
veccable_other = np.array([other], dtype=object)
else:
veccable_other = other
result = vecfunc(self, veccable_other)
result = vecfunc(self, other)
left = self.key if hasattr(self, "key") else self
right = other.key if hasattr(other, "key") else other
return ArrayConstraint(result, left, symbol, right)
Expand Down
11 changes: 0 additions & 11 deletions gpkit/nomials/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class NomialData(object):
"""
# pylint: disable=too-many-instance-attributes
def __init__(self, exps=None, cs=None, simplify=True):
if exps is None and cs is None:
# pass through for classmethods to get a NomialData object,
# which they will then call __init__ on
return
if simplify:
exps, cs = simplify_exps_and_cs(exps, cs)
self.exps, self.cs = exps, cs
Expand Down Expand Up @@ -54,13 +50,6 @@ def __hash__(self):
[str(self.units)]))
return self._hashvalue

@classmethod
def fromnomials(cls, nomials):
"""Construct a NomialData from an iterable of Signomial objects"""
nd = cls() # use pass-through version of __init__
nd.init_from_nomials(nomials)
return nd

@property
def varkeys(self):
"The NomialData's varkeys, created when necessary for a substitution."
Expand Down
18 changes: 0 additions & 18 deletions gpkit/nomials/nomial_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@
from ..repr_conventions import _str, _repr, _repr_latex_


def fast_monomial_str(exp, c):
"Quickly generates a unitless monomial string."
varstrs = []
for (var, x) in exp.items():
if x != 0:
varstr = str(var)
if x != 1:
varstr += "**%.2g" % x
varstrs.append(varstr)
c = mag(c)
cstr = "%.3g" % c
if cstr == "-1" and varstrs:
return "-" + "*".join(varstrs)
else:
cstr = [cstr] if (cstr != "1" or not varstrs) else []
return "*".join(cstr + varstrs)


class Nomial(NomialData):
"Shared non-mathematical properties of all nomials"
__div__ = None
Expand Down
Loading

0 comments on commit 94283c5

Please sign in to comment.