Skip to content

Commit

Permalink
New version 1.5.5 (#125)
Browse files Browse the repository at this point in the history
- Possibly a breaking change, the .to_json() method on both main classes now require an argument to choose if the raw values or the potentially amended values from the associated tsdf DataFrame is exported.
- The Poetry version for package building has been updated from 1.8.2 to 1.8.3.
- Outside of the package I have added more to the shell scripts used in development.
  • Loading branch information
karrmagadgeteer2 authored May 24, 2024
1 parent 013de29 commit 658708c
Show file tree
Hide file tree
Showing 17 changed files with 538 additions and 1,745 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
pip install --user pipx
pipx ensurepath
pipx install poetry==1.8.2
pipx install poetry==1.8.3
- name: Set up Python on ${{ runner.os }}
uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: |
pip install --user pipx
pipx ensurepath
pipx install poetry==1.8.2
pipx install poetry==1.8.3
- name: Set up Python on ${{ runner.os }}
uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: |
pip install --user pipx
pipx ensurepath
pipx install poetry==1.8.2
pipx install poetry==1.8.3
- name: Set up Python on ${{ runner.os }}
uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: |
pip install --user pipx
pipx ensurepath
pipx install poetry==1.8.2
pipx install poetry==1.8.3
- name: Set up Python on ${{ runner.os }}
uses: actions/setup-python@v5
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:

repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.3
rev: v0.4.5
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
Expand All @@ -12,19 +12,19 @@ repos:
hooks:
- id: mypy
additional_dependencies:
- pandas-stubs>=2.2.1.240316
- pandas-stubs>=2.2.2.240514
- pydantic>=2.5.2,<3.0.0
- types-openpyxl>=3.1.0.20240428
- types-python-dateutil>=2.9.0.20240316
- types-requests>=2.31.0.20240406
- types-requests>=2.32.0.20240523
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-use-type-annotations
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-ast
- id: check-added-large-files
Expand All @@ -48,7 +48,7 @@ repos:
- id: fix-byte-order-marker
exclude: .gitignore
- repo: https://github.com/python-poetry/poetry
rev: 1.8.2
rev: 1.8.3
hooks:
- id: poetry-check
- id: poetry-lock
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
At some point we will start documenting changes in release documentation instead.
For now this is the only place where we log summary descriptions.

## Version [1.5.5] - 2024-05-24

- Possibly a breaking change, the .to_json() method on both main classes now require an argument to choose if the raw values or the potentially amended values from the associated tsdf DataFrame is exported.
- The Poetry version for package building has been updated from 1.8.2 to 1.8.3.
- Outside of the package I have added more to the shell scripts used in development.

## Version [1.5.4] - 2024-05-05

- Added new measure Omega Ratio, https://en.wikipedia.org/wiki/Omega_ratio. Works on both OpenTimeSeries and OpenFrame.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ venv:
python3 -m venv ./venv
venv/bin/python --version
venv/bin/python -m pip install --upgrade pip
venv/bin/pip install poetry==1.8.2
venv/bin/pip install poetry==1.8.3

install:
rm -f poetry.lock
Expand Down
1 change: 1 addition & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Without an x next to a version below you can assume that it works as intended.

| Version | Supported |
|---------|--------------------|
| 1.5.5 | :white_check_mark: |
| 1.5.4 | :white_check_mark: |
| 1.5.3 | :white_check_mark: |
| 1.5.2 | :white_check_mark: |
Expand Down
27 changes: 26 additions & 1 deletion make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ param (
[string]$task = "active"
)

# Function to get the latest Python 3.10 version from pyenv
function Get-LatestPython310Version {
$versions = pyenv versions --bare 3.10.*
$latestVersion = $versions | Where-Object { $_ -match '^3\.10\.\d+$' } | Sort-Object -Descending | Select-Object -First 1
return $latestVersion
}

if ($task -eq "active")
{
if ($null -ne $env:PYTHONPATH)
Expand All @@ -28,6 +35,24 @@ if ($task -eq "active")
elseif ($task -eq "make")
{
Remove-Item -Path ".\venv" -Recurse -Force -ErrorAction SilentlyContinue
if (Test-Path $env:USERPROFILE\.pyenv) {
$latestVersion = Get-LatestPython310Version
if ($latestVersion) {
pyenv global $latestVersion
pyenv local $latestVersion
Remove-Item -Path '.python-version' -Force -ErrorAction SilentlyContinue
Write-Output "Python $latestVersion set as both local and global version using pyenv."
} else {
Write-Warning "No Python 3.10 versions found with pyenv."
}
} else {
$pythonVersion = python --version 2>&1
if ($pythonVersion -like "*3.10*") {
Write-Output "Python 3.10 is identified as the system's Python version."
} else {
Write-Warning "Python 3.10 is not installed or configured. Please install Python 3.10 or pyenv."
}
}
python -m venv ./venv
if ($null -ne $env:PYTHONPATH)
{
Expand All @@ -50,7 +75,7 @@ elseif ($task -eq "make")
Write-Output "`nThe Python used in the '$(Split-Path -Leaf $env:VIRTUAL_ENV)' environment is:"
Get-Command python
python.exe -m pip install --upgrade pip
pip install poetry==1.8.2
pip install poetry==1.8.3
Remove-Item -Path 'poetry.lock' -Force -ErrorAction SilentlyContinue
poetry install --with dev
poetry run pre-commit install
Expand Down
29 changes: 21 additions & 8 deletions openseries/_common_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
CountriesType,
DaysInYearType,
LiteralBarPlotMode,
LiteralJsonOutput,
LiteralLinePlotMode,
LiteralNanMethod,
LiteralPlotlyJSlib,
Expand Down Expand Up @@ -651,16 +652,18 @@ def to_drawdown_series(self: Self) -> Self:

def to_json(
self: Self,
what_output: LiteralJsonOutput,
filename: str,
directory: Optional[DirectoryPath] = None,
) -> list[dict[str, Union[str, bool, ValueType, list[str], list[float]]]]:
"""
Dump timeseries data into a json file.
The label and tsdf parameters are deleted before the json file is saved
Parameters
----------
what_output: LiteralJsonOutput
Choice on whether the raw values or the tsdf Dataframe values are
returned as json and exported as json file.
filename: str
Filename including filetype
directory: DirectoryPath, optional
Expand All @@ -669,7 +672,7 @@ def to_json(
Returns
-------
list[Dict[str, Union[str, bool, ValueType, list[str], list[float]]]]
A list of dictionaries with the raw original data of the series
A list of dictionaries with the data of the series
"""
if directory:
Expand All @@ -683,21 +686,31 @@ def to_json(
data = dict(self.__dict__)
output = []
if "label" in data:
if what_output == "tsdf":
values = self.tsdf.iloc[:, 0].tolist()
else:
values = list(cast(list[float], data.get("values")))
for item in cleaner_list:
data.pop(item)
valuetype = cast(ValueType, data.get("valuetype")).value
data.update({"valuetype": valuetype})
data.update({"values": values})
output.append(dict(data))
else:
for serie in cast(list[Any], data.get("constituents")):
if what_output == "tsdf":
values = serie.tsdf.iloc[:, 0].tolist()
else:
values = list(serie.values)
itemdata = dict(serie.__dict__)
for item in cleaner_list:
itemdata.pop(item)
valuetype = cast(ValueType, itemdata["valuetype"]).value
itemdata.update({"valuetype": valuetype})
itemdata.update({"values": values})
output.append(dict(itemdata))

with Path.open(
dirpath.joinpath(filename),
"w",
encoding="utf-8",
) as jsonfile:
with dirpath.joinpath(filename).open(mode="w", encoding="utf-8") as jsonfile:
dump(output, jsonfile, indent=2, sort_keys=False)

return output
Expand Down
1 change: 1 addition & 0 deletions openseries/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class Currency(BaseModel):

CaptorLogoType = dict[str, Union[str, float]]

LiteralJsonOutput = Literal["values", "tsdf"]
LiteralTrunc = Literal["before", "after", "both"]
LiteralLinePlotMode = Literal[
"lines",
Expand Down
Loading

0 comments on commit 658708c

Please sign in to comment.