Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_cdftt2000():
x = "2004-03-01 12:24:22.351793238"
parsed = cdfepoch.parse(x)
assert parsed == [131415926535793232]
assert cdfepoch.to_datetime(parsed) == [datetime(2004, 3, 1, 12, 25, 26, 535793)]
def findepochrange(epochs, starttime=None, endtime=None): # @NoSelf
if isinstance(starttime, list):
start = CDFAstropy.compute(starttime)
if isinstance(endtime, list):
end = CDFAstropy.compute(endtime)
epochs = CDFAstropy.convert_to_astropy(epochs)
epochs_as_np = epochs.value
indices = np.where((epochs_as_np >= start) & (epochs_as_np <= end))
return min(indices[0]), max(indices[0])
def getVersion():
"""
Prints the code version.
"""
print('epochs version:', str(CDFAstropy.version) + '.' +
str(CDFAstropy.release) + '.'+str(CDFAstropy.increment))
def getVersion():
"""
Prints the code version.
"""
print('epochs version:', str(CDFAstropy.version) + '.' +
str(CDFAstropy.release) + '.'+str(CDFAstropy.increment))
def breakdown(epochs, to_np: bool = False):
# Returns either a single array, or a array of arrays depending on the input
epochs = CDFAstropy.convert_to_astropy(epochs)
if epochs.format == 'cdf_tt2000':
return CDFAstropy.breakdown_tt2000(epochs, to_np)
elif epochs.format == 'cdf_epoch':
return CDFAstropy.breakdown_epoch(epochs, to_np)
elif epochs.format == 'cdf_epoch16':
return CDFAstropy.breakdown_epoch16(epochs, to_np)
raise TypeError('Not sure how to handle type {}'.format(type(epochs)))
def findepochrange(epochs, starttime=None, endtime=None): # @NoSelf
if isinstance(starttime, list):
start = CDFAstropy.compute(starttime)
if isinstance(endtime, list):
end = CDFAstropy.compute(endtime)
epochs = CDFAstropy.convert_to_astropy(epochs)
epochs_as_np = epochs.value
indices = np.where((epochs_as_np >= start) & (epochs_as_np <= end))
return min(indices[0]), max(indices[0])
def breakdown(epochs, to_np: bool = False):
# Returns either a single array, or a array of arrays depending on the input
epochs = CDFAstropy.convert_to_astropy(epochs)
if epochs.format == 'cdf_tt2000':
return CDFAstropy.breakdown_tt2000(epochs, to_np)
elif epochs.format == 'cdf_epoch':
return CDFAstropy.breakdown_epoch(epochs, to_np)
elif epochs.format == 'cdf_epoch16':
return CDFAstropy.breakdown_epoch16(epochs, to_np)
raise TypeError('Not sure how to handle type {}'.format(type(epochs)))
def breakdown(epochs, to_np: bool = False):
# Returns either a single array, or a array of arrays depending on the input
epochs = CDFAstropy.convert_to_astropy(epochs)
if epochs.format == 'cdf_tt2000':
return CDFAstropy.breakdown_tt2000(epochs, to_np)
elif epochs.format == 'cdf_epoch':
return CDFAstropy.breakdown_epoch(epochs, to_np)
elif epochs.format == 'cdf_epoch16':
return CDFAstropy.breakdown_epoch16(epochs, to_np)
raise TypeError('Not sure how to handle type {}'.format(type(epochs)))