From ecb0b2ad560d3d20c85b703865369564c5af05a5 Mon Sep 17 00:00:00 2001 From: Elaine Hale Date: Mon, 8 Oct 2018 12:57:04 -0600 Subject: [PATCH 1/3] Incrementing copyright year and removing license notice from .py files. Next step is to put license in with # rather than docstring comments. --- LICENSE | 2 +- bin/csv_to_gdx.py | 38 ---- bin/gdx_to_csv.py | 38 ---- doc/source/conf.py | 341 +++++++++++++++++--------------- gdxpds/__init__.py | 38 ---- gdxpds/_version.py | 4 +- gdxpds/gdx.py | 38 ---- gdxpds/read_gdx.py | 38 ---- gdxpds/test/__init__.py | 38 ---- gdxpds/test/test_conversions.py | 38 ---- gdxpds/test/test_details.py | 38 ---- gdxpds/test/test_read.py | 38 ---- gdxpds/test/test_session.py | 38 ---- gdxpds/tools.py | 38 ---- gdxpds/write_gdx.py | 38 ---- setup.py | 54 ++--- 16 files changed, 212 insertions(+), 645 deletions(-) diff --git a/LICENSE b/LICENSE index 563692e..2f2a467 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2017, Alliance for Sustainable Energy. +Copyright (c) 2018, Alliance for Sustainable Energy. All rights reserved. Redistribution and use in source and binary forms, diff --git a/bin/csv_to_gdx.py b/bin/csv_to_gdx.py index 84e614e..d87dd42 100644 --- a/bin/csv_to_gdx.py +++ b/bin/csv_to_gdx.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' import argparse diff --git a/bin/gdx_to_csv.py b/bin/gdx_to_csv.py index c3cdff8..da5ebb4 100644 --- a/bin/gdx_to_csv.py +++ b/bin/gdx_to_csv.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' import argparse diff --git a/doc/source/conf.py b/doc/source/conf.py index 43f0604..8d6bfa0 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,161 +1,180 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/stable/config - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - - -# -- Project information ----------------------------------------------------- -import gdxpds - -project = 'gdx-pandas' -copyright = '2018, Alliance for Sustainable Energy' -author = 'Elaine T. Hale' - -# The short X.Y version -version = gdxpds.__version__ -# The full version, including alpha/beta/rc tags -release = gdxpds.__version__ - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.coverage', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path . -exclude_patterns = [] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'gdx-pandasdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'gdx-pandas.tex', 'gdx-pandas Documentation', - 'Elaine T. Hale', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'gdx-pandas', 'gdx-pandas Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'gdx-pandas', 'gdx-pandas Documentation', - author, 'gdx-pandas', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Extension configuration ------------------------------------------------- \ No newline at end of file +''' +''' +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/stable/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) +import sphinx_rtd_theme + + +# -- Project information ----------------------------------------------------- +import gdxpds + +project = 'gdx-pandas' +copyright = '2018, Alliance for Sustainable Energy' +author = 'Elaine T. Hale' + +# The short X.Y version +version = gdxpds.__version__ +# The full version, including alpha/beta/rc tags +release = gdxpds.__version__ + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.coverage', + 'sphinx.ext.viewcode', + 'sphinx.ext.githubpages', + 'sphinx.ext.napoleon' # had numpydoc, but got lots of extraneous warnings +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path . +exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'sphinx_rtd_theme' +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +html_theme_options = { + 'collapse_navigation': False, + 'sticky_navigation': True, + 'titles_only': False +} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'gdx-pandasdoc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'gdx-pandas.tex', 'gdx-pandas Documentation', + 'Elaine T. Hale', 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'gdx-pandas', 'gdx-pandas Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'gdx-pandas', 'gdx-pandas Documentation', + author, 'gdx-pandas', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Extension configuration ------------------------------------------------- + +autoclass_content = 'both' +autodoc_member_order = 'bysource' +# Uncomment when https://github.com/sphinx-doc/sphinx/pull/4076 is +# released. +#autodoc_special_members = ['__getitem__', '__setitem__','__iter__'] +numpy_show_class_member = True diff --git a/gdxpds/__init__.py b/gdxpds/__init__.py index 9c5bdce..875818e 100644 --- a/gdxpds/__init__.py +++ b/gdxpds/__init__.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' __author__ = "Elaine T. Hale" diff --git a/gdxpds/_version.py b/gdxpds/_version.py index 68cdeee..eb04a28 100644 --- a/gdxpds/_version.py +++ b/gdxpds/_version.py @@ -1 +1,3 @@ -__version__ = "1.0.5" +''' +''' +__version__ = "1.0.5" diff --git a/gdxpds/gdx.py b/gdxpds/gdx.py index c04fbd1..01e84ff 100644 --- a/gdxpds/gdx.py +++ b/gdxpds/gdx.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] Backend functionality for reading and writing GDX files. The GdxFile and GdxSymbol classes are full-featured interfaces diff --git a/gdxpds/read_gdx.py b/gdxpds/read_gdx.py index 9f8ddc8..a7b241c 100644 --- a/gdxpds/read_gdx.py +++ b/gdxpds/read_gdx.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' from collections import OrderedDict diff --git a/gdxpds/test/__init__.py b/gdxpds/test/__init__.py index 0cca90d..d5b92a3 100644 --- a/gdxpds/test/__init__.py +++ b/gdxpds/test/__init__.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' import os diff --git a/gdxpds/test/test_conversions.py b/gdxpds/test/test_conversions.py index 8974983..dc03746 100644 --- a/gdxpds/test/test_conversions.py +++ b/gdxpds/test/test_conversions.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' import os diff --git a/gdxpds/test/test_details.py b/gdxpds/test/test_details.py index 60a258a..b4e468e 100644 --- a/gdxpds/test/test_details.py +++ b/gdxpds/test/test_details.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' from ctypes import c_bool diff --git a/gdxpds/test/test_read.py b/gdxpds/test/test_read.py index 88b4b28..83ee365 100644 --- a/gdxpds/test/test_read.py +++ b/gdxpds/test/test_read.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' import os diff --git a/gdxpds/test/test_session.py b/gdxpds/test/test_session.py index 7b250ea..982114d 100644 --- a/gdxpds/test/test_session.py +++ b/gdxpds/test/test_session.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' import os diff --git a/gdxpds/tools.py b/gdxpds/tools.py index af83601..2c659f3 100644 --- a/gdxpds/tools.py +++ b/gdxpds/tools.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' import logging diff --git a/gdxpds/write_gdx.py b/gdxpds/write_gdx.py index 6843de8..5059acc 100644 --- a/gdxpds/write_gdx.py +++ b/gdxpds/write_gdx.py @@ -1,42 +1,4 @@ ''' -[LICENSE] - -Copyright (c) 2017, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -[/LICENSE] ''' import logging diff --git a/setup.py b/setup.py index b997167..c288ca8 100644 --- a/setup.py +++ b/setup.py @@ -1,26 +1,28 @@ - -from distutils.core import setup -import os - -here = os.path.abspath(os.path.dirname(__file__)) - -with open(os.path.join(here, 'gdxpds', '_version.py'), encoding='utf-8') as f: - version = f.read() - -version = version.split()[2].strip('"').strip("'") - -setup( - name = 'gdxpds', - version = version, - author = 'Elaine T. Hale', - author_email = 'elaine.hale@nrel.gov', - packages = ['gdxpds', 'gdxpds.test'], - scripts = ['bin/csv_to_gdx.py', 'bin/gdx_to_csv.py'], - url = 'https://github.com/NREL/gdx-pandas', - description = 'Python package to translate between gdx (GAMS data) and pandas.', - long_description=open('README.txt').read(), - package_data={ - 'gdxpds.test': ['*.csv','*.gdx'] - }, - install_requires=open('requirements.txt').read() -) +''' +''' + +from distutils.core import setup +import os + +here = os.path.abspath(os.path.dirname(__file__)) + +with open(os.path.join(here, 'gdxpds', '_version.py'), encoding='utf-8') as f: + version = f.read() + +version = version.split()[2].strip('"').strip("'") + +setup( + name = 'gdxpds', + version = version, + author = 'Elaine T. Hale', + author_email = 'elaine.hale@nrel.gov', + packages = ['gdxpds', 'gdxpds.test'], + scripts = ['bin/csv_to_gdx.py', 'bin/gdx_to_csv.py'], + url = 'https://github.com/NREL/gdx-pandas', + description = 'Python package to translate between gdx (GAMS data) and pandas.', + long_description=open('README.txt').read(), + package_data={ + 'gdxpds.test': ['*.csv','*.gdx'] + }, + install_requires=open('requirements.txt').read() +) From 6414315264a5e693c78ad94c56c5b156c0e3d5e0 Mon Sep 17 00:00:00 2001 From: Elaine Hale Date: Mon, 8 Oct 2018 13:49:27 -0600 Subject: [PATCH 2/3] Updating license and moving it out of the docstrings. --- bin/csv_to_gdx.py | 38 +++- bin/gdx_to_csv.py | 38 +++- dev/add_header.py | 60 ++++-- dev/gdx-pandas-header.txt | 34 --- doc/source/conf.py | 358 ++++++++++++++++---------------- gdxpds/__init__.py | 38 +++- gdxpds/_version.py | 4 +- gdxpds/gdx.py | 38 +++- gdxpds/read_gdx.py | 38 +++- gdxpds/test/__init__.py | 38 +++- gdxpds/test/test_conversions.py | 38 +++- gdxpds/test/test_details.py | 38 +++- gdxpds/test/test_read.py | 38 +++- gdxpds/test/test_session.py | 38 +++- gdxpds/tools.py | 38 +++- gdxpds/write_gdx.py | 38 +++- setup.py | 90 +++++--- 17 files changed, 712 insertions(+), 290 deletions(-) delete mode 100644 dev/gdx-pandas-header.txt diff --git a/bin/csv_to_gdx.py b/bin/csv_to_gdx.py index d87dd42..405df6c 100644 --- a/bin/csv_to_gdx.py +++ b/bin/csv_to_gdx.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] import argparse import os diff --git a/bin/gdx_to_csv.py b/bin/gdx_to_csv.py index da5ebb4..a4e2dba 100644 --- a/bin/gdx_to_csv.py +++ b/bin/gdx_to_csv.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] import argparse import logging diff --git a/dev/add_header.py b/dev/add_header.py index ad33e63..870b7ba 100644 --- a/dev/add_header.py +++ b/dev/add_header.py @@ -11,7 +11,7 @@ from collections import OrderedDict START_LICENSE = '[LICENSE]' -LICENSE_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'gdx-pandas-header.txt') +LICENSE_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),'..','LICENSE') END_LICENSE = '[/LICENSE]' @@ -42,7 +42,16 @@ 'default' :False, 'help' :"""(optional) Remove the license from the given file only, do not add the provided license."""} ) -def get_header(s): + +def get_file_linesep(s): + lines_without = s.splitlines(False) + lines_with = s.splitlines(True) + if lines_without and lines_with: + return lines_with[0][len(lines_without[0]):] + return os.linesep + + +def get_header(s,sep=os.linesep): ''' Splits .py file into its header and body. If no header is found on line 0, one is created. ''' @@ -52,18 +61,24 @@ def get_header(s): lines = s.splitlines(True) #check if has a header - if (len(lines)) > 0 and ('\'\'\'' in lines[0]): + if (len(lines)) > 0 and (lines[0].startswith('#')): eoh = False - header += lines[0] - for l in lines[1:]: + for l in lines: + if (not eoh) and (not l.startswith('#')): + eoh = True + if l == '' + sep: + # keep first blank line with header + header += l + continue + else: + # make a blank line to keep + header += '' + sep if not eoh: header += l - if '\'\'\'' in l: - eoh = True else: body += l else: #no header - header = '\'\'\'' + os.linesep + '\'\'\'' + os.linesep + header = '' + sep body = s return header, body @@ -71,7 +86,7 @@ def get_header(s): def has_license(header): return (START_LICENSE in header) and (END_LICENSE in header) -def rem_license(header): +def rem_license(header,sep=os.linesep): ret_header = '' if has_license(header): found_beg_license = False @@ -96,22 +111,23 @@ def rem_license(header): return ret_header -def add_license(header,lic): +def add_license(header,lic,sep=os.linesep): if has_license(header): raise Exception('There is already a license in the provided header. Please rem_license prior to adding a new one.') ret_head = '' lines = header.splitlines(True) - ret_head += lines[0] #add license to header - ret_head += '%s%s' % (START_LICENSE,os.linesep) - ret_head += '%s%s' % (lic,os.linesep) - ret_head += '%s%s' % (END_LICENSE,os.linesep) + ret_head += ('# ' + START_LICENSE + sep) + count = 0 + for lic_l in lic.splitlines(True): + ret_head += ('# ' + lic_l) + ret_head += ('# ' + END_LICENSE + sep) #add the rest of the header - for l in lines[1:]: + for l in lines: ret_head += l return ret_head @@ -130,9 +146,8 @@ def get_python_files(dirname): return ret if __name__ == '__main__': - #TODO: parse args - parser = argparse.ArgumentParser(description="""Script for adding - a license to the header of Python files.""") + parser = argparse.ArgumentParser(description="""Script for adding a license + to the header of Python files.""") #add the arguments from ARGS for key in ARGS.keys(): @@ -167,15 +182,16 @@ def get_python_files(dirname): print('Removing license from: {}'.format(current_file)) with open(current_file) as f: current_file_text = f.read() - - header, body = get_header(current_file_text) + + sep = get_file_linesep(current_file_text) + header, body = get_header(current_file_text,sep=sep) if has_license(header): - header = rem_license(header) + header = rem_license(header,sep=sep) #only add license if not remove-only if not args.remove: - header = add_license(header,current_license) + header = add_license(header,current_license,sep=sep) with open(current_file,'w') as f: f.write(header+body) diff --git a/dev/gdx-pandas-header.txt b/dev/gdx-pandas-header.txt deleted file mode 100644 index 43abd73..0000000 --- a/dev/gdx-pandas-header.txt +++ /dev/null @@ -1,34 +0,0 @@ -Copyright (c) 2018, Alliance for Sustainable Energy. -All rights reserved. - -Redistribution and use in source and binary forms, -with or without modification, are permitted provided -that the following conditions are met: - -1. Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -2. Redistributions in binary form must reproduce the -above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -3. Neither the name of the copyright holder nor the -names of its contributors may be used to endorse or -promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 8d6bfa0..c489aa7 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,180 +1,178 @@ -''' -''' -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/stable/config - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) -import sphinx_rtd_theme - - -# -- Project information ----------------------------------------------------- -import gdxpds - -project = 'gdx-pandas' -copyright = '2018, Alliance for Sustainable Energy' -author = 'Elaine T. Hale' - -# The short X.Y version -version = gdxpds.__version__ -# The full version, including alpha/beta/rc tags -release = gdxpds.__version__ - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.coverage', - 'sphinx.ext.viewcode', - 'sphinx.ext.githubpages', - 'sphinx.ext.napoleon' # had numpydoc, but got lots of extraneous warnings -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path . -exclude_patterns = [] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'sphinx_rtd_theme' -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -html_theme_options = { - 'collapse_navigation': False, - 'sticky_navigation': True, - 'titles_only': False -} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'gdx-pandasdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'gdx-pandas.tex', 'gdx-pandas Documentation', - 'Elaine T. Hale', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'gdx-pandas', 'gdx-pandas Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'gdx-pandas', 'gdx-pandas Documentation', - author, 'gdx-pandas', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Extension configuration ------------------------------------------------- - -autoclass_content = 'both' -autodoc_member_order = 'bysource' -# Uncomment when https://github.com/sphinx-doc/sphinx/pull/4076 is -# released. -#autodoc_special_members = ['__getitem__', '__setitem__','__iter__'] -numpy_show_class_member = True +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/stable/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) +import sphinx_rtd_theme + + +# -- Project information ----------------------------------------------------- +import gdxpds + +project = 'gdx-pandas' +copyright = '2018, Alliance for Sustainable Energy' +author = 'Elaine T. Hale' + +# The short X.Y version +version = gdxpds.__version__ +# The full version, including alpha/beta/rc tags +release = gdxpds.__version__ + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.coverage', + 'sphinx.ext.viewcode', + 'sphinx.ext.githubpages', + 'sphinx.ext.napoleon' # had numpydoc, but got lots of extraneous warnings +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path . +exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'sphinx_rtd_theme' +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +html_theme_options = { + 'collapse_navigation': False, + 'sticky_navigation': True, + 'titles_only': False +} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'gdx-pandasdoc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'gdx-pandas.tex', 'gdx-pandas Documentation', + 'Elaine T. Hale', 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'gdx-pandas', 'gdx-pandas Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'gdx-pandas', 'gdx-pandas Documentation', + author, 'gdx-pandas', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Extension configuration ------------------------------------------------- + +autoclass_content = 'both' +autodoc_member_order = 'bysource' +# Uncomment when https://github.com/sphinx-doc/sphinx/pull/4076 is +# released. +#autodoc_special_members = ['__getitem__', '__setitem__','__iter__'] +numpy_show_class_member = True diff --git a/gdxpds/__init__.py b/gdxpds/__init__.py index 875818e..3f22646 100644 --- a/gdxpds/__init__.py +++ b/gdxpds/__init__.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] __author__ = "Elaine T. Hale" __email__ = "elaine.hale@nrel.gov" diff --git a/gdxpds/_version.py b/gdxpds/_version.py index eb04a28..222a4c1 100644 --- a/gdxpds/_version.py +++ b/gdxpds/_version.py @@ -1,3 +1 @@ -''' -''' -__version__ = "1.0.5" +__version__ = "1.0.5" \ No newline at end of file diff --git a/gdxpds/gdx.py b/gdxpds/gdx.py index 01e84ff..8486d6f 100644 --- a/gdxpds/gdx.py +++ b/gdxpds/gdx.py @@ -1,5 +1,41 @@ -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] +''' Backend functionality for reading and writing GDX files. The GdxFile and GdxSymbol classes are full-featured interfaces for going between the GDX format and pandas DataFrames, diff --git a/gdxpds/read_gdx.py b/gdxpds/read_gdx.py index a7b241c..7bdbe0f 100644 --- a/gdxpds/read_gdx.py +++ b/gdxpds/read_gdx.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] from collections import OrderedDict import logging diff --git a/gdxpds/test/__init__.py b/gdxpds/test/__init__.py index d5b92a3..919c73d 100644 --- a/gdxpds/test/__init__.py +++ b/gdxpds/test/__init__.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] import os diff --git a/gdxpds/test/test_conversions.py b/gdxpds/test/test_conversions.py index dc03746..7432e74 100644 --- a/gdxpds/test/test_conversions.py +++ b/gdxpds/test/test_conversions.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] import os import subprocess as subp diff --git a/gdxpds/test/test_details.py b/gdxpds/test/test_details.py index b4e468e..f645106 100644 --- a/gdxpds/test/test_details.py +++ b/gdxpds/test/test_details.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] from ctypes import c_bool import copy diff --git a/gdxpds/test/test_read.py b/gdxpds/test/test_read.py index 83ee365..6e9d1b3 100644 --- a/gdxpds/test/test_read.py +++ b/gdxpds/test/test_read.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] import os diff --git a/gdxpds/test/test_session.py b/gdxpds/test/test_session.py index 982114d..e505e9c 100644 --- a/gdxpds/test/test_session.py +++ b/gdxpds/test/test_session.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] import os import shutil diff --git a/gdxpds/tools.py b/gdxpds/tools.py index 2c659f3..4b3f198 100644 --- a/gdxpds/tools.py +++ b/gdxpds/tools.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] import logging import os diff --git a/gdxpds/write_gdx.py b/gdxpds/write_gdx.py index 5059acc..3a11d7b 100644 --- a/gdxpds/write_gdx.py +++ b/gdxpds/write_gdx.py @@ -1,5 +1,39 @@ -''' -''' +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] import logging from numbers import Number diff --git a/setup.py b/setup.py index c288ca8..84bea7c 100644 --- a/setup.py +++ b/setup.py @@ -1,28 +1,62 @@ -''' -''' - -from distutils.core import setup -import os - -here = os.path.abspath(os.path.dirname(__file__)) - -with open(os.path.join(here, 'gdxpds', '_version.py'), encoding='utf-8') as f: - version = f.read() - -version = version.split()[2].strip('"').strip("'") - -setup( - name = 'gdxpds', - version = version, - author = 'Elaine T. Hale', - author_email = 'elaine.hale@nrel.gov', - packages = ['gdxpds', 'gdxpds.test'], - scripts = ['bin/csv_to_gdx.py', 'bin/gdx_to_csv.py'], - url = 'https://github.com/NREL/gdx-pandas', - description = 'Python package to translate between gdx (GAMS data) and pandas.', - long_description=open('README.txt').read(), - package_data={ - 'gdxpds.test': ['*.csv','*.gdx'] - }, - install_requires=open('requirements.txt').read() -) +# [LICENSE] +# Copyright (c) 2018, Alliance for Sustainable Energy. +# All rights reserved. +# +# Redistribution and use in source and binary forms, +# with or without modification, are permitted provided +# that the following conditions are met: +# +# 1. Redistributions of source code must retain the above +# copyright notice, this list of conditions and the +# following disclaimer. +# +# 2. Redistributions in binary form must reproduce the +# above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other +# materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or +# promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# [/LICENSE] + +from distutils.core import setup +import os + +here = os.path.abspath(os.path.dirname(__file__)) + +with open(os.path.join(here, 'gdxpds', '_version.py'), encoding='utf-8') as f: + version = f.read() + +version = version.split()[2].strip('"').strip("'") + +setup( + name = 'gdxpds', + version = version, + author = 'Elaine T. Hale', + author_email = 'elaine.hale@nrel.gov', + packages = ['gdxpds', 'gdxpds.test'], + scripts = ['bin/csv_to_gdx.py', 'bin/gdx_to_csv.py'], + url = 'https://github.com/NREL/gdx-pandas', + description = 'Python package to translate between gdx (GAMS data) and pandas.', + long_description=open('README.txt').read(), + package_data={ + 'gdxpds.test': ['*.csv','*.gdx'] + }, + install_requires=open('requirements.txt').read() +) From 84181841b95063f029eb1f6908e091db7c8f9998 Mon Sep 17 00:00:00 2001 From: Elaine Hale Date: Tue, 9 Oct 2018 13:33:34 -0600 Subject: [PATCH 3/3] Can make real docs now (API and overview). --- CHANGES.txt | 5 ++ README.md | 112 ++----------------------------- dev/README.md | 89 +++++++++++++++++++++++-- dev/md_to_rst.py | 66 +++++++++++++++++++ dev/requirements.txt | 7 +- doc/source/api.rst | 7 ++ doc/source/api/gdxpds.rst | 53 +++++++++++++++ doc/source/api/gdxpds.test.rst | 46 +++++++++++++ doc/source/api/modules.rst | 7 ++ doc/source/index.md | 7 ++ doc/source/index.postfix | 12 ++++ doc/source/index.rst | 21 +++--- doc/source/md_files.txt | 2 + doc/source/overview.md | 108 ++++++++++++++++++++++++++++++ doc/source/overview.postfix | 0 doc/source/overview.rst | 117 +++++++++++++++++++++++++++++++++ gdxpds/_version.py | 2 +- 17 files changed, 539 insertions(+), 122 deletions(-) create mode 100644 dev/md_to_rst.py create mode 100644 doc/source/api.rst create mode 100644 doc/source/api/gdxpds.rst create mode 100644 doc/source/api/gdxpds.test.rst create mode 100644 doc/source/api/modules.rst create mode 100644 doc/source/index.md create mode 100644 doc/source/index.postfix create mode 100644 doc/source/md_files.txt create mode 100644 doc/source/overview.md create mode 100644 doc/source/overview.postfix create mode 100644 doc/source/overview.rst diff --git a/CHANGES.txt b/CHANGES.txt index f6239a6..0ce7301 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +v1.1.0, 10/09/18 -- fixes to_dataframes and to_gdx memory leaks, respects + GAMS_DIR environment variable, additional bug and warning + fixes. GdxSymbol.dataframe can now be set just using the + GdxSymbol.dims columns; in that case the value columns are + filled in with defaults v1.0.4, 03/02/18 -- make sure set 'Value' column fix works even when dims are all named '*' v1.0.3, 02/15/18 -- fix up set 'Value' column when write to GDX v1.0.2, 01/19/18 -- instructions and additional filepaths for running pytest on diff --git a/README.md b/README.md index 8b221d3..aeac0e5 100644 --- a/README.md +++ b/README.md @@ -1,112 +1,10 @@ # gdx-pandas [![PyPI](https://img.shields.io/pypi/v/gdxpds.svg)](https://pypi.python.org/pypi/gdxpds/) +[![Documentation](https://img.shields.io/badge/docs-ready-blue.svg)](http://nrel.github.io/gdx-pandas) -Python package to translate between gdx (GAMS data) and pandas. +gdx-pandas is a python package to translate between gdx (GAMS data) and pandas. -[Install](#install) | [Use](#use) | [Uninstall](#uninstall) - -## Use - -There are two main ways to use gdxpds. The first use case is the one that was -initially supported: direct conversion between GDX files on disk and pandas -DataFrames or a csv version thereof. The Version 1.0.0 rewrite intoduces a -second style of use, that is, interfacing with GDX files and symbols via the -`gdxpds.gdx.GdxFile` and `gdxpds.gdx.GdxSymbol` classes. - -[Direct Conversion](#direct-conversion) | [Backend Classes](#backend-classes) - -### Direct Conversion - -The two primary points of reference for the direct conversion utilities are GDX -files on disk and python dicts of {symbol_name: pandas.DataFrame}, where -each pandas.DataFrame contains data for a single set, parameter, equation, or -variable. For sets and parameters, the last column of the DataFrame is assumed to -contain the value of the element, which for sets should be `True`, and for -parameters should be a `float` (or one of the `gdxpds.gdx.NUMPY_SPECIAL_VALUES`). -Equations and variables have additional 'value' columns, in particular a level, -a marginal value, a lower bound, an upper bound, and a scale, as enumerated in -`gdxpds.gdx.GamsValueType`. These values are all assumed to be found in the last -five columns of the DataFrame, also see `gdxpds.gdx.GAMS_VALUE_COLS_MAP`. - -The basic interface to convert from GDX to DataFrames is: - -```python -import gdxpds - -gdx_file = 'C:\path_to_my_gdx\data.gdx' -dataframes = gdxpds.to_dataframes(gdx_file) -for symbol_name, df in dataframes.items(): - print("Doing work with {}.".format(symbol_name)) -``` - -And vice-versa: - -```python -import gdxpds - -# assume we have a DataFrame df with last column 'value' -data_ready_for_GAMS = { 'symbol_name': df } - -gdx_file = 'C:\path_to_my_output_gdx\data_to_send_to_gams.gdx' -gdx = gdxpds.to_gdx(data_ready_for_GAMS, gdx_file) -``` - -Note that providing a gdx_file is optional, and the returned gdx is an object of -type `gdxpds.gdx.GdxFile`. - -Additional functions include: - -- `gdxpds.list_symbols` -- `gdxpds.to_dataframe` (If the call to this method includes - old_interface=False, then the return value will be a plain DataFrame, not a - {'symbol_name': df} dict.) - -The package also includes command line utilities for converting between GDX and -CSV, see - -```bash -python C:\your_python_path\Scripts\gdx_to_csv.py --help -python C:\your_python_path\Scripts\csv_to_gdx.py --help -``` - -### Backend Classes - -The basic functionalities described above can also be achieved with direct use -of the backend classes now available in `gdxpds.gdx`. To duplicate the GDX read -functionality shown above one would write: - -```python -import gdxpds - -gdx_file = 'C:\path_to_my_gdx\data.gdx' -with gdxpds.gdx.GdxFile(lazy_load=False) as f: - f.read(gdx_file) - for symbol in f: - symbol_name = symbol.name - df = symbol.dataframe - print("Doing work with {}:\n{}".format(symbol_name,df.head())) -``` - -The backend especially gives more control over creating new data in GDX format. -For example: - -```python -import gdxpds - -out_file = 'my_new_gdx_data.gdx' -with gdxpds.gdx.GdxFile() as gdx: - # Create a new set with one dimension - gdx.append(gdxpds.gdx.GdxSymbol('my_set',gdxpds.gdx.GamsDataType.Set,dims=['u'])) - data = pds.DataFrame([['u' + str(i)] for i in range(1,11)]) - data['Value'] = True - gdx[-1].dataframe = data - # Create a new parameter with one dimension - gdx.append(gdxpds.gdx.GdxSymbol('my_parameter',gdxpds.gdx.GamsDataType.Parameter,dims=['u'])) - data = pds.DataFrame([['u' + str(i), i*100] for i in range(1,11)], - columns=(gdx[-1].dims + gdx[-1].value_col_names)) - gdx[-1].dataframe = data - gdx.write(out_file) -``` +[Install](#install) | [Uninstall](#uninstall) ## Install @@ -115,8 +13,6 @@ with gdxpds.gdx.GdxFile() as gdx: - Python 2.6 or higher 2.X; Python 3.4 or higher 3.X - pandas (In general you will want the SciPy stack. Anaconda comes with it, or see [my notes for Windows](http://elainethale.wordpress.com/programming-notes/python-environment-set-up/).) - For Python versions < 3.4, enum34. Also **uninstall the enum package** if it is installed. -- psutil (optional--for monitoring memory use) -- pytest (optional--for running tests) - GAMS Python bindings - See GAMS/win64/XX.X/apifiles/readme.txt on Windows, GAMS/gamsXX.X_osx_x64_64_sfx/apifiles/readme.txt on Mac, or @@ -151,7 +47,7 @@ pip install gdxpds or ```bash -pip install git+https://github.com/NREL/gdx-pandas.git@v1.0.4 +pip install git+https://github.com/NREL/gdx-pandas.git@v1.1.0 ``` or diff --git a/dev/README.md b/dev/README.md index 6b15118..942fb5a 100644 --- a/dev/README.md +++ b/dev/README.md @@ -1,15 +1,96 @@ # Developer How-To +To get all of the development dependencies for Python: + +``` +pip install -r layerstack/dev/requirements.txt +``` + +Also, you will need to install + +- [pandoc](https://pandoc.org/installing.html) + ## Create a new release -- Make the release on github -- Install from github and make sure tests pass -- Create package and push to pypi: +1. Update version number, CHANGES.txt, setup.py, LICENSE and header as needed +2. Run tests locally and fix any issues +3. Install from github and make sure tests pass +4. Uninstall the draft package +5. Publish documentation +6. Create release on github +7. Release tagged version on pypi + +## Publish documentation + +The documentation is built with [Sphinx](http://sphinx-doc.org/index.html). There are several steps to creating and publishing the documentation: + +1. Convert .md input files to .rst +2. Refresh API documentation +3. Build the HTML docs +4. Push to GitHub + +### Markdown to reStructuredText + +Markdown files are registered in `docs/source/md_files.txt`. Paths in that file should be relative to the docs folder and should exclude the file extension. For every file listed there, the `dev/md_to_rst.py` utility will expect to find a markdown (`.md`) file, and will look for an optional `.postfix` file, which is expected to contain `.rst` code to be appended to the `.rst` file created by converting the input `.md` file. Thus, running `dev/md_to_rst.py` on the `doc/source/md_files.txt` file will create revised `.rst` files, one for each entry listed in the registry. In summary: + +``` +cd doc/source +python ../../dev/md_to_rst.py md_files.txt +``` + +### Refresh API Documentation + +- Make sure layerstack is in your PYTHONPATH +- Delete the contents of `source/api`. +- Run `sphinx-apidoc -o source/api ..` from the `doc` folder. +- Compare `source/api/modules.rst` to `source/api.rst`. Delete `setup.rst` and references to it. +- 'git push' changes to the documentation source code as needed. +- Make the documentation per below + +### Building HTML Docs + +Run `make html` for Mac and Linux; `make.bat html` for Windows. + +### Pushing to GitHub Pages + +#### Mac/Linux + +``` +make github +``` + +#### Windows + +``` +make.bat html +``` + +Then run the github-related commands by hand: + +``` +git branch -D gh-pages +git push origin --delete gh-pages +ghp-import -n -b gh-pages -m "Update documentation" ./build/html +git checkout gh-pages +git push origin gh-pages +git checkout master # or whatever branch you were on +``` + +## Release on pypi + +1. [using testpyi](https://packaging.python.org/guides/using-testpypi/) has good instructions for setting up your user account on TestPyPI and PyPI, and configuring twine to know how to access both repositories. +2. Test the package ``` python setup.py sdist twine upload --repository testpypi dist/* # look at https://test.pypi.org/project/gdxpds/ + pip install --index-url https://test.pypi.org/simple/gdxpds + # check it out ... fix things ... + ``` + +3. Upload to pypi + + ``` twine upload --repository pypi dist/* ``` - \ No newline at end of file diff --git a/dev/md_to_rst.py b/dev/md_to_rst.py new file mode 100644 index 0000000..25f53f1 --- /dev/null +++ b/dev/md_to_rst.py @@ -0,0 +1,66 @@ +import argparse +import logging +import os +from subprocess import call, list2cmdline + +from layerstack import start_console_log + +logger = logging.getLogger(__name__) + +def convert_files(file_registry): + # registry is expected to contain paths relative to its location + base_path = os.path.dirname(file_registry) + + if not os.path.exists(file_registry): + raise ValueError("File registry {} not found".format(file_registry)) + + # loop through registry of md files + with open(file_registry,'r') as registry: + for line in registry: + if line: + # non-empty + p = os.path.join(base_path,line.strip()) + p_md = p + '.md' + if not os.path.exists(p_md): + raise ValueError("There is no {} file.".format(p_md)) + # run pandoc + p_rst = p + '.rst' + try: + cmd_and_args = ['pandoc',p_md,'-o',p_rst] + call(cmd_and_args) + except Exception as e: + try: + call(['pandoc']) + except: + logger.error("Call to pandoc fails") + raise e + if not os.path.exists(p_md): + logger.error("Input file {} does not exist".format(p_md)) + raise e + logger.error("Call '{}' failed".format(list2cmdline(cmd_and_args))) + raise e + # append .postfix + p_postfix = p + '.postfix' + if os.path.exists(p_postfix): + with open(p_rst,'a') as rst: + rst.write("\n") + with open(p_postfix,'r') as postfix: + rst.write(postfix.read()) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="""Utility to convert Markdown + (.md) files to reStructuredText (.rst)""") + parser.add_argument('file_registry',help="""Text file that lists the + markdown files to convert. Each line is the file path and name for an + .md file, where the path is relative to the location of file_registry, + and the .md extension is omitted.""") + parser.add_argument("-d","--debug",action='store_true',default=False, + help="Option to output debug information.") + + args = parser.parse_args() + + # start logging + start_console_log(log_level=logging.DEBUG if args.debug else logging.INFO) + + # perform conversion + convert_files(args.file_registry) diff --git a/dev/requirements.txt b/dev/requirements.txt index f1bf77a..72873f1 100644 --- a/dev/requirements.txt +++ b/dev/requirements.txt @@ -1,2 +1,7 @@ -sphinx +ghp-import +numpydoc pandoc +pytest +sphinx +sphinx_rtd_theme +twine diff --git a/doc/source/api.rst b/doc/source/api.rst new file mode 100644 index 0000000..12fb6c4 --- /dev/null +++ b/doc/source/api.rst @@ -0,0 +1,7 @@ +API +### + +.. toctree:: + :maxdepth: 4 + + api/gdxpds diff --git a/doc/source/api/gdxpds.rst b/doc/source/api/gdxpds.rst new file mode 100644 index 0000000..2addfac --- /dev/null +++ b/doc/source/api/gdxpds.rst @@ -0,0 +1,53 @@ +gdxpds package +============== + +Subpackages +----------- + +.. toctree:: + + gdxpds.test + +Submodules +---------- + +gdxpds.gdx module +----------------- + +.. automodule:: gdxpds.gdx + :members: + :undoc-members: + :show-inheritance: + +gdxpds.read\_gdx module +----------------------- + +.. automodule:: gdxpds.read_gdx + :members: + :undoc-members: + :show-inheritance: + +gdxpds.tools module +------------------- + +.. automodule:: gdxpds.tools + :members: + :undoc-members: + :show-inheritance: + +gdxpds.write\_gdx module +------------------------ + +.. automodule:: gdxpds.write_gdx + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: gdxpds + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/gdxpds.test.rst b/doc/source/api/gdxpds.test.rst new file mode 100644 index 0000000..29166c0 --- /dev/null +++ b/doc/source/api/gdxpds.test.rst @@ -0,0 +1,46 @@ +gdxpds.test package +=================== + +Submodules +---------- + +gdxpds.test.test\_conversions module +------------------------------------ + +.. automodule:: gdxpds.test.test_conversions + :members: + :undoc-members: + :show-inheritance: + +gdxpds.test.test\_details module +-------------------------------- + +.. automodule:: gdxpds.test.test_details + :members: + :undoc-members: + :show-inheritance: + +gdxpds.test.test\_read module +----------------------------- + +.. automodule:: gdxpds.test.test_read + :members: + :undoc-members: + :show-inheritance: + +gdxpds.test.test\_session module +-------------------------------- + +.. automodule:: gdxpds.test.test_session + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: gdxpds.test + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/modules.rst b/doc/source/api/modules.rst new file mode 100644 index 0000000..5262598 --- /dev/null +++ b/doc/source/api/modules.rst @@ -0,0 +1,7 @@ +gdx-pandas +========== + +.. toctree:: + :maxdepth: 4 + + gdxpds diff --git a/doc/source/index.md b/doc/source/index.md new file mode 100644 index 0000000..8487dcb --- /dev/null +++ b/doc/source/index.md @@ -0,0 +1,7 @@ +gdx-pandas documentation +======================== + +[![PyPI](https://img.shields.io/pypi/v/gdxpds.svg)](https://pypi.python.org/pypi/gdxpds/) +[![Documentation](https://img.shields.io/badge/docs-ready-blue.svg)](http://nrel.github.io/gdx-pandas) + +gdx-pandas is a python package to translate between gdx (GAMS data) and pandas. diff --git a/doc/source/index.postfix b/doc/source/index.postfix new file mode 100644 index 0000000..6373eef --- /dev/null +++ b/doc/source/index.postfix @@ -0,0 +1,12 @@ +.. toctree:: + :maxdepth: 2 + + overview + api + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/doc/source/index.rst b/doc/source/index.rst index fd227ea..3dcefd8 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -1,16 +1,21 @@ -.. gdx-pandas documentation master file, created by - sphinx-quickstart on Mon Apr 2 20:51:20 2018. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +gdx-pandas documentation +======================== -Welcome to gdx-pandas's documentation! -====================================== +|PyPI| |Documentation| + +gdx-pandas is a python package to translate between gdx (GAMS data) and +pandas. + +.. |PyPI| image:: https://img.shields.io/pypi/v/gdxpds.svg + :target: https://pypi.python.org/pypi/gdxpds/ +.. |Documentation| image:: https://img.shields.io/badge/docs-ready-blue.svg + :target: http://nrel.github.io/gdx-pandas .. toctree:: :maxdepth: 2 - :caption: Contents: - + overview + api Indices and tables ================== diff --git a/doc/source/md_files.txt b/doc/source/md_files.txt new file mode 100644 index 0000000..b20cee4 --- /dev/null +++ b/doc/source/md_files.txt @@ -0,0 +1,2 @@ +index +overview diff --git a/doc/source/overview.md b/doc/source/overview.md new file mode 100644 index 0000000..38123f3 --- /dev/null +++ b/doc/source/overview.md @@ -0,0 +1,108 @@ +# gdx-pandas overview + +There are two main ways to use gdxpds. The first use case is the one that was +initially supported: direct conversion between GDX files on disk and pandas +DataFrames or a csv version thereof. Starting with the Version 1.0.0 rewrite, +there is now a second style of use which involves interfacing with GDX files and +symbols via the `gdxpds.gdx.GdxFile` and `gdxpds.gdx.GdxSymbol` classes. + +[Direct Conversion](#direct-conversion) | [Backend Classes](#backend-classes) + +### Direct Conversion + +The two primary points of reference for the direct conversion utilities are GDX +files on disk and python dicts of {symbol_name: pandas.DataFrame}, where +each pandas.DataFrame contains data for a single set, parameter, equation, or +variable. For sets and parameters, the last column of the DataFrame is assumed to +contain the value of the element, which for sets should be `True`, and for +parameters should be a `float` (or one of the `gdxpds.gdx.NUMPY_SPECIAL_VALUES`). +Equations and variables have additional 'value' columns, in particular a level, +a marginal value, a lower bound, an upper bound, and a scale, as enumerated in +`gdxpds.gdx.GamsValueType`. These values are all assumed to be found in the last +five columns of the DataFrame, also see `gdxpds.gdx.GAMS_VALUE_COLS_MAP`. + +The basic interface to convert from GDX to DataFrames is: + +```python +import gdxpds + +gdx_file = 'C:\path_to_my_gdx\data.gdx' +dataframes = gdxpds.to_dataframes(gdx_file) +for symbol_name, df in dataframes.items(): + print("Doing work with {}.".format(symbol_name)) +``` + +And vice-versa: + +```python +import gdxpds + +# assume we have a DataFrame df with last column 'value' +data_ready_for_GAMS = { 'symbol_name': df } + +gdx_file = 'C:\path_to_my_output_gdx\data_to_send_to_gams.gdx' +gdx = gdxpds.to_gdx(data_ready_for_GAMS, gdx_file) +``` + +Note that providing a gdx_file is optional, and the returned gdx is an object of +type `gdxpds.gdx.GdxFile`. + +Additional functions include: + +- `gdxpds.list_symbols` +- `gdxpds.to_dataframe` (If the call to this method includes + old_interface=False, then the return value will be a plain DataFrame, not a + {'symbol_name': df} dict.) + +The package also includes command line utilities for converting between GDX and +CSV, see + +```bash +python C:\your_python_path\Scripts\gdx_to_csv.py --help +python C:\your_python_path\Scripts\csv_to_gdx.py --help +``` + +### Backend Classes + +The basic functionalities described above can also be achieved with direct use +of the backend classes now available in `gdxpds.gdx`. To duplicate the GDX read +functionality shown above one would write: + +```python +import gdxpds + +gdx_file = 'C:\path_to_my_gdx\data.gdx' +with gdxpds.gdx.GdxFile(lazy_load=False) as f: + f.read(gdx_file) + for symbol in f: + symbol_name = symbol.name + df = symbol.dataframe + print("Doing work with {}:\n{}".format(symbol_name,df.head())) +``` + +The backend especially gives more control over creating new data in GDX format. +For example: + +```python +import gdxpds + +out_file = 'my_new_gdx_data.gdx' +with gdxpds.gdx.GdxFile() as gdx: + # Create a new set with one dimension + gdx.append(gdxpds.gdx.GdxSymbol('my_set',gdxpds.gdx.GamsDataType.Set,dims=['u'])) + data = pds.DataFrame([['u' + str(i)] for i in range(1,11)]) + data['Value'] = True + gdx[-1].dataframe = data + # Create a new parameter with one dimension + gdx.append(gdxpds.gdx.GdxSymbol('my_parameter',gdxpds.gdx.GamsDataType.Parameter,dims=['u'])) + data = pds.DataFrame([['u' + str(i), i*100] for i in range(1,11)], + columns=(gdx[-1].dims + gdx[-1].value_col_names)) + gdx[-1].dataframe = data + gdx.write(out_file) +``` + +Starting with Version 1.1.0, gdxpds does not allow GdxSymbol.dims to change once +they have been firmly established (as evidenced by GdxSymbol.num_dims > 0 or +GdxSymbol.num_records > 0), but does allow GdxSymbol.dataframe to be set using +the dimensional columns alone. In that use case, GdxSymbol fills in the +remaining dataframe columns with default values. diff --git a/doc/source/overview.postfix b/doc/source/overview.postfix new file mode 100644 index 0000000..e69de29 diff --git a/doc/source/overview.rst b/doc/source/overview.rst new file mode 100644 index 0000000..26d5b54 --- /dev/null +++ b/doc/source/overview.rst @@ -0,0 +1,117 @@ +gdx-pandas overview +=================== + +There are two main ways to use gdxpds. The first use case is the one +that was initially supported: direct conversion between GDX files on +disk and pandas DataFrames or a csv version thereof. Starting with the +Version 1.0.0 rewrite, there is now a second style of use which involves +interfacing with GDX files and symbols via the ``gdxpds.gdx.GdxFile`` +and ``gdxpds.gdx.GdxSymbol`` classes. + +`Direct Conversion <#direct-conversion>`__ \| `Backend +Classes <#backend-classes>`__ + +Direct Conversion +~~~~~~~~~~~~~~~~~ + +The two primary points of reference for the direct conversion utilities +are GDX files on disk and python dicts of {symbol_name: +pandas.DataFrame}, where each pandas.DataFrame contains data for a +single set, parameter, equation, or variable. For sets and parameters, +the last column of the DataFrame is assumed to contain the value of the +element, which for sets should be ``True``, and for parameters should be +a ``float`` (or one of the ``gdxpds.gdx.NUMPY_SPECIAL_VALUES``). +Equations and variables have additional ‘value’ columns, in particular a +level, a marginal value, a lower bound, an upper bound, and a scale, as +enumerated in ``gdxpds.gdx.GamsValueType``. These values are all assumed +to be found in the last five columns of the DataFrame, also see +``gdxpds.gdx.GAMS_VALUE_COLS_MAP``. + +The basic interface to convert from GDX to DataFrames is: + +.. code:: python + + import gdxpds + + gdx_file = 'C:\path_to_my_gdx\data.gdx' + dataframes = gdxpds.to_dataframes(gdx_file) + for symbol_name, df in dataframes.items(): + print("Doing work with {}.".format(symbol_name)) + +And vice-versa: + +.. code:: python + + import gdxpds + + # assume we have a DataFrame df with last column 'value' + data_ready_for_GAMS = { 'symbol_name': df } + + gdx_file = 'C:\path_to_my_output_gdx\data_to_send_to_gams.gdx' + gdx = gdxpds.to_gdx(data_ready_for_GAMS, gdx_file) + +Note that providing a gdx_file is optional, and the returned gdx is an +object of type ``gdxpds.gdx.GdxFile``. + +Additional functions include: + +- ``gdxpds.list_symbols`` +- ``gdxpds.to_dataframe`` (If the call to this method includes + old_interface=False, then the return value will be a plain DataFrame, + not a {‘symbol_name’: df} dict.) + +The package also includes command line utilities for converting between +GDX and CSV, see + +.. code:: bash + + python C:\your_python_path\Scripts\gdx_to_csv.py --help + python C:\your_python_path\Scripts\csv_to_gdx.py --help + +Backend Classes +~~~~~~~~~~~~~~~ + +The basic functionalities described above can also be achieved with +direct use of the backend classes now available in ``gdxpds.gdx``. To +duplicate the GDX read functionality shown above one would write: + +.. code:: python + + import gdxpds + + gdx_file = 'C:\path_to_my_gdx\data.gdx' + with gdxpds.gdx.GdxFile(lazy_load=False) as f: + f.read(gdx_file) + for symbol in f: + symbol_name = symbol.name + df = symbol.dataframe + print("Doing work with {}:\n{}".format(symbol_name,df.head())) + +The backend especially gives more control over creating new data in GDX +format. For example: + +.. code:: python + + import gdxpds + + out_file = 'my_new_gdx_data.gdx' + with gdxpds.gdx.GdxFile() as gdx: + # Create a new set with one dimension + gdx.append(gdxpds.gdx.GdxSymbol('my_set',gdxpds.gdx.GamsDataType.Set,dims=['u'])) + data = pds.DataFrame([['u' + str(i)] for i in range(1,11)]) + data['Value'] = True + gdx[-1].dataframe = data + # Create a new parameter with one dimension + gdx.append(gdxpds.gdx.GdxSymbol('my_parameter',gdxpds.gdx.GamsDataType.Parameter,dims=['u'])) + data = pds.DataFrame([['u' + str(i), i*100] for i in range(1,11)], + columns=(gdx[-1].dims + gdx[-1].value_col_names)) + gdx[-1].dataframe = data + gdx.write(out_file) + +Starting with Version 1.1.0, gdxpds does not allow GdxSymbol.dims to +change once they have been firmly established (as evidenced by +GdxSymbol.num_dims > 0 or GdxSymbol.num_records > 0), but does allow +GdxSymbol.dataframe to be set using the dimensional columns alone. In +that use case, GdxSymbol fills in the remaining dataframe columns with +default values. + diff --git a/gdxpds/_version.py b/gdxpds/_version.py index 222a4c1..ff1068c 100644 --- a/gdxpds/_version.py +++ b/gdxpds/_version.py @@ -1 +1 @@ -__version__ = "1.0.5" \ No newline at end of file +__version__ = "1.1.0" \ No newline at end of file