Skip to content

Commit 5c38610

Browse files
committed
update
1 parent c16adef commit 5c38610

File tree

330 files changed

+5410
-5352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

330 files changed

+5410
-5352
lines changed

.github/workflows/generate-stubs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
uses: stefanzweifel/git-auto-commit-action@v5
4343
with:
4444
commit_message: "chore: regenerate Java stubs"
45-
file_pattern: "src/neqsim-stubs/**"
45+
file_pattern: "src/jneqsim-stubs/**"

scripts/generate_stubs.py

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
This enables IDE autocompletion and type checking for the neqsim Java library
55
accessed via JPype.
66
7+
The Java package 'neqsim' is exposed as 'jneqsim' in Python to avoid naming
8+
conflicts with the Python 'neqsim' package. The stubs are generated accordingly.
9+
710
Usage:
811
python scripts/generate_stubs.py
912
10-
The stubs will be generated in the src/neqsim-stubs directory.
13+
The stubs will be generated in the src/jneqsim-stubs directory.
1114
"""
1215

16+
import re
17+
import shutil
1318
import sys
1419
from pathlib import Path
1520

@@ -18,6 +23,25 @@
1823
sys.path.insert(0, str(src_path))
1924

2025

26+
def rename_package_in_stubs(stubs_dir: Path, old_name: str, new_name: str):
27+
"""
28+
Rename all references from old_name to new_name in stub files.
29+
This handles the neqsim -> jneqsim renaming to avoid conflicts
30+
with the Python neqsim package.
31+
"""
32+
for pyi_file in stubs_dir.rglob("*.pyi"):
33+
content = pyi_file.read_text(encoding="utf-8")
34+
35+
# Replace import statements and type references
36+
# Match 'neqsim.' but not 'jneqsim.' (negative lookbehind)
37+
new_content = re.sub(
38+
rf"(?<!j){old_name}\.", f"{new_name}.", content
39+
)
40+
41+
if new_content != content:
42+
pyi_file.write_text(new_content, encoding="utf-8")
43+
44+
2145
def generate_stubs():
2246
"""Generate type stubs for neqsim Java classes."""
2347
import jpype
@@ -32,27 +56,61 @@ def generate_stubs():
3256
# Import the neqsim Java package to get JPackage reference
3357
from neqsim.neqsimpython import jneqsim
3458

35-
# Output directory for stubs
36-
output_dir = src_path / "neqsim-stubs"
37-
output_dir.mkdir(exist_ok=True)
59+
# Temporary output directory (stubgenj will create 'neqsim-stubs')
60+
temp_output_dir = src_path / "temp-stubs"
61+
if temp_output_dir.exists():
62+
shutil.rmtree(temp_output_dir)
63+
temp_output_dir.mkdir(exist_ok=True)
64+
65+
# Final output directory
66+
final_output_dir = src_path / "jneqsim-stubs"
3867

39-
# Generate stubs for the neqsim package
40-
print(f"Generating stubs in {output_dir}...")
68+
print("Generating stubs...")
4169

4270
# Generate stubs for the neqsim package (pass JPackage objects)
43-
# stubgenj expects a list of JPackage objects, not strings
4471
stubgenj.generateJavaStubs(
4572
parentPackages=[jneqsim], # The neqsim JPackage
4673
useStubsSuffix=True, # Creates neqsim-stubs folder structure
47-
outputDir=str(output_dir),
74+
outputDir=str(temp_output_dir),
4875
jpypeJPackageStubs=True, # Include jpype stubs
4976
includeJavadoc=True, # Include javadoc in stubs
5077
)
5178

52-
print(f"Stubs generated successfully in {output_dir}")
53-
print("\nTo use the stubs for type checking, add the stubs path to your IDE.")
54-
print("For VS Code with Pylance, add to settings.json:")
55-
print(' "python.analysis.extraPaths": ["src/neqsim-stubs"]')
79+
# Rename neqsim -> jneqsim in all stub files to avoid conflict
80+
# with Python neqsim package
81+
neqsim_stubs = temp_output_dir / "neqsim-stubs"
82+
if neqsim_stubs.exists():
83+
print("Renaming 'neqsim' -> 'jneqsim' in stubs to avoid naming conflict...")
84+
rename_package_in_stubs(temp_output_dir, "neqsim", "jneqsim")
85+
86+
# Clean up existing output
87+
if final_output_dir.exists():
88+
shutil.rmtree(final_output_dir)
89+
final_output_dir.mkdir(exist_ok=True)
90+
91+
# Move jpype-stubs as-is (it's at temp_output_dir/jpype-stubs)
92+
jpype_stubs = temp_output_dir / "jpype-stubs"
93+
if jpype_stubs.exists():
94+
shutil.move(str(jpype_stubs), str(final_output_dir / "jpype-stubs"))
95+
96+
# Rename folder neqsim-stubs -> jneqsim-stubs
97+
target = final_output_dir / "jneqsim-stubs"
98+
shutil.move(str(neqsim_stubs), str(target))
99+
100+
# Clean up temp directory
101+
shutil.rmtree(temp_output_dir)
102+
103+
print(f"Stubs generated successfully in {final_output_dir}")
104+
print("\n" + "=" * 60)
105+
print("USAGE INSTRUCTIONS")
106+
print("=" * 60)
107+
print("\nThe Java 'neqsim' package stubs are available as 'jneqsim'")
108+
print("to avoid conflicts with the Python 'neqsim' package.")
109+
print("\nFor VS Code with Pylance, add to settings.json:")
110+
print(' "python.analysis.extraPaths": ["src/jneqsim-stubs"]')
111+
print("\nFor mypy, add to pyproject.toml:")
112+
print(' [tool.mypy]')
113+
print(' mypy_path = "src/jneqsim-stubs"')
56114

57115

58116
if __name__ == "__main__":
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
import sys
3+
if sys.version_info >= (3, 8):
4+
from typing import Protocol
5+
else:
6+
from typing_extensions import Protocol
7+
8+
import jneqsim.api
9+
import jneqsim.blackoil
10+
import jneqsim.chemicalreactions
11+
import jneqsim.datapresentation
12+
import jneqsim.fluidmechanics
13+
import jneqsim.mathlib
14+
import jneqsim.physicalproperties
15+
import jneqsim.process
16+
import jneqsim.pvtsimulation
17+
import jneqsim.standards
18+
import jneqsim.statistics
19+
import jneqsim.thermo
20+
import jneqsim.thermodynamicoperations
21+
import jneqsim.util
22+
import typing
23+
24+
25+
class __module_protocol__(Protocol):
26+
# A module protocol which reflects the result of ``jp.JPackage("neqsim")``.
27+
28+
api: jneqsim.api.__module_protocol__
29+
blackoil: jneqsim.blackoil.__module_protocol__
30+
chemicalreactions: jneqsim.chemicalreactions.__module_protocol__
31+
datapresentation: jneqsim.datapresentation.__module_protocol__
32+
fluidmechanics: jneqsim.fluidmechanics.__module_protocol__
33+
mathlib: jneqsim.mathlib.__module_protocol__
34+
physicalproperties: jneqsim.physicalproperties.__module_protocol__
35+
process: jneqsim.process.__module_protocol__
36+
pvtsimulation: jneqsim.pvtsimulation.__module_protocol__
37+
standards: jneqsim.standards.__module_protocol__
38+
statistics: jneqsim.statistics.__module_protocol__
39+
thermo: jneqsim.thermo.__module_protocol__
40+
thermodynamicoperations: jneqsim.thermodynamicoperations.__module_protocol__
41+
util: jneqsim.util.__module_protocol__

src/neqsim-stubs/neqsim-stubs/api/__init__.pyi renamed to src/jneqsim-stubs/jneqsim-stubs/api/__init__.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ if sys.version_info >= (3, 8):
55
else:
66
from typing_extensions import Protocol
77

8-
import neqsim.api.ioc
8+
import jneqsim.api.ioc
99
import typing
1010

1111

1212
class __module_protocol__(Protocol):
13-
# A module protocol which reflects the result of ``jp.JPackage("neqsim.api")``.
13+
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.api")``.
1414

15-
ioc: neqsim.api.ioc.__module_protocol__
15+
ioc: jneqsim.api.ioc.__module_protocol__

src/neqsim-stubs/neqsim-stubs/api/ioc/__init__.pyi renamed to src/jneqsim-stubs/jneqsim-stubs/api/ioc/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ class CalculationResult:
2020

2121

2222
class __module_protocol__(Protocol):
23-
# A module protocol which reflects the result of ``jp.JPackage("neqsim.api.ioc")``.
23+
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.api.ioc")``.
2424

2525
CalculationResult: typing.Type[CalculationResult]

src/neqsim-stubs/neqsim-stubs/blackoil/__init__.pyi renamed to src/jneqsim-stubs/jneqsim-stubs/blackoil/__init__.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ else:
77

88
import java.util
99
import jpype
10-
import neqsim.blackoil.io
11-
import neqsim.thermo.system
10+
import jneqsim.blackoil.io
11+
import jneqsim.thermo.system
1212
import typing
1313

1414

1515

1616
class BlackOilConverter:
1717
def __init__(self): ...
1818
@staticmethod
19-
def convert(systemInterface: neqsim.thermo.system.SystemInterface, double: float, doubleArray: typing.Union[typing.List[float], jpype.JArray], double3: float, double4: float) -> 'BlackOilConverter.Result': ...
19+
def convert(systemInterface: jneqsim.thermo.system.SystemInterface, double: float, doubleArray: typing.Union[typing.List[float], jpype.JArray], double3: float, double4: float) -> 'BlackOilConverter.Result': ...
2020
class Result:
2121
pvt: 'BlackOilPVTTable' = ...
2222
blackOilSystem: 'SystemBlackOil' = ...
@@ -103,11 +103,11 @@ class SystemBlackOil:
103103

104104

105105
class __module_protocol__(Protocol):
106-
# A module protocol which reflects the result of ``jp.JPackage("neqsim.blackoil")``.
106+
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.blackoil")``.
107107

108108
BlackOilConverter: typing.Type[BlackOilConverter]
109109
BlackOilFlash: typing.Type[BlackOilFlash]
110110
BlackOilFlashResult: typing.Type[BlackOilFlashResult]
111111
BlackOilPVTTable: typing.Type[BlackOilPVTTable]
112112
SystemBlackOil: typing.Type[SystemBlackOil]
113-
io: neqsim.blackoil.io.__module_protocol__
113+
io: jneqsim.blackoil.io.__module_protocol__

src/neqsim-stubs/neqsim-stubs/blackoil/io/__init__.pyi renamed to src/jneqsim-stubs/jneqsim-stubs/blackoil/io/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.lang
1010
import java.nio.file
1111
import java.util
1212
import jpype.protocol
13-
import neqsim.blackoil
13+
import jneqsim.blackoil
1414
import typing
1515

1616

@@ -22,8 +22,8 @@ class EclipseBlackOilImporter:
2222
@staticmethod
2323
def fromReader(reader: java.io.Reader) -> 'EclipseBlackOilImporter.Result': ...
2424
class Result:
25-
pvt: neqsim.blackoil.BlackOilPVTTable = ...
26-
system: neqsim.blackoil.SystemBlackOil = ...
25+
pvt: jneqsim.blackoil.BlackOilPVTTable = ...
26+
system: jneqsim.blackoil.SystemBlackOil = ...
2727
rho_o_sc: float = ...
2828
rho_w_sc: float = ...
2929
rho_g_sc: float = ...
@@ -46,6 +46,6 @@ class EclipseBlackOilImporter:
4646

4747

4848
class __module_protocol__(Protocol):
49-
# A module protocol which reflects the result of ``jp.JPackage("neqsim.blackoil.io")``.
49+
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.blackoil.io")``.
5050

5151
EclipseBlackOilImporter: typing.Type[EclipseBlackOilImporter]

src/neqsim-stubs/neqsim-stubs/chemicalreactions/__init__.pyi renamed to src/jneqsim-stubs/jneqsim-stubs/chemicalreactions/__init__.pyi

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ else:
66
from typing_extensions import Protocol
77

88
import java.lang
9-
import neqsim.chemicalreactions.chemicalequilibrium
10-
import neqsim.chemicalreactions.chemicalreaction
11-
import neqsim.chemicalreactions.kinetics
12-
import neqsim.thermo
13-
import neqsim.thermo.phase
14-
import neqsim.thermo.system
9+
import jneqsim.chemicalreactions.chemicalequilibrium
10+
import jneqsim.chemicalreactions.chemicalreaction
11+
import jneqsim.chemicalreactions.kinetics
12+
import jneqsim.thermo
13+
import jneqsim.thermo.phase
14+
import jneqsim.thermo.system
1515
import typing
1616

1717

1818

19-
class ChemicalReactionOperations(neqsim.thermo.ThermodynamicConstantsInterface, java.lang.Cloneable):
20-
def __init__(self, systemInterface: neqsim.thermo.system.SystemInterface): ...
19+
class ChemicalReactionOperations(jneqsim.thermo.ThermodynamicConstantsInterface, java.lang.Cloneable):
20+
def __init__(self, systemInterface: jneqsim.thermo.system.SystemInterface): ...
2121
def addNewComponents(self) -> None: ...
2222
def calcBVector(self) -> typing.MutableSequence[float]: ...
2323
def calcChemRefPot(self, int: int) -> typing.MutableSequence[float]: ...
@@ -26,8 +26,8 @@ class ChemicalReactionOperations(neqsim.thermo.ThermodynamicConstantsInterface,
2626
def clone(self) -> 'ChemicalReactionOperations': ...
2727
def getAllElements(self) -> typing.MutableSequence[java.lang.String]: ...
2828
def getDeltaReactionHeat(self) -> float: ...
29-
def getKinetics(self) -> neqsim.chemicalreactions.kinetics.Kinetics: ...
30-
def getReactionList(self) -> neqsim.chemicalreactions.chemicalreaction.ChemicalReactionList: ...
29+
def getKinetics(self) -> jneqsim.chemicalreactions.kinetics.Kinetics: ...
30+
def getReactionList(self) -> jneqsim.chemicalreactions.chemicalreaction.ChemicalReactionList: ...
3131
def hasReactions(self) -> bool: ...
3232
def reacHeat(self, int: int, string: typing.Union[java.lang.String, str]) -> float: ...
3333
@typing.overload
@@ -39,20 +39,20 @@ class ChemicalReactionOperations(neqsim.thermo.ThermodynamicConstantsInterface,
3939
def setReactiveComponents(self) -> None: ...
4040
@typing.overload
4141
def setReactiveComponents(self, int: int) -> None: ...
42-
def setSystem(self, systemInterface: neqsim.thermo.system.SystemInterface) -> None: ...
42+
def setSystem(self, systemInterface: jneqsim.thermo.system.SystemInterface) -> None: ...
4343
@typing.overload
4444
def solveChemEq(self, int: int) -> bool: ...
4545
@typing.overload
4646
def solveChemEq(self, int: int, int2: int) -> bool: ...
47-
def solveKinetics(self, int: int, phaseInterface: neqsim.thermo.phase.PhaseInterface, int2: int) -> float: ...
47+
def solveKinetics(self, int: int, phaseInterface: jneqsim.thermo.phase.PhaseInterface, int2: int) -> float: ...
4848
def sortReactiveComponents(self) -> None: ...
4949
def updateMoles(self, int: int) -> None: ...
5050

5151

5252
class __module_protocol__(Protocol):
53-
# A module protocol which reflects the result of ``jp.JPackage("neqsim.chemicalreactions")``.
53+
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.chemicalreactions")``.
5454

5555
ChemicalReactionOperations: typing.Type[ChemicalReactionOperations]
56-
chemicalequilibrium: neqsim.chemicalreactions.chemicalequilibrium.__module_protocol__
57-
chemicalreaction: neqsim.chemicalreactions.chemicalreaction.__module_protocol__
58-
kinetics: neqsim.chemicalreactions.kinetics.__module_protocol__
56+
chemicalequilibrium: jneqsim.chemicalreactions.chemicalequilibrium.__module_protocol__
57+
chemicalreaction: jneqsim.chemicalreactions.chemicalreaction.__module_protocol__
58+
kinetics: jneqsim.chemicalreactions.kinetics.__module_protocol__

src/neqsim-stubs/neqsim-stubs/chemicalreactions/chemicalequilibrium/__init__.pyi renamed to src/jneqsim-stubs/jneqsim-stubs/chemicalreactions/chemicalequilibrium/__init__.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import java.io
1010
import java.lang
1111
import java.util
1212
import jpype
13-
import neqsim.chemicalreactions
14-
import neqsim.thermo
15-
import neqsim.thermo.component
16-
import neqsim.thermo.system
13+
import jneqsim.chemicalreactions
14+
import jneqsim.thermo
15+
import jneqsim.thermo.component
16+
import jneqsim.thermo.system
1717
import typing
1818

1919

@@ -36,7 +36,7 @@ class ChemEq(java.io.Serializable):
3636
def step(self) -> float: ...
3737

3838
class ChemicalEquilibrium(java.io.Serializable):
39-
def __init__(self, doubleArray: typing.Union[typing.List[typing.MutableSequence[float]], jpype.JArray], doubleArray2: typing.Union[typing.List[float], jpype.JArray], systemInterface: neqsim.thermo.system.SystemInterface, componentInterfaceArray: typing.Union[typing.List[neqsim.thermo.component.ComponentInterface], jpype.JArray], int: int): ...
39+
def __init__(self, doubleArray: typing.Union[typing.List[typing.MutableSequence[float]], jpype.JArray], doubleArray2: typing.Union[typing.List[float], jpype.JArray], systemInterface: jneqsim.thermo.system.SystemInterface, componentInterfaceArray: typing.Union[typing.List[jneqsim.thermo.component.ComponentInterface], jpype.JArray], int: int): ...
4040
def calcRefPot(self) -> None: ...
4141
def chemSolve(self) -> None: ...
4242
def getMoles(self) -> typing.MutableSequence[float]: ...
@@ -46,22 +46,22 @@ class ChemicalEquilibrium(java.io.Serializable):
4646
def step(self) -> float: ...
4747
def updateMoles(self) -> None: ...
4848

49-
class LinearProgrammingChemicalEquilibrium(neqsim.thermo.ThermodynamicConstantsInterface):
50-
def __init__(self, doubleArray: typing.Union[typing.List[float], jpype.JArray], componentInterfaceArray: typing.Union[typing.List[neqsim.thermo.component.ComponentInterface], jpype.JArray], stringArray: typing.Union[typing.List[java.lang.String], jpype.JArray], chemicalReactionOperations: neqsim.chemicalreactions.ChemicalReactionOperations, int: int): ...
49+
class LinearProgrammingChemicalEquilibrium(jneqsim.thermo.ThermodynamicConstantsInterface):
50+
def __init__(self, doubleArray: typing.Union[typing.List[float], jpype.JArray], componentInterfaceArray: typing.Union[typing.List[jneqsim.thermo.component.ComponentInterface], jpype.JArray], stringArray: typing.Union[typing.List[java.lang.String], jpype.JArray], chemicalReactionOperations: jneqsim.chemicalreactions.ChemicalReactionOperations, int: int): ...
5151
def calcA(self) -> typing.MutableSequence[typing.MutableSequence[float]]: ...
5252
def calcx(self, matrix: Jama.Matrix, matrix2: Jama.Matrix) -> None: ...
5353
def changePrimaryComponents(self) -> None: ...
54-
def generateInitialEstimates(self, systemInterface: neqsim.thermo.system.SystemInterface, doubleArray: typing.Union[typing.List[float], jpype.JArray], double2: float, int: int) -> typing.MutableSequence[float]: ...
54+
def generateInitialEstimates(self, systemInterface: jneqsim.thermo.system.SystemInterface, doubleArray: typing.Union[typing.List[float], jpype.JArray], double2: float, int: int) -> typing.MutableSequence[float]: ...
5555
def getA(self) -> typing.MutableSequence[typing.MutableSequence[float]]: ...
5656
def getRefPot(self) -> typing.MutableSequence[float]: ...
5757

58-
class ReferencePotComparator(java.util.Comparator[neqsim.thermo.component.ComponentInterface], java.io.Serializable):
58+
class ReferencePotComparator(java.util.Comparator[jneqsim.thermo.component.ComponentInterface], java.io.Serializable):
5959
def __init__(self): ...
60-
def compare(self, componentInterface: neqsim.thermo.component.ComponentInterface, componentInterface2: neqsim.thermo.component.ComponentInterface) -> int: ...
60+
def compare(self, componentInterface: jneqsim.thermo.component.ComponentInterface, componentInterface2: jneqsim.thermo.component.ComponentInterface) -> int: ...
6161

6262

6363
class __module_protocol__(Protocol):
64-
# A module protocol which reflects the result of ``jp.JPackage("neqsim.chemicalreactions.chemicalequilibrium")``.
64+
# A module protocol which reflects the result of ``jp.JPackage("jneqsim.chemicalreactions.chemicalequilibrium")``.
6565

6666
ChemEq: typing.Type[ChemEq]
6767
ChemicalEquilibrium: typing.Type[ChemicalEquilibrium]

0 commit comments

Comments
 (0)