Skip to content

Commit 6c50426

Browse files
authored
Potential fix for issue 156 (#157)
* Potential fix for issue 156 * lint errors
1 parent ff5b9f9 commit 6c50426

File tree

5 files changed

+134
-112
lines changed

5 files changed

+134
-112
lines changed

docs/conf.py

Lines changed: 85 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,47 @@
1919
# If extensions (or modules to document with autodoc) are in another directory,
2020
# add these directories to sys.path here. If the directory is relative to the
2121
# documentation root, use os.path.abspath to make it absolute, like shown here.
22-
#sys.path.insert(0, os.path.abspath('.'))
22+
# sys.path.insert(0, os.path.abspath('.'))
2323

2424
# -- General configuration ------------------------------------------------
2525

2626
# If your documentation needs a minimal Sphinx version, state it here.
27-
#needs_sphinx = '1.3'
27+
# needs_sphinx = '1.3'
2828

2929
# Add any Sphinx extension module names here, as strings. They can be
3030
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3131
# ones.
3232
extensions = [
33-
'sphinx.ext.autodoc',
34-
'sphinx.ext.coverage',
35-
'sphinx.ext.viewcode',
33+
"sphinx.ext.autodoc",
34+
"sphinx.ext.coverage",
35+
"sphinx.ext.viewcode",
3636
]
3737

3838
# Add any paths that contain templates here, relative to this directory.
39-
templates_path = ['_templates']
39+
templates_path = ["_templates"]
4040

4141
# The suffix(es) of source filenames.
42-
source_suffix = '.rst'
42+
source_suffix = ".rst"
4343

4444
# The encoding of source files.
45-
#source_encoding = 'utf-8-sig'
45+
# source_encoding = 'utf-8-sig'
4646

4747
# The master toctree document.
48-
master_doc = 'index'
48+
master_doc = "index"
4949

5050
# General information about the project.
51-
project = u'PyFunctional'
52-
copyright = u'2019, Pedro Rodriguez'
53-
author = u'Pedro Rodriguez'
51+
project = u"PyFunctional"
52+
copyright = u"2019, Pedro Rodriguez"
53+
author = u"Pedro Rodriguez"
5454

5555
# The version info for the project you're documenting, acts as replacement for
5656
# |version| and |release|, also used in various other places throughout the
5757
# built documents.
5858
#
5959
# The short X.Y version.
60-
version = '1.3'
60+
version = "1.3"
6161
# The full version, including alpha/beta/rc tags.
62-
release = '1.3.0'
62+
release = "1.3.0"
6363

6464
# The language for content autogenerated by Sphinx. Refer to documentation
6565
# for a list of supported languages.
@@ -70,37 +70,37 @@
7070

7171
# There are two options for replacing |today|: either, you set today to some
7272
# non-false value, then it is used:
73-
#today = ''
73+
# today = ''
7474
# Else, today_fmt is used as the format for a strftime call.
75-
#today_fmt = '%B %d, %Y'
75+
# today_fmt = '%B %d, %Y'
7676

7777
# List of patterns, relative to source directory, that match files and
7878
# directories to ignore when looking for source files.
79-
exclude_patterns = ['_build']
79+
exclude_patterns = ["_build"]
8080

8181
# The reST default role (used for this markup: `text`) to use for all
8282
# documents.
83-
#default_role = None
83+
# default_role = None
8484

8585
# If true, '()' will be appended to :func: etc. cross-reference text.
86-
#add_function_parentheses = True
86+
# add_function_parentheses = True
8787

8888
# If true, the current module name will be prepended to all description
8989
# unit titles (such as .. function::).
90-
#add_module_names = True
90+
# add_module_names = True
9191

9292
# If true, sectionauthor and moduleauthor directives will be shown in the
9393
# output. They are ignored by default.
94-
#show_authors = False
94+
# show_authors = False
9595

9696
# The name of the Pygments (syntax highlighting) style to use.
97-
pygments_style = 'sphinx'
97+
pygments_style = "sphinx"
9898

9999
# A list of ignored prefixes for module index sorting.
100-
#modindex_common_prefix = []
100+
# modindex_common_prefix = []
101101

102102
# If true, keep warnings as "system message" paragraphs in the built documents.
103-
#keep_warnings = False
103+
# keep_warnings = False
104104

105105
# If true, `todo` and `todoList` produce output, else they produce nothing.
106106
todo_include_todos = False
@@ -110,156 +110,155 @@
110110

111111
# The theme to use for HTML and HTML Help pages. See the documentation for
112112
# a list of builtin themes.
113-
html_theme = 'default'
113+
html_theme = "default"
114114

115115
# Theme options are theme-specific and customize the look and feel of a theme
116116
# further. For a list of options available for each theme, see the
117117
# documentation.
118-
#html_theme_options = {}
118+
# html_theme_options = {}
119119

120120
# Add any paths that contain custom themes here, relative to this directory.
121-
#html_theme_path = []
121+
# html_theme_path = []
122122

123123
# The name for this set of Sphinx documents. If None, it defaults to
124124
# "<project> v<release> documentation".
125-
#html_title = None
125+
# html_title = None
126126

127127
# A shorter title for the navigation bar. Default is the same as html_title.
128-
#html_short_title = None
128+
# html_short_title = None
129129

130130
# The name of an image file (relative to this directory) to place at the top
131131
# of the sidebar.
132-
#html_logo = None
132+
# html_logo = None
133133

134134
# The name of an image file (within the static path) to use as favicon of the
135135
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
136136
# pixels large.
137-
#html_favicon = None
137+
# html_favicon = None
138138

139139
# Add any paths that contain custom static files (such as style sheets) here,
140140
# relative to this directory. They are copied after the builtin static files,
141141
# so a file named "default.css" will overwrite the builtin "default.css".
142-
html_static_path = ['_static']
142+
html_static_path = ["_static"]
143143

144144
# Add any extra paths that contain custom files (such as robots.txt or
145145
# .htaccess) here, relative to this directory. These files are copied
146146
# directly to the root of the documentation.
147-
#html_extra_path = []
147+
# html_extra_path = []
148148

149149
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
150150
# using the given strftime format.
151-
#html_last_updated_fmt = '%b %d, %Y'
151+
# html_last_updated_fmt = '%b %d, %Y'
152152

153153
# If true, SmartyPants will be used to convert quotes and dashes to
154154
# typographically correct entities.
155-
#html_use_smartypants = True
155+
# html_use_smartypants = True
156156

157157
# Custom sidebar templates, maps document names to template names.
158-
#html_sidebars = {}
158+
# html_sidebars = {}
159159

160160
# Additional templates that should be rendered to pages, maps page names to
161161
# template names.
162-
#html_additional_pages = {}
162+
# html_additional_pages = {}
163163

164164
# If false, no module index is generated.
165-
#html_domain_indices = True
165+
# html_domain_indices = True
166166

167167
# If false, no index is generated.
168-
#html_use_index = True
168+
# html_use_index = True
169169

170170
# If true, the index is split into individual pages for each letter.
171-
#html_split_index = False
171+
# html_split_index = False
172172

173173
# If true, links to the reST sources are added to the pages.
174-
#html_show_sourcelink = True
174+
# html_show_sourcelink = True
175175

176176
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
177-
#html_show_sphinx = True
177+
# html_show_sphinx = True
178178

179179
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
180-
#html_show_copyright = True
180+
# html_show_copyright = True
181181

182182
# If true, an OpenSearch description file will be output, and all pages will
183183
# contain a <link> tag referring to it. The value of this option must be the
184184
# base URL from which the finished HTML is served.
185-
#html_use_opensearch = ''
185+
# html_use_opensearch = ''
186186

187187
# This is the file name suffix for HTML files (e.g. ".xhtml").
188-
#html_file_suffix = None
188+
# html_file_suffix = None
189189

190190
# Language to be used for generating the HTML full-text search index.
191191
# Sphinx supports the following languages:
192192
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
193193
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
194-
#html_search_language = 'en'
194+
# html_search_language = 'en'
195195

196196
# A dictionary with options for the search language support, empty by default.
197197
# Now only 'ja' uses this config value
198-
#html_search_options = {'type': 'default'}
198+
# html_search_options = {'type': 'default'}
199199

200200
# The name of a javascript file (relative to the configuration directory) that
201201
# implements a search results scorer. If empty, the default will be used.
202-
#html_search_scorer = 'scorer.js'
202+
# html_search_scorer = 'scorer.js'
203203

204204
# Output file base name for HTML help builder.
205-
htmlhelp_basename = 'PyFunctionaldoc'
205+
htmlhelp_basename = "PyFunctionaldoc"
206206

207207
# -- Options for LaTeX output ---------------------------------------------
208208

209209
latex_elements = {
210-
# The paper size ('letterpaper' or 'a4paper').
211-
#'papersize': 'letterpaper',
212-
213-
# The font size ('10pt', '11pt' or '12pt').
214-
#'pointsize': '10pt',
215-
216-
# Additional stuff for the LaTeX preamble.
217-
#'preamble': '',
218-
219-
# Latex figure (float) alignment
220-
#'figure_align': 'htbp',
210+
# The paper size ('letterpaper' or 'a4paper').
211+
#'papersize': 'letterpaper',
212+
# The font size ('10pt', '11pt' or '12pt').
213+
#'pointsize': '10pt',
214+
# Additional stuff for the LaTeX preamble.
215+
#'preamble': '',
216+
# Latex figure (float) alignment
217+
#'figure_align': 'htbp',
221218
}
222219

223220
# Grouping the document tree into LaTeX files. List of tuples
224221
# (source start file, target name, title,
225222
# author, documentclass [howto, manual, or own class]).
226223
latex_documents = [
227-
(master_doc, 'PyFunctional.tex', u'PyFunctional Documentation',
228-
u'Pedro Rodriguez', 'manual'),
224+
(
225+
master_doc,
226+
"PyFunctional.tex",
227+
u"PyFunctional Documentation",
228+
u"Pedro Rodriguez",
229+
"manual",
230+
),
229231
]
230232

231233
# The name of an image file (relative to this directory) to place at the top of
232234
# the title page.
233-
#latex_logo = None
235+
# latex_logo = None
234236

235237
# For "manual" documents, if this is true, then toplevel headings are parts,
236238
# not chapters.
237-
#latex_use_parts = False
239+
# latex_use_parts = False
238240

239241
# If true, show page references after internal links.
240-
#latex_show_pagerefs = False
242+
# latex_show_pagerefs = False
241243

242244
# If true, show URL addresses after external links.
243-
#latex_show_urls = False
245+
# latex_show_urls = False
244246

245247
# Documents to append as an appendix to all manuals.
246-
#latex_appendices = []
248+
# latex_appendices = []
247249

248250
# If false, no module index is generated.
249-
#latex_domain_indices = True
251+
# latex_domain_indices = True
250252

251253

252254
# -- Options for manual page output ---------------------------------------
253255

254256
# One entry per manual page. List of tuples
255257
# (source start file, name, description, authors, manual section).
256-
man_pages = [
257-
(master_doc, 'pyfunctional', u'PyFunctional Documentation',
258-
[author], 1)
259-
]
258+
man_pages = [(master_doc, "pyfunctional", u"PyFunctional Documentation", [author], 1)]
260259

261260
# If true, show URL addresses after external links.
262-
#man_show_urls = False
261+
# man_show_urls = False
263262

264263

265264
# -- Options for Texinfo output -------------------------------------------
@@ -268,19 +267,25 @@
268267
# (source start file, target name, title, author,
269268
# dir menu entry, description, category)
270269
texinfo_documents = [
271-
(master_doc, 'PyFunctional', u'PyFunctional Documentation',
272-
author, 'PyFunctional', 'One line description of project.',
273-
'Miscellaneous'),
270+
(
271+
master_doc,
272+
"PyFunctional",
273+
u"PyFunctional Documentation",
274+
author,
275+
"PyFunctional",
276+
"One line description of project.",
277+
"Miscellaneous",
278+
),
274279
]
275280

276281
# Documents to append as an appendix to all manuals.
277-
#texinfo_appendices = []
282+
# texinfo_appendices = []
278283

279284
# If false, no module index is generated.
280-
#texinfo_domain_indices = True
285+
# texinfo_domain_indices = True
281286

282287
# How to display URL addresses: 'footnote', 'no', or 'inline'.
283-
#texinfo_show_urls = 'footnote'
288+
# texinfo_show_urls = 'footnote'
284289

285290
# If true, do not generate a @detailmenu in the "Top" node's menu.
286-
#texinfo_no_detailmenu = False
291+
# texinfo_no_detailmenu = False

functional/pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def drop_right(self, n):
393393
:param n: number of elements to drop
394394
:return: sequence with last n elements dropped
395395
"""
396-
return self._transform(transformations.CACHE_T, transformations.drop_right_t(n))
396+
return self._transform(transformations.drop_right_t(n))
397397

398398
def drop_while(self, func):
399399
"""

functional/test/test_functional.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ def test_drop_right(self):
211211
self.assertIteratorEqual(s.drop_right(0), s)
212212
self.assertIteratorEqual(s.drop_right(-1), s)
213213

214+
s = seq(1, 2, 3, 4, 5).filter(lambda x: x < 4)
215+
expect = [1, 2]
216+
result = s.drop_right(1)
217+
self.assert_type(result)
218+
self.assertIteratorEqual(result, expect)
219+
220+
s = seq(5, 4, 3, 2, 1).sorted()
221+
expect = [1, 2, 3]
222+
result = s.drop_right(2)
223+
self.assert_type(result)
224+
self.assertIteratorEqual(result, expect)
225+
214226
def test_drop_while(self):
215227
l = [1, 2, 3, 4, 5, 6, 7, 8]
216228
f = lambda x: x < 4

functional/transformations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ def drop_right_t(n):
207207
else:
208208
end_index = -n
209209
return Transformation(
210-
"drop_right({0})".format(n), lambda sequence: sequence[:end_index], None
210+
"drop_right({0})".format(n),
211+
lambda sequence: sequence[:end_index],
212+
[ExecutionStrategies.PRE_COMPUTE],
211213
)
212214

213215

0 commit comments

Comments
 (0)