Skip to content

Commit

Permalink
minor update on format
Browse files Browse the repository at this point in the history
Signed-off-by: Yiyu Ni <[email protected]>
  • Loading branch information
niyiyu committed Nov 4, 2024
1 parent 07278ae commit 2d4de89
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 127 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ dask-worker-space/

# tmp directory
tmp/
dev/

# Mac OS
.DS_Store
Expand Down
121 changes: 0 additions & 121 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,124 +31,3 @@ repos:
rev: 23.7.0
hooks:
- id: black


# - repo: https://github.com/PyCQA/flake8
# rev: 6.0.0
# hooks:
# - id: flake8
# additional_dependencies:
# - flake8-black
# exclude: .git,__pycache__,build,dist
# repos:

# # Compare the local template version to the latest remote template version
# # This hook should always pass. It will print a message if the local version
# # is out of date.
# - repo: https://github.com/lincc-frameworks/pre-commit-hooks
# rev: v0.1.1
# hooks:
# - id: check-lincc-frameworks-template-version
# name: Check template version
# description: Compare current template version against latest
# verbose: true

# # Clear output from jupyter notebooks so that only the input cells are committed.
# - repo: local
# hooks:
# - id: jupyter-nb-clear-output
# name: Clear output from Jupyter notebooks
# description: Clear output from Jupyter notebooks.
# files: \.ipynb$
# stages: [commit]
# language: system
# entry: jupyter nbconvert --clear-output

# # Prevents committing directly branches named 'main' and 'master'.
# - repo: https://github.com/pre-commit/pre-commit-hooks
# rev: v4.4.0
# hooks:
# - id: no-commit-to-branch
# name: Prevent main branch commits
# description: Prevent the user from committing directly to the primary branch.
# - id: check-added-large-files
# name: Check for large files
# description: Prevent the user from committing very large files.
# args: ['--maxkb=500']

# # Verify that pyproject.toml is well formed
# - repo: https://github.com/abravalheri/validate-pyproject
# rev: v0.12.1
# hooks:
# - id: validate-pyproject
# name: Validate pyproject.toml
# description: Verify that pyproject.toml adheres to the established schema.


# # Automatically sort the imports used in .py files
# - repo: https://github.com/pycqa/isort
# rev: 5.12.0
# hooks:
# - id: isort
# name: Run isort
# description: Sort and organize imports in .py and .pyi files.
# types_or: [python, pyi]



# # Analyze the code style and report code that doesn't adhere.
# - repo: https://github.com/psf/black
# rev: 23.7.0
# hooks:
# - id: black-jupyter
# name: Format code using black
# types_or: [python, pyi, jupyter]
# # It is recommended to specify the latest version of Python
# # supported by your project here, or alternatively use
# # pre-commit's default_language_version, see
# # https://pre-commit.com/#top_level-default_language_version
# language_version: python3.10




# # Run unit tests, verify that they pass. Note that coverage is run against
# # the ./src directory here because that is what will be committed. In the
# # github workflow script, the coverage is run against the installed package
# # and uploaded to Codecov by calling pytest like so:
# # `python -m pytest --cov=<package_name> --cov-report=xml`
# - repo: local
# hooks:
# - id: pytest-check
# name: Run unit tests
# description: Run unit tests with pytest.
# entry: bash -c "if python -m pytest --co -qq; then python -m pytest --cov=./src --cov-report=html; fi"
# language: system
# pass_filenames: false
# always_run: true
# # Make sure Sphinx can build the documentation while explicitly omitting
# # notebooks from the docs, so users don't have to wait through the execution
# # of each notebook or each commit. By default, these will be checked in the
# # GitHub workflows.
# - repo: local
# hooks:
# - id: sphinx-build
# name: Build documentation with Sphinx
# entry: sphinx-build
# language: system
# always_run: true
# exclude_types: [file, symlink]
# args:
# [
# "-M", # Run sphinx in make mode, so we can use -D flag later
# # Note: -M requires next 3 args to be builder, source, output
# "html", # Specify builder
# "./docs", # Source directory of documents
# "./_readthedocs", # Output directory for rendered documents
# "-T", # Show full trace back on exception
# "-E", # Don't use saved env; always read all files
# "-d", # Flag for cached environment and doctrees
# "./docs/_build/doctrees", # Directory
# "-D", # Flag to override settings in conf.py
# "exclude_patterns=notebooks/*", # Exclude our notebooks from pre-commit
# ]
12 changes: 6 additions & 6 deletions src/noisepy/seis/io/channelcatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ def get_inventory(self, timespan: DateTimeRange, station: Station) -> obspy.Inve
station = inventory.Station(sta, lat, lon, elevation, channels=channels)
stations.append(station)
nets.append(inventory.Network(net, stations))
return inventory.Inventory(nets)
return obspy.Inventory(nets)

Check warning on line 191 in src/noisepy/seis/io/channelcatalog.py

View check run for this annotation

Codecov / codecov/patch

src/noisepy/seis/io/channelcatalog.py#L191

Added line #L191 was not covered by tests


def sta_info_from_inv(inv: inventory.Inventory):
def sta_info_from_inv(inv: obspy.Inventory):
"""
this function outputs station info from the obspy inventory object
(used in S0B)
Expand Down Expand Up @@ -225,7 +225,7 @@ def sta_info_from_inv(inv: inventory.Inventory):
return sta, net, lon, lat, elv, location


def stats2inv_staxml(stats, respdir: str) -> inventory.Inventory:
def stats2inv_staxml(stats, respdir: str) -> obspy.Inventory:
if not respdir:
raise ValueError("Abort! staxml is selected but no directory is given to access the files")
else:
Expand All @@ -248,7 +248,7 @@ def stats2inv_staxml(stats, respdir: str) -> inventory.Inventory:


def stats2inv_sac(stats):
inv = inventory.Inventory(networks=[], source="homegrown")
inv = obspy.Inventory(networks=[], source="homegrown")

Check warning on line 251 in src/noisepy/seis/io/channelcatalog.py

View check run for this annotation

Codecov / codecov/patch

src/noisepy/seis/io/channelcatalog.py#L251

Added line #L251 was not covered by tests
net = inventory.Network(
# This is the network code according to the SEED standard.
code=stats.network,
Expand Down Expand Up @@ -292,8 +292,8 @@ def stats2inv_sac(stats):
return inv


def stats2inv_mseed(stats, locs: pd.DataFrame) -> inventory.Inventory:
inv = inventory.Inventory(networks=[], source="homegrown")
def stats2inv_mseed(stats, locs: pd.DataFrame) -> obspy.Inventory:
inv = obspy.Inventory(networks=[], source="homegrown")
ista = locs[locs["station"] == stats.station].index.values.astype("int64")[0]

net = inventory.Network(
Expand Down

0 comments on commit 2d4de89

Please sign in to comment.