Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/generate-stubs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "chore: regenerate Java stubs"
file_pattern: "src/jneqsim-stubs/**"
file_pattern: "src/jneqsim/**/*.pyi"
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ codeql-db/
codeql-*.sarif
tools/codeql/

# Generated stubs
src/jneqsim-stubs/
# Stubs build artifacts (cleaned up by generate_stubs.py)
src/temp-stubs/
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.extraPaths": ["src"]
}
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[tool.poetry]
packages = [
{include = "neqsim", from = "src"},
{include = "jneqsim", from = "src"},
]
name = "neqsim"
version = "3.14.0"
homepage = "https://github.com/Equinor/neqsim-python"
Expand Down Expand Up @@ -27,6 +31,9 @@ stubgenj = "^0.2.12" # Generate type stubs for Java classes
[tool.poetry.extras]
interactive = ["matplotlib", "jupyter", "tabulate"]

[tool.mypy]
mypy_path = "src"

[tool.pytest.ini_options]
addopts = "-p no:faulthandler"

Expand Down
30 changes: 16 additions & 14 deletions scripts/generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Usage:
python scripts/generate_stubs.py

The stubs will be generated in the src/jneqsim-stubs directory.
The stubs will be generated in the src/jneqsim directory.
"""

import re
Expand Down Expand Up @@ -60,8 +60,8 @@ def generate_stubs():
shutil.rmtree(temp_output_dir)
temp_output_dir.mkdir(exist_ok=True)

# Final output directory
final_output_dir = src_path / "jneqsim-stubs"
# Final output directory: stubs live directly under src/ alongside neqsim/
final_output_dir = src_path

print("Generating stubs...")

Expand All @@ -81,34 +81,36 @@ def generate_stubs():
print("Renaming 'neqsim' -> 'jneqsim' in stubs to avoid naming conflict...")
rename_package_in_stubs(temp_output_dir, "neqsim", "jneqsim")

# Clean up existing output
if final_output_dir.exists():
shutil.rmtree(final_output_dir)
final_output_dir.mkdir(exist_ok=True)
# Clean up existing jneqsim output
jneqsim_stubs_out = final_output_dir / "jneqsim"
if jneqsim_stubs_out.exists():
shutil.rmtree(jneqsim_stubs_out)

# Move jpype-stubs as-is (it's at temp_output_dir/jpype-stubs)
jpype_stubs = temp_output_dir / "jpype-stubs"
if jpype_stubs.exists():
shutil.move(str(jpype_stubs), str(final_output_dir / "jpype-stubs"))
jpype_stubs_out = final_output_dir / "jpype-stubs"
if jpype_stubs_out.exists():
shutil.rmtree(jpype_stubs_out)
shutil.move(str(jpype_stubs), str(jpype_stubs_out))

# Rename folder neqsim-stubs -> jneqsim-stubs
target = final_output_dir / "jneqsim-stubs"
shutil.move(str(neqsim_stubs), str(target))
# Rename folder neqsim-stubs -> jneqsim
shutil.move(str(neqsim_stubs), str(jneqsim_stubs_out))

# Clean up temp directory
shutil.rmtree(temp_output_dir)

print(f"Stubs generated successfully in {final_output_dir}")
print(f"Stubs generated successfully in {final_output_dir / 'jneqsim'}")
print("\n" + "=" * 60)
print("USAGE INSTRUCTIONS")
print("=" * 60)
print("\nThe Java 'neqsim' package stubs are available as 'jneqsim'")
print("to avoid conflicts with the Python 'neqsim' package.")
print("\nFor VS Code with Pylance, add to settings.json:")
print(' "python.analysis.extraPaths": ["src/jneqsim-stubs"]')
print(' "python.analysis.extraPaths": ["src"]')
print("\nFor mypy, add to pyproject.toml:")
print(" [tool.mypy]")
print(' mypy_path = "src/jneqsim-stubs"')
print(' mypy_path = "src"')


if __name__ == "__main__":
Expand Down
45 changes: 45 additions & 0 deletions src/jneqsim/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

import sys
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol

import jneqsim.api
import jneqsim.blackoil
import jneqsim.chemicalreactions
import jneqsim.datapresentation
import jneqsim.fluidmechanics
import jneqsim.integration
import jneqsim.mathlib
import jneqsim.mcp
import jneqsim.physicalproperties
import jneqsim.process
import jneqsim.pvtsimulation
import jneqsim.standards
import jneqsim.statistics
import jneqsim.thermo
import jneqsim.thermodynamicoperations
import jneqsim.util
import typing


class __module_protocol__(Protocol):
# A module protocol which reflects the result of ``jp.JPackage("neqsim")``.

api: jneqsim.api.__module_protocol__
blackoil: jneqsim.blackoil.__module_protocol__
chemicalreactions: jneqsim.chemicalreactions.__module_protocol__
datapresentation: jneqsim.datapresentation.__module_protocol__
fluidmechanics: jneqsim.fluidmechanics.__module_protocol__
integration: jneqsim.integration.__module_protocol__
mathlib: jneqsim.mathlib.__module_protocol__
mcp: jneqsim.mcp.__module_protocol__
physicalproperties: jneqsim.physicalproperties.__module_protocol__
process: jneqsim.process.__module_protocol__
pvtsimulation: jneqsim.pvtsimulation.__module_protocol__
standards: jneqsim.standards.__module_protocol__
statistics: jneqsim.statistics.__module_protocol__
thermo: jneqsim.thermo.__module_protocol__
thermodynamicoperations: jneqsim.thermodynamicoperations.__module_protocol__
util: jneqsim.util.__module_protocol__
15 changes: 15 additions & 0 deletions src/jneqsim/api/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import sys
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol

import jneqsim.api.ioc
import typing


class __module_protocol__(Protocol):
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.api")``.

ioc: jneqsim.api.ioc.__module_protocol__
25 changes: 25 additions & 0 deletions src/jneqsim/api/ioc/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

import sys
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol

import java.lang
import jpype
import typing



class CalculationResult:
fluidProperties: typing.MutableSequence[typing.MutableSequence[float]] = ...
calculationError: typing.MutableSequence[java.lang.String] = ...
def __init__(self, doubleArray: typing.Union[typing.List[typing.MutableSequence[float]], jpype.JArray], stringArray: typing.Union[typing.List[java.lang.String], jpype.JArray]): ...
def equals(self, object: typing.Any) -> bool: ...
def hashCode(self) -> int: ...


class __module_protocol__(Protocol):
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.api.ioc")``.

CalculationResult: typing.Type[CalculationResult]
114 changes: 114 additions & 0 deletions src/jneqsim/blackoil/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@

import sys
if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol

import java.io
import java.util
import jpype
import jneqsim.blackoil.io
import jneqsim.thermo.system
import typing



class BlackOilConverter:
def __init__(self): ...
@staticmethod
def convert(systemInterface: jneqsim.thermo.system.SystemInterface, double: float, doubleArray: typing.Union[typing.List[float], jpype.JArray], double3: float, double4: float) -> 'BlackOilConverter.Result': ...
class Result:
pvt: 'BlackOilPVTTable' = ...
blackOilSystem: 'SystemBlackOil' = ...
rho_o_sc: float = ...
rho_g_sc: float = ...
rho_w_sc: float = ...
bubblePoint: float = ...
def __init__(self): ...

class BlackOilFlash(java.io.Serializable):
def __init__(self, blackOilPVTTable: 'BlackOilPVTTable', double: float, double2: float, double3: float): ...
def flash(self, double: float, double2: float, double3: float, double4: float, double5: float) -> 'BlackOilFlashResult': ...

class BlackOilFlashResult(java.io.Serializable):
O_std: float = ...
Gf_std: float = ...
W_std: float = ...
V_o: float = ...
V_g: float = ...
V_w: float = ...
rho_o: float = ...
rho_g: float = ...
rho_w: float = ...
mu_o: float = ...
mu_g: float = ...
mu_w: float = ...
Rs: float = ...
Rv: float = ...
Bo: float = ...
Bg: float = ...
Bw: float = ...
def __init__(self): ...

class BlackOilPVTTable(java.io.Serializable):
def __init__(self, list: java.util.List['BlackOilPVTTable.Record'], double: float): ...
def Bg(self, double: float) -> float: ...
def Bo(self, double: float) -> float: ...
def Bw(self, double: float) -> float: ...
def Rs(self, double: float) -> float: ...
def RsEffective(self, double: float) -> float: ...
def Rv(self, double: float) -> float: ...
def getBubblePointP(self) -> float: ...
def mu_g(self, double: float) -> float: ...
def mu_o(self, double: float) -> float: ...
def mu_w(self, double: float) -> float: ...
class Record(java.io.Serializable):
p: float = ...
Rs: float = ...
Bo: float = ...
mu_o: float = ...
Bg: float = ...
mu_g: float = ...
Rv: float = ...
Bw: float = ...
mu_w: float = ...
def __init__(self, double: float, double2: float, double3: float, double4: float, double5: float, double6: float, double7: float, double8: float, double9: float): ...

class SystemBlackOil(java.io.Serializable):
def __init__(self, blackOilPVTTable: BlackOilPVTTable, double: float, double2: float, double3: float): ...
def copyShallow(self) -> 'SystemBlackOil': ...
def flash(self) -> BlackOilFlashResult: ...
def getBg(self) -> float: ...
def getBo(self) -> float: ...
def getBw(self) -> float: ...
def getGasDensity(self) -> float: ...
def getGasReservoirVolume(self) -> float: ...
def getGasStdTotal(self) -> float: ...
def getGasViscosity(self) -> float: ...
def getOilDensity(self) -> float: ...
def getOilReservoirVolume(self) -> float: ...
def getOilStdTotal(self) -> float: ...
def getOilViscosity(self) -> float: ...
def getPressure(self) -> float: ...
def getRs(self) -> float: ...
def getRv(self) -> float: ...
def getTemperature(self) -> float: ...
def getWaterDensity(self) -> float: ...
def getWaterReservoirVolume(self) -> float: ...
def getWaterStd(self) -> float: ...
def getWaterViscosity(self) -> float: ...
def setPressure(self, double: float) -> None: ...
def setStdTotals(self, double: float, double2: float, double3: float) -> None: ...
def setTemperature(self, double: float) -> None: ...


class __module_protocol__(Protocol):
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.blackoil")``.

BlackOilConverter: typing.Type[BlackOilConverter]
BlackOilFlash: typing.Type[BlackOilFlash]
BlackOilFlashResult: typing.Type[BlackOilFlashResult]
BlackOilPVTTable: typing.Type[BlackOilPVTTable]
SystemBlackOil: typing.Type[SystemBlackOil]
io: jneqsim.blackoil.io.__module_protocol__
Loading
Loading