Comments (6)
This error sounds like Python is preferring to load the folder called bridgestan
over the Python module. The easiest thing to do is probably to re-name the downloaded bridgestan to something like bridgestan_repo
and then pip install bridgestan_repo/python
from bridgestan.
Hi, I updated the module import, but it shows a new error.
import bridgestan.python.bridgestan as bs
import numpy as np
stan = "../test_models/bernoulli/bernoulli.stan"
data = "../test_models/bernoulli/bernoulli.data.json"
model = bs.StanModel.from_stan_file(stan, data)
print(f"This model's name is {model.name()}.")
print(f"It has {model.param_num()} parameters.")
x = np.random.random(model.param_unc_num())
q = np.log(x / (1 - x)) # unconstrained scale
lp, grad = model.log_density_gradient(q, jacobian=False)
print(f"log_density and gradient of Bernoulli model: {(lp, grad)}")
Error msg:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[<ipython-input-22-fb3d9974c29f>](https://localhost:8080/#) in <module>
4 stan = "../test_models/bernoulli/bernoulli.stan"
5 data = "../test_models/bernoulli/bernoulli.data.json"
----> 6 model = bs.StanModel.from_stan_file(stan, data)
7
8 print(f"This model's name is {model.name()}.")
[/content/bridgestan/python/bridgestan/model.py](https://localhost:8080/#) in from_stan_file(cls, stan_file, model_data, stanc_args, make_args, seed, chain_id)
196 :raises RuntimeError: If compilation fails.
197 """
--> 198 result = compile_model(stan_file, stanc_args=stanc_args, make_args=make_args)
199 return cls(str(result), model_data, seed=seed, chain_id=chain_id)
200
[/content/bridgestan/python/bridgestan/compile.py](https://localhost:8080/#) in compile_model(stan_file, stanc_args, make_args)
84
85 stanc_args
---> 86 output = generate_so_name(file_path)
87 cmd = (
88 [MAKE]
[/content/bridgestan/python/bridgestan/compile.py](https://localhost:8080/#) in generate_so_name(model)
51 def generate_so_name(model: Path):
52 name = model.stem
---> 53 return model.with_stem(f"{name}_model").with_suffix(".so")
54
55
AttributeError: 'PosixPath' object has no attribute 'with_stem'
from bridgestan.
That seems like you’re using a version of python earlier than 3.9, which is the minimum version we support. It’s possible changing that one thing is all you’d need to use an older version, but there could be more places we use 3.9 specific code
from bridgestan.
The error actually happened in Python 3.9.16. Here is the google colab file I'm running. Even in Python 3.9.16, the posix error keeps showing.
from bridgestan.
I ran your file and confirmed the output. But, I then added this cell:
import sys
sys.version
3.8.10 (default, Nov 14 2022, 12:59:47) \n[GCC 9.4.0]
The google collab kernel you are using seems to be detached from the python
command in the collab workspace.
from bridgestan.
Interesting, thx!
from bridgestan.
Related Issues (20)
- Python ctypes.CDDL compiled binary loading error HOT 5
- Can/should StanRNG API be more consistent across the interfaces? HOT 4
- Error in R/example.R HOT 1
- Hessian-vector product from stan-dev/math HOT 1
- Runtime errors during `param_unconstrain` because of precision issues HOT 7
- feature request: `theta_unc` taking multi dimensional arrays as input. HOT 6
- Error in `R/example.R` HOT 20
- Add to Getting Started doc necessary dependencies on Stan and Stan Math HOT 3
- Add to Getting Started doc recommendation to use --shallow-submodules HOT 5
- Add to Getting Started doc how to specify pre-existing Stan directory HOT 1
- Add to doc a section highlighting the functionality or lack there of across the interfaces HOT 3
- Julia tests require STAN_THREADS=true, doc this
- TBB path issue on Windows HOT 2
- Missing support for precompiled header HOT 25
- Tracking: Changes in the next version of Stan
- Better Error Message for Python Interface Automatically Downloading BridgeStan Source HOT 1
- bridgestan on Julia crashes on windows if .julia path has spaces HOT 5
- clang argument error during model compile on MacOS HOT 14
- Functionality necessary to nest Stan models in other PPLs HOT 13
- Tracking: Changes in Stan 2.34
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bridgestan.