Skip to content
Snippets Groups Projects
Commit 230933ba authored by Erin (Josh) Rigler's avatar Erin (Josh) Rigler
Browse files

Merge branch 'python-safety' into 'master'

Python safety

See merge request !169
parents 7889a332 42250395
No related branches found
No related tags found
1 merge request!169Python safety
Pipeline #125432 passed
ARG FROM_IMAGE=usgs/python:3.8-obspy
FROM ${FROM_IMAGE}
ARG GIT_BRANCH_NAME=none
......@@ -21,12 +19,14 @@ RUN cd /geomag-algorithms \
# install into system python
&& poetry export -o requirements.txt --dev --without-hashes \
# only install dependencies, not project
&& pip install -r requirements.txt
&& pip install -r requirements.txt \
&& pip cache purge
# install rest of library separate from dependencies
COPY . /geomag-algorithms
RUN cd /geomag-algorithms \
&& pip install . \
&& pip cache purge \
# add data directory owned by usgs-user
&& mkdir -p /data \
&& chown -R usgs-user:usgs-user /data
......
......@@ -461,7 +461,7 @@ class SqDistAlgorithm(Algorithm):
# to White et al. (USGS SIR 2014-5045).
fom = 10 ** (-3 / 20.0) # halve power at corner frequency
omg = np.pi / np.float64(smooth) # corner angular frequency
sig = np.sqrt(-2 * np.log(fom) / omg ** 2) + np.finfo(float).eps # sig>0
sig = np.sqrt(-2 * np.log(fom) / omg**2) + np.finfo(float).eps # sig>0
ts = np.linspace(
np.max((-m, -3 * np.round(sig))),
np.min((m, 3 * np.round(sig))),
......@@ -536,7 +536,7 @@ class SqDistAlgorithm(Algorithm):
# when forecasting, grow sigma=sqrt(var) like a prediction
# interval; sumc2 and jstep will be reset with the next
# valid observation
phiJminus1 = phiJminus1 + phi ** jstep
phiJminus1 = phiJminus1 + phi**jstep
jstep = jstep + 1
sumc2 = (
sumc2
......
......@@ -4,7 +4,7 @@ from .common import sqlalchemy_metadata
from .metadata_table import metadata
# create copy of original metadata table and add to sqlalchemy metadata
metadata_history = metadata.tometadata(
metadata_history = metadata.to_metadata(
metadata=sqlalchemy_metadata, name="metadata_history"
)
metadata_history.indexes.clear()
......
from typing_extensions import Literal
from typing import Literal
DataInterval = Literal["tenhertz", "second", "minute", "hour", "day", "month"]
DataType = Literal[
......
from typing import List, Tuple
from typing_extensions import Literal
from typing import List, Literal, Tuple
import numpy as np
......@@ -116,7 +115,7 @@ def calculate_D_absolute(
m.angle
+ np.degrees(
m.measurement_type.meridian
* (np.arcsin(m.residual / np.sqrt((m.h + h_baseline) ** 2 + m.e ** 2)))
* (np.arcsin(m.residual / np.sqrt((m.h + h_baseline) ** 2 + m.e**2)))
)
- np.degrees(np.arctan(m.e / (m.h + h_baseline)))
for m in declination_measurements
......@@ -168,7 +167,7 @@ def calculate_HZ_absolutes(
inclination_radians = np.radians(inclination)
h_abs = corrected_f * np.cos(inclination_radians)
z_abs = corrected_f * np.sin(inclination_radians)
h_b = np.sqrt(h_abs ** 2 - mean.e ** 2) - mean.h
h_b = np.sqrt(h_abs**2 - mean.e**2) - mean.h
z_b = z_abs - mean.z
# adjust absolutes to reference measurement
if reference:
......
from typing import Dict, List, Optional, Tuple
from typing_extensions import Literal
from typing import Dict, List, Literal, Optional, Tuple
import numpy as np
from obspy import Stream, UTCDateTime
......@@ -187,7 +186,7 @@ def get_ordinates(
d_ord = d_abs - d_bas
z_ord = z_abs - z_bas
e_ord = h_abs * np.radians(d_ord)
h_ord = np.sqrt(h_ord ** 2 - e_ord ** 2)
h_ord = np.sqrt(h_ord**2 - e_ord**2)
return (h_ord, e_ord, z_ord)
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -21,36 +21,35 @@ version = "1.4.4"
[tool.poetry.dependencies]
python = "^3.7,<3.10"
python = "^3.8,<3.11"
# core
numpy = "^1.21.1"
obspy = "^1.2.2"
openpyxl = "^3.0.7"
pycurl = {version = "^7.44.1", optional = true}
pydantic = "^1.8.2"
requests = "^2.26.0"
scipy = "^1.7.1"
typer = "^0.3.2"
numpy = "^1.22.3"
obspy = "^1.3.0"
openpyxl = "^3.0.9"
pycurl = {version = "^7.45.1", optional = true}
pydantic = "^1.9.0"
requests = "^2.27.1"
scipy = "^1.8.0"
typer = "^0.4.0"
# webservice
alembic = "^1.6.5"
Authlib = "^0.15.4"
cryptography = "^3.4.7"
databases = {extras = ["mysql", "sqlite"], version = "^0.4.3"}
fastapi = "^0.68.0"
alembic = "^1.7.7"
Authlib = "^1.0.0"
cryptography = "^36.0.2"
databases = {extras = ["mysql", "sqlite"], version = "^0.5.5"}
fastapi = "^0.75.0"
gunicorn = "^20.1.0"
SQLAlchemy = "^1.3.24"
SQLAlchemy-Utc = "^0.12.0"
typing-extensions = "^3.10.0"
uvicorn = {extras = ["standard"], version = "^0.15.0"}
httpx = "0.18.1"
SQLAlchemy = "^1.4.32"
SQLAlchemy-Utc = "^0.14.0"
uvicorn = {extras = ["standard"], version = "^0.17.6"}
httpx = "0.22.0"
[tool.poetry.dev-dependencies]
black = "^21.7b0"
black = "^22.1.0"
pytest = "^6.2.4"
pytest-cov = "^2.12.1"
safety = "^1.10.3"
mypy = "^0.910"
mypy = "^0.941"
# type hints
data-science-types = "^0.2.23"
openpyxl-stubs = "^0.1.19"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment