Comments (2)
This actually seems pretty hard because it looks like scipy.special
implements gamma
using Fortran or C code. However, there is a math.gamma(x: float)
function. It throws an error when you get float('inf')
, but I wrote a quick wrapper as a workaround. It runs really quickly on values and is correct within 1E-12. However, I need to test to see how it would work on vectorized implementations.
Here is the function + test code:
import math
import scipy.special
from numpy import arange
import time
def gamma(x):
try:
return math.gamma(x)
except ValueError:
return float('inf')
def test_correctness():
for i in arange(-10, 10, .01):
if gamma(i) != scipy.special.gamma(i):
print(i, gamma(i)- scipy.special.gamma(i))
def test_speed():
start = time.time()
for i in arange(-10, 10, .01):
gamma(i)
print("Our gamma time: ", time.time() - start)
start = time.time()
for i in arange(-10, 10, .01):
scipy.special.gamma(i)
print("scipy gamma time: ", time.time() - start)
test_correctness()
test_speed()
from mintpy.
@2gotgrossman Your solution looks good to me. The input of gamma()
is usually small in our cases: < 2000, so the difference between math.gamma()
and scipy.special.gamma()
is definitely negligible for us.
from mintpy.
Related Issues (20)
- Mintpy can't load `int8` types from GDAL HOT 8
- tropo_gacos: can not convert NaN to integer HOT 4
- prep_isce.py KeyError HOT 2
- FileNotFoundError: [Errno 2] No such file or directory: '' (*.slc.full from isce2 is missing) HOT 1
- UTM conversion raise OutOfRangeError in `prep_hyp3.py` HOT 3
- Change Mix, Max Range of Colorbar HOT 1
- How to get full resolution result of geo_velocity.h5? HOT 1
- Load data error in opensarlab mintpy timeseries notebook HOT 2
- TypeError: Object dtype dtype('O') HOT 2
- when load GAMMA format unw file, load_data report a error HOT 4
- Index Out Of Range during correct_troposphere step HOT 1
- Release new version of MintPy to support HyP3 Burst InSAR products HOT 4
- AriaTS_setup HOT 2
- Subset HyP3 datasets and create horz and vert displacement on Jupyter notebook HOT 1
- An error occurred using GACOS data in mintpy HOT 2
- Deprecated numpy.float usage in smallbaselineApp.py breaks with numpy > 1.24.0 HOT 2
- The meaning of numTriNonzeroIntAmbiguity.h5 HOT 1
- output save_gbis.py issue HOT 1
- hyp3 + mintpy: Error in Second Step (Modify Network) HOT 1
- metadata inconsistency for UTM coordinates HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mintpy.