Skip to content

Commit

Permalink
Merge pull request #179 from dstansby/pre-commit
Browse files Browse the repository at this point in the history
pre-commit fixes
  • Loading branch information
dstansby committed May 22, 2023
2 parents deedfbc + bcf4050 commit 8877352
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 22 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
repos:
- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v2.1.1
hooks:
- id: autoflake
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|__init__.py|.svg)$"

- repo: https://github.com/timothycrosley/isort
rev: 5.8.0
rev: 5.12.0
hooks:
- id: isort
args: ['--sp','setup.cfg']
exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|.svg)$"

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.4.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand All @@ -27,7 +27,7 @@ repos:
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.txt|tca.*|.svg)$"

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.961'
hooks:
- id: mypy
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: 'v1.3.0'
# hooks:
# - id: mypy
4 changes: 2 additions & 2 deletions cdflib/cdfread.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

class CDF:
"""
Read a CDF file into the CDF object. This object contains methods to load
Read a CDF file into the CDF object. This object contains methods to load
the cdf file information, variable names, and values.
Example
-------
>>> import cdflib
Expand Down
20 changes: 10 additions & 10 deletions cdflib/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class CDFepoch(object):
Convert between CDF-based epochs, np.datetime64, and Unix time.
There are three (3) epoch data types in CDF:
1. CDF_EPOCH is milliseconds since Year 0 represented as a
1. CDF_EPOCH is milliseconds since Year 0 represented as a
single double (float in Python),
2. CDF_EPOCH16 is picoseconds since Year 0 represented as
2. CDF_EPOCH16 is picoseconds since Year 0 represented as
2-doubles (complex in Python), and
3. CDF_TIME_TT2000 (TT2000 as short) is nanoseconds since J2000 with
leap seconds, represented by an 8-byte integer (int in Python).
Expand Down Expand Up @@ -90,7 +90,7 @@ class CDFepoch(object):
@staticmethod
def encode(epochs, iso_8601: bool = True): # @NoSelf
"""
Converts one or more epochs into UTC strings. The input epoch
Converts one or more epochs into UTC strings. The input epoch
format is deduced from the argument type.
Parameters
Expand All @@ -105,8 +105,8 @@ def encode(epochs, iso_8601: bool = True): # @NoSelf
(in numpy, a np.int64 or a np.ndarray of np.int64)
iso_8601: bool
The return time format. If ISO 8601 is True, the format is,
for example, 2008-02-02T06:08:10.10.012014016, otherwise
The return time format. If ISO 8601 is True, the format is,
for example, 2008-02-02T06:08:10.10.012014016, otherwise
the format is 02-Feb-2008 06:08:10.012.014.016.
"""
Expand Down Expand Up @@ -174,8 +174,8 @@ def _compose_date(years, months, days,
def to_datetime(cls, cdf_time: Union[int, Sequence[int]],
to_np: bool = False) -> List[datetime.datetime]:
"""
Converts CDF epoch argument to np.numpy.datetime64. This method
converts a scalar, or array-like. Precision is only kept to the
Converts CDF epoch argument to np.numpy.datetime64. This method
converts a scalar, or array-like. Precision is only kept to the
nearest microsecond.
If to_np is True, then the values will be returned in a numpy array.
Expand All @@ -189,8 +189,8 @@ def to_datetime(cls, cdf_time: Union[int, Sequence[int]],
@staticmethod
def unixtime(cdf_time, to_np: bool = False): # @NoSelf
"""
Converts CDF epoch argument into seconds after 1970-01-01. This method
converts a scalar, or array-like. Precision is only kept to the
Converts CDF epoch argument into seconds after 1970-01-01. This method
converts a scalar, or array-like. Precision is only kept to the
nearest microsecond.
If to_np is True, then the values will be returned in a numpy array.
Expand Down Expand Up @@ -1120,7 +1120,7 @@ def _calc_from_julian(epoch0, epoch1):

@staticmethod
def breakdown_epoch16(epochs, to_np: bool = False):
"""
"""
Calculate date and time from epochs
Parameters
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ def linkcode_resolve(domain, info):
if not info['module']:
return None
filename = info['module'].replace('.', '/')
return "https://github.com/MAVENSDC/cdflib/tree/master/%s.py" % filename
return "https://github.com/MAVENSDC/cdflib/tree/master/%s.py" % filename
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ What can cdflib do?

.. note::
While we try to simplify things in this documentation, the full API description of each module can be found in the ``API Reference`` section


.. toctree::
:maxdepth: 1
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/cdfread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ This command will return all data inside of the variable `Variable1`, from recor

.. automodule:: cdflib
:undoc-members:
:show-inheritance:
:show-inheritance:
31 changes: 31 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import datetime as dt

import numpy as np

import cdflib

cdf = cdflib.cdfwrite.CDF("test.cdf")

var_spec = {}
var_spec['Variable'] = "time"
var_spec['Data_Type'] = "CDF_EPOCH"
var_spec['Num_Elements'] = 10
var_spec['Rec_Vary'] = True
var_spec['Dim_Sizes'] = []

time = np.array([dt.datetime(2001,1,1),
dt.datetime(2001,1,2),
dt.datetime(2001,1,3),
dt.datetime(2001,1,4),
dt.datetime(2001,1,5),
dt.datetime(2001,1,6),
dt.datetime(2001,1,7),
dt.datetime(2001,1,8),
dt.datetime(2001,1,9),
dt.datetime(2001,1,10)])

time_list = [[f.year, f.month, f.day, 0, 0, 0, 0] for f in time]
var_data = [cdflib.cdfepoch.compute(t) for t in time_list]

cdf.write_var(var_spec, var_data=var_data)
cdf.close()

0 comments on commit 8877352

Please sign in to comment.