Opened 11 years ago
Closed 11 years ago
#7313 closed enhancement (fixed)
search_doc does not find phrases across multiple lines
Reported by: | ncohen | Owned by: | tba |
---|---|---|---|
Priority: | minor | Milestone: | sage-4.3.3 |
Component: | documentation | Keywords: | |
Cc: | ddrake | Merged in: | sage-4.3.3.alpha0 |
Authors: | John Palmieri | Reviewers: | Ross Kyprianou, Mitesh Patel |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Hello !!!
Out of curiosity, I tried to look for a function I knew in Sage :
sage: search_doc("Floyd-Warshall") html/en/reference/sage/graphs/graph.html:5797:<dd><p>Uses the Floyd-Warshall algorithm to find a shortest weighted path sage: search_doc("Floyd-Warshall","pair") sage: Graph.shortest_path_all_pairs?
I understand the current way to look for things in the doc is to grep it, and that for some reason we may need to keep our lines short ( less than 80 characters or so ).. I also understand that finding another way to search the doc ( if there is none available already ) may be some big amount of work. Even though, this really isn't the expected behaviour of the function, and I think we should do something about it.
Nathann
Attachments (1)
Change History (9)
comment:1 Changed 11 years ago by
- Priority changed from critical to minor
- Summary changed from Very bad thing in the behaviour of search_doc to search_doc does not find phrases across multiple lines
- Type changed from defect to enhancement
comment:2 Changed 11 years ago by
Got it !! I mixed Sage-devel and TRAC :-) Sorry !
comment:3 Changed 11 years ago by
- Cc ddrake added
- Milestone changed from sage-4.3.1 to sage-4.3.2
- Report Upstream set to N/A
- Status changed from new to needs_review
Here's a patch implementing a "multiline" keyword for searches, so you can do
sage: print search_src('dhsw', 'betti', interact=False) sage: print search_src('dhsw', 'betti', interact=False, multiline=True) homology/chain_complex.py homology/simplicial_complex.py
(With multiline searches, it doesn't return line numbers, just the file names.)
comment:4 Changed 11 years ago by
Tested this on sage-4.3.2.alpha0 with trac_7313-multiline.patch (tried the patch in ticket #7018 but that had errors)
Look for occurrences of "Pseudo". We find two occurrences.
sage: search_src("Pseudo-") combinat/words/word.py:2655: - [2] V. Anne, L.Q. Zamboni, I. Zorca, Palindromes and Pseudo- combinat/words/word.py:2656: Palindromes in Episturmian and Pseudo-Palindromic Infinite Words, rings/all.py:122:# Pseudo-ring of PARI objects. databases/compressed_storage.py:113: Pseudo-acquisition for base's stuff that we don't
Next, search for a multiline ocurrence of "Pseudo-Palindromes" which should occur over lines 2655-2656 in word.py according to the last search. (Note: the 2nd line is prefixed with whitespace)
sage: search_src("Pseudo-Palindromes", multiline=True) # finds nothing
Not sure if the problem is due to the patch mentioned in #7018 needs including and updating for alpha0, or this ticket needs more work or theres something Ive missed.
comment:5 Changed 11 years ago by
Tested this on sage-4.3.2.alpha0 with trac_7313-multiline.patch (tried the patch in ticket #7018 but that had errors)
(The patch from #7018 is already part of 4.3.2.alpha0, which is probably why applying it gave you errors.)
Since the string "Pseudo-Palindromes" doesn't appear, I think it is correct that searching for it returns nothing. Try this instead:
sage: search_src("Pseudo-", "Palindromes", multiline=True)
Actually, though, Pseudo- and Palindromes appear on the same line, so this isn't the best test case. How about
sage: search_src("Zamboni", "Infinite") sage: search_src("Zamboni", "Infinite", multiline=True) combinat/words/word.py
comment:6 Changed 11 years ago by
- Reviewers set to Mitesh Patel
- Status changed from needs_review to positive_review
Quick note: multiline = kwds.get('multiline', False)
, etc., should also work.
comment:7 Changed 11 years ago by
(Confirming positive review). Tried a number of tests, verified using egrep and all worked (including using options such as path_re and ignore_case). Representative test below.
sage: search_src("Labbe",path_re=".*py") # returned a few occurences including in word.py (not shown) sage: search_src("Pirillo",path_re=".*py") combinat/words/word_generators.py:753: - [1] X. Droubay, J. Justin, G. Pirillo, Episturmian words and some combinat/words/word_generators.py:756: - [2] J. Justin, G. Pirillo, Episturmian words and episturmian combinat/words/word.py:2875: - [3] X. Droubay, J. Justin, G. Pirillo, Episturmian words and sage: search_src("Pirillo","Labbe",path_re=".*py") # not found (on same line) sage: search_src("Pirillo","Labbe",multiline=True,path_re=".*py") # Expect one occurence and found one. combinat/words/word_generators.py
comment:8 Changed 11 years ago by
- Merged in set to sage-4.3.3.alpha0
- Resolution set to fixed
- Reviewers changed from Mitesh Patel to Ross Kyprianou, Mitesh Patel
- Status changed from positive_review to closed
Please use summaries that actually describe the problem.