I get an error when I try to call the init_printing function from scipy
init_printing(use_latex=True)
TypeError: init_printing() got an unexpected keyword argument 'use_latex'
How do I correctly enable latex?
help(init_printing)
Help on function init_printing in module sympy.interactive.printing:
init_printing(pretty_print=True, order=None, use_unicode=None, wrap_line=None, no_global=False, ip=None)
Initializes pretty-printer depending on the environment.
You probably aren't using a new enough version of SymPy. Make sure you are using 0.7.4.1, the latest.
Related
I am trying to use 'drop_all' after service test fails or finishes on flask app layer:
#pytest.fixture(scope='class')
def db_connection():
db_url = TestConfig.db_url
db = SQLAlchemyORM(db_url)
db.create_all(True)
yield db_connection
db.drop_all()
When some test passes the 'drop_all' works, but when it fails the test freezes.
So, that solution solves my problem:
https://stackoverflow.com/a/44437760/3050042
Unfortunately, I got a mess with that.
When I use the 'Session.close_all()' SQLAlchemy warns:
The Session.close_all() method is deprecated and will be removed in a future release. Please refer to session.close_all_sessions().
When I change to the suggestion:
AttributeError: 'scoped_session' object has no attribute 'close_all_sessions'
Yes, I use scoped_session and pure SQLAlchemy.
How to solve this?
The close_all_sessions function is defined at the top level of sqlalchemy.orm.session. At the time of writing this answer, here is how it looks. Thus, you can use it as follows.
from sqlalchemy.orm.session import close_all_sessions
close_all_sessions()
I am new to deep learning and trying to implement code written here
http://r2rt.com/recurrent-neural-networks-in-tensorflow-i.html.
I am trying to implement same code but I am getting error
no module name basic_rnn
while importing basic_rnn as written in the code:
import basic_rnn
def plot_learning_curve(num_steps, state_size=4, epochs=1):
global losses, total_loss, final_state, train_step, x, y, init_state
tf.reset_default_graph()
g = tf.get_default_graph()
losses, total_loss, final_state, train_step, x, y, init_state = \
basic_rnn.setup_graph(g,basic_rnn.RNN_config(num_steps=num_steps, state_size=state_size))
res = train_network(epochs, num_steps, state_size=state_size, verbose=False)
plt.plot(res)
then I changed basic_rnn = tf.contrib.rnn.BasicRNNCell,
then I am getting error
'module' object has no attribute 'setup_graph'.
I am assuming I will again get error in while implementing basic_rnn.RNN_config.
What would be the correct syntax?
I am using tensorflow of version 1.0.0
pls help
You can look at the gist code provided by the author, r2rt:
https://gist.github.com/anonymous/5fc9903990ecec5f09361934920bb999. Though you need to tweak the code a bit to get it run.
Basically, you need to implement the setuo_graph and RNN_config functions in basic_rnn.py. But since there are three versions of RNNs that the original blog is comparing, I think it would be better if you put RNN_config in one Python file.
Besides, I found some of r2rt's code is deprecated, so I adapted the code and created my own repo. Check it out if you are interested:
https://github.com/innerfirexy/rnn-tf-r2rt
You can run the code in run_RNNs.py in IPython. I changed the gist code a bit by moving the RNN_config function to train.py, and giving train_network a config parameter.
I'm new to python, and while it's a pretty simple language, I'm having a hard time finding a solid and easy to read language reference that lists all the supported build-in methods and libraries that come with the installation. The main documentation site is confusing. There's more info about what's deprecated than what's recommended. I tried using pydoc to find method usage. For example, I want to see a simple list of all the methods that are part of the string class (e.g. replace(), toupper(), etc). But I'm not sure how to use it to list the methods, or to list a method and its usage. What do people use for a quick reference that works?
When I do something like 'pydoc string', I see a message that says "Warning: most of the code you see here isn't normally used nowadays.
Beginning with Python 1.6, many of these functions are implemented as
methods on the standard string object. They used to be implemented by
a built-in module called strop, but strop is now obsolete itself."
So while there's info about the method replace() there, I'm worried that it's not the right info based on that warning. How can I see the methods of the standard string object?
Documentation about standard functions:
https://docs.python.org/2/library/functions.html
Documentation about standard libraries:
https://docs.python.org/2/library/
You could use dir() and help(). i.e. :
From python shell :
>>> import math
>>> dir(math)
['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
>>> help(math.tan)
Will print :
Help on built-in function tan in module math:
tan(...)
tan(x)
Return the tangent of x (measured in radians).
(press "q" to exit the help page)
Hope it helps.
EDIT
Another solution from the shell :
$ python -m pydoc sys
Then press "q" to exit.
I'm trying to mark a function as deprecated so that the script calling it runs to its normal completion, but gets caught by PyCharm's static code inspections. (There are some other questions on this deprecation warnings, but I think they predate Python 2.6, when I believe class-based exceptions were introduced.)
Here's what I have:
class Deprecated(DeprecationWarning):
pass
def save_plot_and_insert(filename, worksheet, row, col):
"""
Deprecated. Docstring ...<snip>
"""
raise Deprecated()
# Active lines of
# the function here
# ...
My understanding is that Deprecated Warnings should allow the code to run, but this code sample actually halts when the function is called. When I remove "raise" from the body of the function, the code runs, but PyCharm doesn't mark the function call as deprecated.
What is the Pythonic (2.7.x) way of marking functions as deprecated?
You shouldn't raise DeprecationWarning (or a subclass) because then you still are raising an actual exception.
Instead use warnings.warn:
import warnings
warnings.warn("deprecated", DeprecationWarning)
I am trying an OpenGL tutorial. I am running macosx with Haskell Platform installed
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
main :: IO ()
main = do
(progname, _) <- getArgsAndInitialize
createWindow "Hello World"
displayCallback $= display
display :: IO ()
display = do
clear [ ColorBuffer ]
flush
This is the error I am getting, the following is repeated for "clear","ColorBuffer" and "Flush"
Hello_World.hs:8:19:
Ambiguous occurrence `$='
It could refer to either `Graphics.Rendering.OpenGL.$=',
imported from `Graphics.Rendering.OpenGL' at Hello_World.hs:1:1-32
(and originally defined in `Data.StateVar')
or `Graphics.UI.GLUT.$=',
imported from `Graphics.UI.GLUT' at Hello_World.hs:2:1-23
(and originally defined in `OpenGL-2.2.3.1:Graphics.Rendering.OpenGL.GL.StateVar')
This code was working before, since then I have installed some packages via cabal install and by homebrew.
Since I think it might have something to do with packages here is "ghc-pkg list" (sorry for the block, just extra info that might help)
Cabal-1.14.0
GLUT-2.1.2.1
HTTP-4000.2.5
HUnit-1.2.5.1
OpenGL-2.2.3.1
QuickCheck-2.5.1.1
array-0.4.0.0
async-2.0.1.3
base-4.5.1.0
bin-package-db-0.0.0.0
binary-0.5.1.0
bytestring-0.9.2.1
cgi-3001.1.7.4
containers-0.4.2.1
deepseq-1.3.0.0
directory-1.1.0.2
extensible-exceptions-0.1.1.4
fgl-5.4.2.4
filepath-1.3.0.0
ghc-7.4.2
ghc-prim-0.2.0.0
haskell-platform-2012.4.0.0
haskell-src-1.0.1.5
haskell2010-1.1.0.1
haskell98-2.0.0.1
hoopl-3.8.7.3
hpc-0.5.1.1
html-1.0.1.2
integer-gmp-0.4.0.0
mtl-2.1.2
network-2.3.1.0
old-locale-1.0.0.4
old-time-1.1.0.0
parallel-3.2.0.3
parsec-3.1.3
pretty-1.1.1.0
primitive-0.5.0.1
process-1.1.0.1
random-1.0.1.1
regex-base-0.93.2
regex-compat-0.95.1
regex-posix-0.95.2
rts-1.0
split-0.2.1.1
stm-2.4
syb-0.3.7
template-haskell-2.7.0.0
text-0.11.2.3
time-1.4
transformers-0.3.0.0
unix-2.5.1.1
vector-0.10.0.1
xhtml-3000.2.1
zlib-0.5.4.0
/Users/james/.ghc/x86_64-darwin-7.4.2/package.conf.d
Cabal-1.16.0.3
GLURaw-1.3.0.0
ObjectName-1.0.0.0
OpenGL-2.6.0.1
OpenGLRaw-1.3.0.0
StateVar-1.0.0.0
Tensor-1.0.0.1
aeson-0.6.1.0
ansi-terminal-0.6
ansi-wl-pprint-0.6.6
attoparsec-0.10.4.0
blaze-builder-0.3.1.0
blaze-html-0.5.1.3
blaze-markup-0.5.1.4
cairo-0.12.4
cpphs-1.16
data-default-0.5.0
dlist-0.5
fay-0.14.1.0
fay-base-0.14.1.0
ghc-paths-0.1.0.9
gio-0.12.4
glib-0.12.4
gtk-0.12.4
hashable-1.2.0.5
haskeline-0.7.0.3
haskell-lexer-1.0
haskell-src-exts-1.13.5
hostname-1.0
language-ecmascript-0.10
language-haskell-extract-0.2.4
optparse-applicative-0.5.2.1
pango-0.12.4
pretty-show-1.5
safe-0.3.3
terminfo-0.3.2.5
test-framework-0.8
test-framework-hunit-0.3.0
test-framework-th-0.2.4
uniplate-1.6.10
unordered-containers-0.2.3.0
utf8-string-0.3.7
xml-1.3.12
You've imported both of these modules
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
which each export a function named ($=). You should figure out which you want to use and probably hide one of them, e.g.
import Graphics.Rendering.OpenGL hiding (($=))
or use qualified imports of one or both of those libs.
There were two problems. I think the error was due to me installing OpenGL when it was already installed and the second was my code was missing "mainLoop" so the program would stop really quickly. I just ended up reinstalling the haskell platform.
Thank you