Serving the Quantitative Finance Community

 
User avatar
FaridMoussaoui
Posts: 327
Joined: June 20th, 2008, 10:05 am
Location: Genève, Genf, Ginevra, Geneva

Re: Python tricks

February 14th, 2020, 8:38 pm

Tell us all the commands you did to install the package.

or install the conda manager then do this from the command line (you should add conda binary path to you PATH):
conda install -c clawpack -c conda-forge clawpack
 
User avatar
FaridMoussaoui
Posts: 327
Joined: June 20th, 2008, 10:05 am
Location: Genève, Genf, Ginevra, Geneva

Re: Python tricks

February 14th, 2020, 8:38 pm

That's not the correct link. Your error arise in the pip file unpacking.py
uh! Is that a bug in Python?
What next?
No, YOU are doing something wrong.
 
User avatar
FaridMoussaoui
Posts: 327
Joined: June 20th, 2008, 10:05 am
Location: Genève, Genf, Ginevra, Geneva

Re: Python tricks

February 14th, 2020, 8:39 pm

or better: install linux.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Python tricks

February 14th, 2020, 9:45 pm

That's not the correct link. Your error arise in the pip file unpacking.py
uh! Is that a bug in Python?
What next?
No, YOU are doing something wrong.
All the other packages install fine.

PyClaw requires Python 2.7 or greater and a modern Fortran 95 compiler. PyClaw is known to work with GNU gfortran 4.2 and higher and the IBM XLF compiler.

??

 install linux.
You mean, like voting for Fine Gael?
 
User avatar
FaridMoussaoui
Posts: 327
Joined: June 20th, 2008, 10:05 am
Location: Genève, Genf, Ginevra, Geneva

Re: Python tricks

February 14th, 2020, 9:55 pm

I told you yesterday: Install cygwin and you will have a linux like command line. Then GNU fortran compiler.

PS1: Everyone I know doing serious scientific computing uses Linux (or at least OSX).
PS2: I have no idea what does mean your voting reference.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Python tricks

May 25th, 2020, 6:56 am

From "Python in a nutshell"

"Sometimes, however, you need a deep copy .... fortunately, this need is rare, since a deep copy can take a lot of memory and time."

I don't agree

1. Many applications need deep-fried-copied object
2. Deep copy is more thread-safe than shallow copy.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Python tricks

June 2nd, 2020, 10:26 am

"There are less than 5% CS graduates can program in languages other than Python, R or Java. "

and 95% of that 5% are C++ programmers

?
 
User avatar
bearish
Posts: 5188
Joined: February 3rd, 2011, 2:19 pm

Re: Python tricks

June 2nd, 2020, 9:28 pm

There are fewer than...
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Python tricks

June 3rd, 2020, 9:31 am

hinterland
 
User avatar
tags
Topic Author
Posts: 3162
Joined: February 21st, 2010, 12:58 pm

Re: Python tricks

June 9th, 2020, 3:44 pm

hello everyone,

i'm looking into google's haiku project. they explain "Haiku is a simple neural network library for JAX developed by some of the authors of Sonnet, a neural network library for Tensorlow."

I have some sense of what Sonnet is. Now, JAX is described "JAX is Autograd and XLA, brought together for high-performance machine learning research.". So, it looks like we're in the realm of Python.

But, there is syntax that I'm not used to (as Python consumer) e.g. in this piece of code:

def make_network() -> hk.RNNCore:
  """Defines the network architecture."""
  model = hk.DeepRNN([
      lambda x: jax.nn.one_hot(x, num_classes=dataset.NUM_CHARS),
      hk.LSTM(FLAGS.hidden_size),
      jax.nn.relu,
      hk.LSTM(FLAGS.hidden_size),
      hk.nets.MLP([FLAGS.hidden_size, dataset.NUM_CHARS]),
  ])
  return model

Can you please explain what is the -> and/or provide me with keywords so that I google for them?

Making sure I'll get some reactions: this makes me think to some years ago when people started to write auto main(int argc, char *argv []) -> int {} in C++

Usual disclaimers apply: I'm French, my question may be dumb, etc...

Merci.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Python tricks

June 9th, 2020, 7:08 pm

Bonsoir, Monsieur tags

It looks like explicitly giving the return type (Python 3.8.3?) just as in C++ lambda functions?

https://docs.python.org/3/library/typing.html

Looks important, anything that promotes robustness.

My take is you put your type annotations in code and use 3rd party type checkers. Can't be bad.

Buona serata.
 
User avatar
tags
Topic Author
Posts: 3162
Joined: February 21st, 2010, 12:58 pm

Re: Python tricks

June 9th, 2020, 7:53 pm

Bonsoir, Monsieur tags

It looks like explicitly giving the return type (Python 3.8.3?) just as in C++ lambda functions?

https://docs.python.org/3/library/typing.html

Looks important, anything that promotes robustness.
Bonsoir Cuch. Tout va bien?
Thank you very much indeed. I wasn't aware of this strong typing syntax (really never came across such things before last night..). I'm reading further about it now.
I'm not always against tighter conventions!
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Python tricks

June 9th, 2020, 8:34 pm

I like lockdowns in life, code and judo :-) 
tout bien, merci!
 
User avatar
ISayMoo
Posts: 2332
Joined: September 30th, 2015, 8:30 pm

Re: Python tricks

June 15th, 2020, 8:31 am

This is a great tool for exposing C++ code to Python: https://github.com/pybind/pybind11
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Python tricks

June 15th, 2020, 12:33 pm

This is a great tool for exposing C++ code to Python: https://github.com/pybind/pybind11
Yep.
I recommend this for my 2020 MSc students.